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,900
0x9792fB4c8Fcca2C18d836839c54D1d5F313A139e
// SPDX-License-Identifier: MIT // Developed by KG Technologies (https://kgtechnologies.io) pragma solidity 0.8.11; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; /** * @notice Represents Slotie Smart Contract */ contract ISlotie { /** * @dev ERC-721 INTERFACE */ function ownerOf(uint256 tokenId) public view virtual returns (address) {} /** * @dev CUSTOM INTERFACE */ function mintTo(uint256 amount, address _to) external {} } contract ISlotieJr { /** * @dev ERC-721 INTERFACE */ function ownerOf(uint256 tokenId) public view virtual returns (address) {} function totalSupply() public view returns (uint256) {} /** * @dev CUSTOM INTERFACE */ function mintTo(uint256 amount, address _to) external {} function maxMintPerTransaction() public returns (uint256) {} } abstract contract IWatts is IERC20 { function burn(address _from, uint256 _amount) external {} function seeClaimableBalanceOfUser(address user) external view returns(uint256) {} function seeClaimableTotalSupply() external view returns(uint256) {} function burnClaimable(address _from, uint256 _amount) public {} function transferOwnership(address newOwner) public {} function setSlotieNFT(address newSlotieNFT) external {} function setLockPeriod(uint256 newLockPeriod) external {} function setIsBlackListed(address _address, bool _isBlackListed) external {} } /** * @title SlotieJrBreeding. * * @author KG Technologies (https://kgtechnologies.io). * * @notice This Smart Contract can be used to breed Slotie NFTs. * * @dev The primary mode of verifying permissioned actions is through Merkle Proofs * which are generated off-chain. */ contract SlotieJrBreeding is Ownable { /** * @notice The Smart Contract of Slotie * @dev ERC-721 Smart Contract */ ISlotie public immutable slotie; /** * @notice The Smart Contract of Slotie Jr. * @dev ERC-721 Smart Contract */ ISlotieJr public immutable slotiejr; /** * @notice The Smart Contract of Watts. * @dev ERC-20 Smart Contract */ IWatts public immutable watts; /** * @dev BREED DATA */ uint256 public maxBreedableJuniors = 5000; bool public isBreedingStarted = false; uint256 public breedPrice = 1800 ether; uint256 public breedCoolDown = 2 * 30 days; mapping(uint256 => uint256) public slotieToLastBreedTimeStamp; bytes32 public merkleRoot = 0x92b34b7175c93f0db8f32e6996287e5d3141e4364dcc5f03e3f3b0454d999605; /** * @dev TRACKING DATA */ uint256 public bornJuniors; /** * @dev Events */ event ReceivedEther(address indexed sender, uint256 indexed amount); event Bred(address initiator, uint256 indexed father, uint256 indexed mother, uint256 indexed slotieJr); event setMerkleRootEvent(bytes32 indexed root); event setIsBreedingStartedEvent(bool indexed started); event setMaxBreedableJuniorsEvent(uint256 indexed maxMintable); event setBreedCoolDownEvent(uint256 indexed coolDown); event setBreedPriceEvent(uint256 indexed price); event WithdrawAllEvent(address indexed recipient, uint256 amount); constructor( address slotieAddress, address slotieJrAddress, address wattsAddress ) Ownable() { slotie = ISlotie(slotieAddress); slotiejr = ISlotieJr(slotieJrAddress); watts = IWatts(wattsAddress); } /** * @dev BREEDING */ function breed( uint256 father, uint256 mother, uint256 fatherStart, uint256 motherStart, bytes32[] calldata fatherProof, bytes32[] calldata motherProof ) external { require(isBreedingStarted, "BREEDING NOT STARTED"); require(address(slotie) != address(0), "SLOTIE NFT NOT SET"); require(address(slotiejr) != address(0), "SLOTIE JR NFT NOT SET"); require(address(watts) != address(0), "WATTS NOT SET"); require(bornJuniors < maxBreedableJuniors, "MAX JUNIORS HAVE BEEN BRED"); require(father != mother, "CANNOT BREED THE SAME SLOTIE"); require(slotie.ownerOf(father) == msg.sender, "SENDER NOT OWNER OF FATHER"); require(slotie.ownerOf(mother) == msg.sender, "SENDER NOT OWNER OF MOTHER"); uint256 fatherLastBred = slotieToLastBreedTimeStamp[father]; uint256 motherLastBred = slotieToLastBreedTimeStamp[mother]; /** * @notice Check if father can breed based based on time logic * * @dev If father hasn't bred before we check the merkle proof to see * if it can breed already. If it has bred already we check if it's passed the * cooldown period. */ if (fatherLastBred != 0) { require(block.timestamp >= fatherLastBred + breedCoolDown, "FATHER IS STILL IN COOLDOWN"); } /// @dev see father. if (motherLastBred != 0) { require(block.timestamp >= motherLastBred + breedCoolDown, "MOTHER IS STILL IN COOLDOWN"); } if (fatherLastBred == 0 || motherLastBred == 0) { bytes32 leafFather = keccak256(abi.encodePacked(father, fatherStart, fatherLastBred)); bytes32 leafMother = keccak256(abi.encodePacked(mother, motherStart, motherLastBred)); require(MerkleProof.verify(fatherProof, merkleRoot, leafFather), "INVALID PROOF FOR FATHER"); require(MerkleProof.verify(motherProof, merkleRoot, leafMother), "INVALID PROOF FOR MOTHER"); require(block.timestamp >= fatherStart || block.timestamp >= motherStart, "SLOTIES CANNOT CANNOT BREED YET"); } slotieToLastBreedTimeStamp[father] = block.timestamp; slotieToLastBreedTimeStamp[mother] = block.timestamp; bornJuniors++; require(watts.balanceOf(msg.sender) >= breedPrice, "SENDER DOES NOT HAVE ENOUGH WATTS"); uint256 claimableBalance = watts.seeClaimableBalanceOfUser(msg.sender); uint256 burnFromClaimable = claimableBalance >= breedPrice ? breedPrice : claimableBalance; uint256 burnFromBalance = claimableBalance >= breedPrice ? 0 : breedPrice - claimableBalance; if (claimableBalance > 0) { watts.burnClaimable(msg.sender, burnFromClaimable); } if (burnFromBalance > 0) { watts.burn(msg.sender, burnFromBalance); } slotiejr.mintTo(1, msg.sender); emit Bred(msg.sender, father, mother, slotiejr.totalSupply()); } /** * @dev OWNER ONLY */ /** * @notice function to set the merkle root for breeding. * * @param _merkleRoot. The new merkle root to set. */ function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner { merkleRoot = _merkleRoot; emit setMerkleRootEvent(_merkleRoot); } /** * @notice function to turn on/off breeding. * * @param _status. The new state of the breeding. */ function setBreedingStatus(bool _status) external onlyOwner { isBreedingStarted = _status; emit setIsBreedingStartedEvent(_status); } /** * @notice function to set the maximum amount of juniors that can be bred. * * @param max. The new maximum. */ function setMaxBreedableJuniors(uint256 max) external onlyOwner { maxBreedableJuniors = max; emit setMaxBreedableJuniorsEvent(max); } /** * @notice function to set the cooldown period for breeding a slotie. * * @param coolDown. The new cooldown period. */ function setBreedCoolDown(uint256 coolDown) external onlyOwner { breedCoolDown = coolDown; emit setBreedCoolDownEvent(coolDown); } /** * @notice function to set the watts price for breeding two sloties. * * @param price. The new watts price. */ function setBreedPice(uint256 price) external onlyOwner { breedPrice = price; emit setBreedPriceEvent(price); } /** * @dev WATTS OWNER */ function WATTSOWNER_TransferOwnership(address newOwner) external onlyOwner { watts.transferOwnership(newOwner); } function WATTSOWNER_SetSlotieNFT(address newSlotie) external onlyOwner { watts.setSlotieNFT(newSlotie); } function WATTSOWNER_SetLockPeriod(uint256 newLockPeriod) external onlyOwner { watts.setLockPeriod(newLockPeriod); } function WATTSOWNER_SetIsBlackListed(address _set, bool _is) external onlyOwner { watts.setIsBlackListed(_set, _is); } function WATTSOWNER_seeClaimableBalanceOfUser(address user) external view onlyOwner returns (uint256) { return watts.seeClaimableBalanceOfUser(user); } function WATTSOWNER_seeClaimableTotalSupply() external view onlyOwner returns (uint256) { return watts.seeClaimableTotalSupply(); } /** * @dev FINANCE */ /** * @notice Allows owner to withdraw funds generated from sale. * * @param _to. The address to send the funds to. */ function withdrawAll(address _to) external onlyOwner { require(_to != address(0), "CANNOT WITHDRAW TO ZERO ADDRESS"); uint256 contractBalance = address(this).balance; require(contractBalance > 0, "NO ETHER TO WITHDRAW"); payable(_to).transfer(contractBalance); emit WithdrawAllEvent(_to, contractBalance); } /** * @dev Fallback function for receiving Ether */ receive() external payable { emit ReceivedEther(msg.sender, msg.value); } } // 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/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.0 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.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; } }
0x6080604052600436106101845760003560e01c80639c0132f2116100d1578063de8643d41161008a578063f583750e11610064578063f583750e146104b3578063f859bf8e146104d3578063f9dd6579146104f3578063fa09e6301461051357600080fd5b8063de8643d414610453578063eeae08d414610473578063f2fde38b1461049357600080fd5b80639c0132f21461039e578063a5c4f1d9146103be578063af7fc562146103de578063ca32eff5146103f4578063d108a18914610409578063d78bbe591461042957600080fd5b80636fdb02161161013e5780637fcdecbb116101185780637fcdecbb146103165780638da5cb5b1461032c5780638f068ba01461034a578063944c21ec1461037e57600080fd5b80636fdb0216146102ad578063715018a6146102e15780637cb64759146102f657600080fd5b8062ee3a7f146101bd5780630e8821d2146101df5780630fdb4715146102085780632a5f510e146102545780632eb4a7ab1461026a5780634365433b1461028057600080fd5b366101b857604051349033907fa419615bc8fda4c87663805ee2a3597a6d71c1d476911d9892f340d965bc7bf190600090a3005b600080fd5b3480156101c957600080fd5b506101dd6101d83660046118dd565b610533565b005b3480156101eb57600080fd5b506101f560015481565b6040519081526020015b60405180910390f35b34801561021457600080fd5b5061023c7f0000000000000000000000005fdb2b0c56afa73b8ca2228e6ab92be90325961d81565b6040516001600160a01b0390911681526020016101ff565b34801561026057600080fd5b506101f560035481565b34801561027657600080fd5b506101f560065481565b34801561028c57600080fd5b506101f561029b3660046118dd565b60056020526000908152604090205481565b3480156102b957600080fd5b5061023c7f0000000000000000000000005dff0b226fde7085a850aff06e2ea62d1ad506f581565b3480156102ed57600080fd5b506101dd610599565b34801561030257600080fd5b506101dd6103113660046118dd565b6105cf565b34801561032257600080fd5b506101f560075481565b34801561033857600080fd5b506000546001600160a01b031661023c565b34801561035657600080fd5b5061023c7f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd081565b34801561038a57600080fd5b506101dd610399366004611906565b61062c565b3480156103aa57600080fd5b506101dd6103b936600461193d565b610693565b3480156103ca57600080fd5b506101f56103d936600461193d565b61073c565b3480156103ea57600080fd5b506101f560045481565b34801561040057600080fd5b506101f56107f9565b34801561041557600080fd5b506101dd6104243660046118dd565b6108ab565b34801561043557600080fd5b506002546104439060ff1681565b60405190151581526020016101ff565b34801561045f57600080fd5b506101dd61046e3660046118dd565b610922565b34801561047f57600080fd5b506101dd61048e3660046118dd565b61097f565b34801561049f57600080fd5b506101dd6104ae36600461193d565b6109dc565b3480156104bf57600080fd5b506101dd6104ce36600461195a565b610a77565b3480156104df57600080fd5b506101dd6104ee3660046119db565b610b28565b3480156104ff57600080fd5b506101dd61050e36600461193d565b611610565b34801561051f57600080fd5b506101dd61052e36600461193d565b611688565b6000546001600160a01b031633146105665760405162461bcd60e51b815260040161055d90611a71565b60405180910390fd5b600481905560405181907f44bcd365c93e8d375fed9d768aef4a979c0654ea26d43bcedc0840a959a418df90600090a250565b6000546001600160a01b031633146105c35760405162461bcd60e51b815260040161055d90611a71565b6105cd60006117cb565b565b6000546001600160a01b031633146105f95760405162461bcd60e51b815260040161055d90611a71565b600681905560405181907f514d2649f6bc26024ef36a98d0bf2bd3b1212d7fceaf99f6086e9690d0032fc790600090a250565b6000546001600160a01b031633146106565760405162461bcd60e51b815260040161055d90611a71565b6002805460ff19168215159081179091556040517f5ccaafc0be07c3fb2143f33544d0be1eb157c8f9d4d07624b7dca45b083d8e1790600090a250565b6000546001600160a01b031633146106bd5760405162461bcd60e51b815260040161055d90611a71565b60405163f2fde38b60e01b81526001600160a01b0382811660048301527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd0169063f2fde38b906024015b600060405180830381600087803b15801561072157600080fd5b505af1158015610735573d6000803e3d6000fd5b5050505050565b600080546001600160a01b031633146107675760405162461bcd60e51b815260040161055d90611a71565b604051632ac7dc5960e11b81526001600160a01b0383811660048301527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd0169063558fb8b290602401602060405180830381865afa1580156107cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f19190611aa6565b90505b919050565b600080546001600160a01b031633146108245760405162461bcd60e51b815260040161055d90611a71565b7f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b0316635fc79ded6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610882573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a69190611aa6565b905090565b6000546001600160a01b031633146108d55760405162461bcd60e51b815260040161055d90611a71565b604051633bccb96d60e11b8152600481018290527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b03169063779972da90602401610707565b6000546001600160a01b0316331461094c5760405162461bcd60e51b815260040161055d90611a71565b600381905560405181907fa123b60cf5b156b3cf895693c6a53b21f21d51c8d7d3445a9d8afea4cd95801990600090a250565b6000546001600160a01b031633146109a95760405162461bcd60e51b815260040161055d90611a71565b600181905560405181907f0acfff8000f703ad71456fb1646b4382e48b9cdad7b9f205458e67dfdcb8861e90600090a250565b6000546001600160a01b03163314610a065760405162461bcd60e51b815260040161055d90611a71565b6001600160a01b038116610a6b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161055d565b610a74816117cb565b50565b6000546001600160a01b03163314610aa15760405162461bcd60e51b815260040161055d90611a71565b60405163aa71830d60e01b81526001600160a01b03838116600483015282151560248301527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd0169063aa71830d90604401600060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050505050565b60025460ff16610b715760405162461bcd60e51b81526020600482015260146024820152731094915151125391c81393d50814d5105495115160621b604482015260640161055d565b7f0000000000000000000000005fdb2b0c56afa73b8ca2228e6ab92be90325961d6001600160a01b0316610bdc5760405162461bcd60e51b815260206004820152601260248201527114d313d5125148139195081393d50814d15560721b604482015260640161055d565b7f0000000000000000000000005dff0b226fde7085a850aff06e2ea62d1ad506f56001600160a01b0316610c4a5760405162461bcd60e51b815260206004820152601560248201527414d313d5125148129488139195081393d50814d155605a1b604482015260640161055d565b7f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b0316610cb05760405162461bcd60e51b815260206004820152600d60248201526c15d0551514c81393d50814d155609a1b604482015260640161055d565b60015460075410610d035760405162461bcd60e51b815260206004820152601a60248201527f4d4158204a554e494f52532048415645204245454e2042524544000000000000604482015260640161055d565b86881415610d535760405162461bcd60e51b815260206004820152601c60248201527f43414e4e4f54204252454544205448452053414d4520534c4f54494500000000604482015260640161055d565b6040516331a9108f60e11b81526004810189905233906001600160a01b037f0000000000000000000000005fdb2b0c56afa73b8ca2228e6ab92be90325961d1690636352211e90602401602060405180830381865afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde9190611abf565b6001600160a01b031614610e345760405162461bcd60e51b815260206004820152601a60248201527f53454e444552204e4f54204f574e4552204f4620464154484552000000000000604482015260640161055d565b6040516331a9108f60e11b81526004810188905233906001600160a01b037f0000000000000000000000005fdb2b0c56afa73b8ca2228e6ab92be90325961d1690636352211e90602401602060405180830381865afa158015610e9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebf9190611abf565b6001600160a01b031614610f155760405162461bcd60e51b815260206004820152601a60248201527f53454e444552204e4f54204f574e4552204f46204d4f54484552000000000000604482015260640161055d565b600088815260056020526040808220548983529120548115610f8d57600454610f3e9083611af2565b421015610f8d5760405162461bcd60e51b815260206004820152601b60248201527f464154484552204953205354494c4c20494e20434f4f4c444f574e0000000000604482015260640161055d565b8015610fef57600454610fa09082611af2565b421015610fef5760405162461bcd60e51b815260206004820152601b60248201527f4d4f54484552204953205354494c4c20494e20434f4f4c444f574e0000000000604482015260640161055d565b811580610ffa575080155b156111e05760408051602081018c90529081018990526060810183905260009060800160408051601f1981840301815282825280516020918201209083018d90529082018a90526060820184905291506000906080016040516020818303038152906040528051906020012090506110a988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600654915085905061181b565b6110f55760405162461bcd60e51b815260206004820152601860248201527f494e56414c49442050524f4f4620464f52204641544845520000000000000000604482015260640161055d565b61113686868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600654915084905061181b565b6111825760405162461bcd60e51b815260206004820152601860248201527f494e56414c49442050524f4f4620464f52204d4f544845520000000000000000604482015260640161055d565b89421015806111915750884210155b6111dd5760405162461bcd60e51b815260206004820152601f60248201527f534c4f544945532043414e4e4f542043414e4e4f542042524545442059455400604482015260640161055d565b50505b60008a81526005602052604080822042908190558b835290822055600780549161120983611b0a565b90915550506003546040516370a0823160e01b81523360048201527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b0316906370a0823190602401602060405180830381865afa158015611275573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112999190611aa6565b10156112f15760405162461bcd60e51b815260206004820152602160248201527f53454e44455220444f4553204e4f54204841564520454e4f55474820574154546044820152605360f81b606482015260840161055d565b604051632ac7dc5960e11b81523360048201526000907f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b03169063558fb8b290602401602060405180830381865afa158015611358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137c9190611aa6565b905060006003548210156113905781611394565b6003545b905060006003548310156113b557826003546113b09190611b25565b6113b8565b60005b905082156114415760405163f839f52b60e01b8152336004820152602481018390527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b03169063f839f52b90604401600060405180830381600087803b15801561142857600080fd5b505af115801561143c573d6000803e3d6000fd5b505050505b80156114c857604051632770a7eb60e21b8152336004820152602481018290527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd06001600160a01b031690639dc29fac90604401600060405180830381600087803b1580156114af57600080fd5b505af11580156114c3573d6000803e3d6000fd5b505050505b604051635b91d9a760e11b8152600160048201523360248201527f0000000000000000000000005dff0b226fde7085a850aff06e2ea62d1ad506f56001600160a01b03169063b723b34e90604401600060405180830381600087803b15801561153057600080fd5b505af1158015611544573d6000803e3d6000fd5b505050507f0000000000000000000000005dff0b226fde7085a850aff06e2ea62d1ad506f56001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ca9190611aa6565b6040513381528d908f907faab5ef98a3dfce3cf76b96b59d41509a6d3e456d17a4d13786ebf1e857554e2d9060200160405180910390a450505050505050505050505050565b6000546001600160a01b0316331461163a5760405162461bcd60e51b815260040161055d90611a71565b604051634e0c354560e11b81526001600160a01b0382811660048301527f0000000000000000000000005058b77cbd029f56a11bd56326519e3ec0081cd01690639c186a8a90602401610707565b6000546001600160a01b031633146116b25760405162461bcd60e51b815260040161055d90611a71565b6001600160a01b0381166117085760405162461bcd60e51b815260206004820152601f60248201527f43414e4e4f5420574954484452415720544f205a45524f204144445245535300604482015260640161055d565b478061174d5760405162461bcd60e51b81526020600482015260146024820152734e4f20455448455220544f20574954484452415760601b604482015260640161055d565b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611783573d6000803e3d6000fd5b50816001600160a01b03167f2bd20150a637d72a74539599f66637c3ec4f6d3807458bf9e002061053ae167c826040516117bf91815260200190565b60405180910390a25050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000826118288584611831565b14949350505050565b600081815b84518110156118d557600085828151811061185357611853611b3c565b602002602001015190508083116118955760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506118c2565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806118cd81611b0a565b915050611836565b509392505050565b6000602082840312156118ef57600080fd5b5035919050565b803580151581146107f457600080fd5b60006020828403121561191857600080fd5b611921826118f6565b9392505050565b6001600160a01b0381168114610a7457600080fd5b60006020828403121561194f57600080fd5b813561192181611928565b6000806040838503121561196d57600080fd5b823561197881611928565b9150611986602084016118f6565b90509250929050565b60008083601f8401126119a157600080fd5b50813567ffffffffffffffff8111156119b957600080fd5b6020830191508360208260051b85010111156119d457600080fd5b9250929050565b60008060008060008060008060c0898b0312156119f757600080fd5b88359750602089013596506040890135955060608901359450608089013567ffffffffffffffff80821115611a2b57600080fd5b611a378c838d0161198f565b909650945060a08b0135915080821115611a5057600080fd5b50611a5d8b828c0161198f565b999c989b5096995094979396929594505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215611ab857600080fd5b5051919050565b600060208284031215611ad157600080fd5b815161192181611928565b634e487b7160e01b600052601160045260246000fd5b60008219821115611b0557611b05611adc565b500190565b6000600019821415611b1e57611b1e611adc565b5060010190565b600082821015611b3757611b37611adc565b500390565b634e487b7160e01b600052603260045260246000fdfea26469706673582212206d6949a66cfb822f22373e1206e3c25b3f27c5b39a657a5fbc781ade3759259e64736f6c634300080b0033
{"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, 2581, 2683, 2475, 26337, 2549, 2278, 2620, 11329, 3540, 2475, 2278, 15136, 2094, 2620, 21619, 2620, 23499, 2278, 27009, 2094, 2487, 2094, 2629, 2546, 21486, 2509, 27717, 23499, 2063, 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, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1063, 21442, 19099, 18907, 1065, 2013, 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,901
0x979316f5b3f3d8db956af519553c853525a5b1af
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, "Address: low-level call with value failed" ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, "Address: insufficient balance for call" ); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}( data ); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall( target, data, "Address: low-level static call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall( target, data, "Address: low-level delegate call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require( owner != address(0), "ERC721: owner query for nonexistent token" ); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require( _exists(tokenId), "ERC721: approved query for nonexistent token" ); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require( ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own" ); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received( _msgSender(), from, tokenId, _data ) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert( "ERC721: transfer to non ERC721Receiver implementer" ); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/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/interfaces/IERC165.sol pragma solidity ^0.8.0; // File: @openzeppelin/contracts/interfaces/IERC2981.sol pragma solidity ^0.8.0; /** * @dev Interface for the NFT Royalty Standard */ interface IERC2981 is IERC165 { /** * @dev Called with the sale price to determine how much royalty is owed and to whom. * @param tokenId - the NFT asset queried for royalty information * @param salePrice - the sale price of the NFT asset specified by `tokenId` * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for `salePrice` */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); } // 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: contracts/Authorizable.sol pragma solidity >=0.4.22 <0.9.0; contract Authorizable is Ownable { address public trustee; constructor() { trustee = address(0x0); } modifier onlyAuthorized() { require(msg.sender == trustee || msg.sender == owner()); _; } function setTrustee(address _newTrustee) public onlyOwner { trustee = _newTrustee; } } // File: contracts/FeralfileArtworkV2.sol pragma solidity ^0.8.0; contract FeralfileExhibitionV2 is ERC721Enumerable, Authorizable, IERC2981 { using Strings for uint256; // royalty payout address address public royaltyPayoutAddress; // The maximum limit of edition size for each exhibitions uint256 public immutable maxEditionPerArtwork; // the basis points of royalty payments for each secondary sales uint256 public immutable secondarySaleRoyaltyBPS; // the maximum basis points of royalty payments uint256 public constant MAX_ROYALITY_BPS = 100_00; // token base URI string private _tokenBaseURI; // contract URI string private _contractURI; /// @notice A structure for Feral File artwork struct Artwork { string title; string artistName; string fingerprint; uint256 editionSize; } struct ArtworkEdition { uint256 editionID; string ipfsCID; } uint256[] private _allArtworks; mapping(uint256 => Artwork) public artworks; // artworkID => Artwork mapping(uint256 => ArtworkEdition) public artworkEditions; // artworkEditionID => ArtworkEdition mapping(uint256 => uint256[]) internal allArtworkEditions; // artworkID => []ArtworkEditionID mapping(uint256 => bool) internal registeredBitmarks; // bitmarkID => bool mapping(string => bool) internal registeredIPFSCIDs; // ipfsCID => bool constructor( string memory name_, string memory symbol_, uint256 maxEditionPerArtwork_, uint256 secondarySaleRoyaltyBPS_, address royaltyPayoutAddress_, string memory contractURI_, string memory tokenBaseURI_ ) ERC721(name_, symbol_) { require( maxEditionPerArtwork_ > 0, "maxEdition of each artwork in an exhibition needs to be greater than zero" ); require( secondarySaleRoyaltyBPS_ <= MAX_ROYALITY_BPS, "royalty BPS for secondary sales can not be greater than the maximum royalty BPS" ); require( royaltyPayoutAddress_ != address(0), "invalid royalty payout address" ); maxEditionPerArtwork = maxEditionPerArtwork_; secondarySaleRoyaltyBPS = secondarySaleRoyaltyBPS_; royaltyPayoutAddress = royaltyPayoutAddress_; _contractURI = contractURI_; _tokenBaseURI = tokenBaseURI_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Enumerable, IERC165) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /// @notice Call to create an artwork in the exhibition /// @param fingerprint - the fingerprint of an artwork /// @param title - the title of an artwork /// @param artistName - the artist of an artwork /// @param editionSize - the maximum edition size of an artwork function createArtwork( string memory fingerprint, string memory title, string memory artistName, uint256 editionSize ) external onlyAuthorized { require(bytes(title).length != 0, "title can not be empty"); require(bytes(artistName).length != 0, "artist can not be empty"); require(bytes(fingerprint).length != 0, "fingerprint can not be empty"); require(editionSize > 0, "edition size needs to be at least 1"); require( editionSize <= maxEditionPerArtwork, "artwork edition size exceeds the maximum edition size of the exhibition" ); uint256 artworkID = uint256(keccak256(abi.encode(fingerprint))); /// @notice make sure the artwork have not been registered require( bytes(artworks[artworkID].fingerprint).length == 0, "an artwork with the same fingerprint has already registered" ); Artwork memory artwork = Artwork( fingerprint, title, artistName, editionSize ); _allArtworks.push(artworkID); artworks[artworkID] = artwork; emit NewArtwork(artworkID); } /// @notice Return a count of artworks registered in this exhibition function totalArtworks() public view virtual returns (uint256) { return _allArtworks.length; } /// @notice Return the token identifier for the `index`th artwork function getArtworkByIndex(uint256 index) public view virtual returns (uint256) { require( index < totalArtworks(), "artworks: global index out of bounds" ); return _allArtworks[index]; } /// @notice Swap an existent artwork from bitmark to ERC721 /// @param artworkID - the artwork id where the new edition is referenced to /// @param bitmarkID - the bitmark id of artwork edition before swapped /// @param editionNumber - the edition number of the artwork edition /// @param owner - the owner address of the new minted token /// @param ipfsCID - the IPFS cid for the new token function swapArtworkFromBitmark( uint256 artworkID, uint256 bitmarkID, uint256 editionNumber, address owner, string memory ipfsCID ) external onlyAuthorized { /// @notice the edition size is not set implies the artwork is not created require(artworks[artworkID].editionSize > 0, "artwork is not found"); /// @notice The range of editionNumber should be between 0 (AP) ~ artwork.editionSize require( editionNumber <= artworks[artworkID].editionSize, "edition number exceed the edition size of the artwork" ); require(owner != address(0), "invalid owner address"); require(!registeredBitmarks[bitmarkID], "bitmark id has registered"); require(!registeredIPFSCIDs[ipfsCID], "ipfs id has registered"); uint256 editionID = artworkID + editionNumber; require( artworkEditions[editionID].editionID == 0, "the edition is existent" ); ArtworkEdition memory edition = ArtworkEdition(editionID, ipfsCID); artworkEditions[editionID] = edition; allArtworkEditions[artworkID].push(editionID); registeredBitmarks[bitmarkID] = true; registeredIPFSCIDs[ipfsCID] = true; _safeMint(owner, editionID); emit NewArtworkEdition(owner, artworkID, editionID); } /// @notice Update the IPFS cid of an edition to a new value function updateArtworkEditionIPFSCid(uint256 tokenId, string memory ipfsCID) external onlyAuthorized { require(_exists(tokenId), "artwork edition is not found"); require(!registeredIPFSCIDs[ipfsCID], "ipfs id has registered"); ArtworkEdition storage edition = artworkEditions[tokenId]; delete registeredIPFSCIDs[edition.ipfsCID]; registeredIPFSCIDs[ipfsCID] = true; edition.ipfsCID = ipfsCID; } /// @notice setRoyaltyPayoutAddress assigns a payout address so // that we can split the royalty. /// @param royaltyPayoutAddress_ - the new royalty payout address function setRoyaltyPayoutAddress(address royaltyPayoutAddress_) external onlyAuthorized { require( royaltyPayoutAddress_ != address(0), "invalid royalty payout address" ); royaltyPayoutAddress = royaltyPayoutAddress_; } /// @notice Return the edition counts for an artwork function totalEditionOfArtwork(uint256 artworkID) public view returns (uint256) { return allArtworkEditions[artworkID].length; } /// @notice Return the edition id of an artwork by index function getArtworkEditionByIndex(uint256 artworkID, uint256 index) public view returns (uint256) { require(index < totalEditionOfArtwork(artworkID)); return allArtworkEditions[artworkID][index]; } /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _tokenBaseURI; if (bytes(baseURI).length == 0) { baseURI = "ipfs://"; } return string( abi.encodePacked( baseURI, artworkEditions[tokenId].ipfsCID, "/metadata.json" ) ); } /// @notice Update the base URI for all tokens function setTokenBaseURI(string memory baseURI_) external onlyAuthorized { _tokenBaseURI = baseURI_; } /// @notice A URL for the opensea storefront-level metadata function contractURI() public view returns (string memory) { return _contractURI; } /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param tokenId - the NFT asset queried for royalty information /// @param salePrice - the sale price of the NFT asset specified by tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for salePrice function royaltyInfo(uint256 tokenId, uint256 salePrice) external view override returns (address receiver, uint256 royaltyAmount) { require( _exists(tokenId), "ERC2981: query royalty info for nonexistent token" ); receiver = royaltyPayoutAddress; royaltyAmount = (salePrice * secondarySaleRoyaltyBPS) / MAX_ROYALITY_BPS; } event NewArtwork(uint256 indexed artworkID); event NewArtworkEdition( address indexed owner, uint256 indexed artworkID, uint256 indexed editionID ); }
0x608060405234801561001057600080fd5b50600436106101c25760003560e01c806301ffc9a7146101c757806306fdde03146101ef578063081812fc14610204578063095ea7b31461022f5780630cfcb5f11461024457806318160ddd1461025757806323b872dd146102695780632a55205a1461027c5780632f745c59146102ae5780633afb021a146102c15780633f6805ba146102d457806342842e0e146102e757806345aeefde146102fa5780634b6026731461030d5780634f6ccce71461033057806362fe2131146103435780636352211e14610364578063641b18e91461037757806370a082311461038a578063715018a61461039d5780637f34c0dd146103a557806384ad61af146103b85780638da5cb5b146103df5780638ef79e91146103e757806395d89b41146103fa578063a22cb46514610402578063b488370314610415578063b88d4fde14610428578063c87b56dd1461043b578063d0d1ea701461044e578063e4a233e114610461578063e8a3d48514610469578063e985e9c514610471578063ea211d7c14610484578063ec9cbb44146104ab578063f2fde38b146104b4578063fdf97cb2146104c7578063fe2a3bf3146104da575b600080fd5b6101da6101d5366004612460565b6104fa565b60405190151581526020015b60405180910390f35b6101f7610525565b6040516101e691906124dc565b6102176102123660046124ef565b6105b7565b6040516001600160a01b0390911681526020016101e6565b61024261023d366004612524565b610644565b005b6102426102523660046125f9565b610755565b6008545b6040519081526020016101e6565b61024261027736600461263f565b6108a8565b61028f61028a36600461267b565b6108d9565b604080516001600160a01b0390931683526020830191909152016101e6565b61025b6102bc366004612524565b610999565b6102426102cf36600461269d565b610a2f565b600c54610217906001600160a01b031681565b6102426102f536600461263f565b610ded565b61024261030836600461272c565b610e08565b61032061031b3660046124ef565b610eba565b6040516101e69493929190612747565b61025b61033e3660046124ef565b61107a565b6103566103513660046124ef565b61110d565b6040516101e6929190612792565b6102176103723660046124ef565b6111b2565b61025b61038536600461267b565b611229565b61025b61039836600461272c565b611276565b6102426112fd565b6102426103b33660046127ab565b611338565b61025b7f000000000000000000000000000000000000000000000000000000000000004d81565b61021761168c565b6102426103f5366004612815565b61169b565b6101f76116ec565b610242610410366004612849565b6116fb565b61025b6104233660046124ef565b6117bc565b610242610436366004612885565b611834565b6101f76104493660046124ef565b611866565b61024261045c36600461272c565b6119cd565b600f5461025b565b6101f7611a1e565b6101da61047f366004612900565b611a2d565b61025b7f00000000000000000000000000000000000000000000000000000000000005dc81565b61025b61271081565b6102426104c236600461272c565b611a5b565b600b54610217906001600160a01b031681565b61025b6104e83660046124ef565b60009081526012602052604090205490565b60006001600160e01b0319821663780e9d6360e01b148061051f575061051f82611afb565b92915050565b6060600080546105349061292a565b80601f01602080910402602001604051908101604052809291908181526020018280546105609061292a565b80156105ad5780601f10610582576101008083540402835291602001916105ad565b820191906000526020600020905b81548152906001019060200180831161059057829003601f168201915b5050505050905090565b60006105c282611b20565b6106285760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061064f826111b2565b9050806001600160a01b0316836001600160a01b031614156106bd5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161061f565b336001600160a01b03821614806106d957506106d98133611a2d565b6107465760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b606482015260840161061f565b6107508383611b3d565b505050565b600b546001600160a01b0316331480610786575061077161168c565b6001600160a01b0316336001600160a01b0316145b61078f57600080fd5b61079882611b20565b6107e35760405162461bcd60e51b815260206004820152601c60248201527b185c9d1ddbdc9ac819591a5d1a5bdb881a5cc81b9bdd08199bdd5b9960221b604482015260640161061f565b6014816040516107f39190612965565b9081526040519081900360200190205460ff16156108235760405162461bcd60e51b815260040161061f90612981565b600082815260116020526040908190209051601490610846906001840190612a4b565b908152604051908190036020018120805460ff1916905560019060149061086e908590612965565b90815260405160209181900382019020805460ff19169215159290921790915582516108a2916001840191908501906123b1565b50505050565b6108b23382611bab565b6108ce5760405162461bcd60e51b815260040161061f90612a57565b610750838383611c75565b6000806108e584611b20565b61094b5760405162461bcd60e51b815260206004820152603160248201527f455243323938313a20717565727920726f79616c747920696e666f20666f72206044820152703737b732bc34b9ba32b73a103a37b5b2b760791b606482015260840161061f565b600c546001600160a01b031691506127106109867f00000000000000000000000000000000000000000000000000000000000005dc85612abe565b6109909190612add565b90509250929050565b60006109a483611276565b8210610a065760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161061f565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600b546001600160a01b0316331480610a605750610a4b61168c565b6001600160a01b0316336001600160a01b0316145b610a6957600080fd5b8251610ab05760405162461bcd60e51b81526020600482015260166024820152757469746c652063616e206e6f7420626520656d70747960501b604482015260640161061f565b8151610af85760405162461bcd60e51b81526020600482015260176024820152766172746973742063616e206e6f7420626520656d70747960481b604482015260640161061f565b8351610b455760405162461bcd60e51b815260206004820152601c60248201527b66696e6765727072696e742063616e206e6f7420626520656d70747960201b604482015260640161061f565b60008111610ba15760405162461bcd60e51b815260206004820152602360248201527f65646974696f6e2073697a65206e6565647320746f206265206174206c65617360448201526274203160e81b606482015260840161061f565b7f000000000000000000000000000000000000000000000000000000000000004d811115610c475760405162461bcd60e51b815260206004820152604760248201527f617274776f726b2065646974696f6e2073697a6520657863656564732074686560448201527f206d6178696d756d2065646974696f6e2073697a65206f66207468652065786860648201526634b134ba34b7b760c91b608482015260a40161061f565b600084604051602001610c5a91906124dc565b60408051601f198184030181529181528151602092830120600081815260109093529120600201805491925090610c909061292a565b159050610d035760405162461bcd60e51b815260206004820152603b60248201527f616e20617274776f726b2077697468207468652073616d652066696e6765727060448201527a1c9a5b9d081a185cc8185b1c9958591e481c9959da5cdd195c9959602a1b606482015260840161061f565b60408051608081018252868152602080820187905281830186905260608201859052600f8054600181019091557f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac80201849055600084815260108252929092208151805192938493610d7792849201906123b1565b506020828101518051610d9092600185019201906123b1565b5060408201518051610dac9160028401916020909101906123b1565b506060919091015160039091015560405182907f22350b25f1b72bb3621199a79abefeb4fcd77bb1e65638cd09350666e4db089190600090a2505050505050565b61075083838360405180602001604052806000815250611834565b600b546001600160a01b0316331480610e395750610e2461168c565b6001600160a01b0316336001600160a01b0316145b610e4257600080fd5b6001600160a01b038116610e985760405162461bcd60e51b815260206004820152601e60248201527f696e76616c696420726f79616c7479207061796f757420616464726573730000604482015260640161061f565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b601060205260009081526040902080548190610ed59061292a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f019061292a565b8015610f4e5780601f10610f2357610100808354040283529160200191610f4e565b820191906000526020600020905b815481529060010190602001808311610f3157829003601f168201915b505050505090806001018054610f639061292a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8f9061292a565b8015610fdc5780601f10610fb157610100808354040283529160200191610fdc565b820191906000526020600020905b815481529060010190602001808311610fbf57829003601f168201915b505050505090806002018054610ff19061292a565b80601f016020809104026020016040519081016040528092919081815260200182805461101d9061292a565b801561106a5780601f1061103f5761010080835404028352916020019161106a565b820191906000526020600020905b81548152906001019060200180831161104d57829003601f168201915b5050505050908060030154905084565b600061108560085490565b82106110e85760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161061f565b600882815481106110fb576110fb612aff565b90600052602060002001549050919050565b6011602052600090815260409020805460018201805491929161112f9061292a565b80601f016020809104026020016040519081016040528092919081815260200182805461115b9061292a565b80156111a85780601f1061117d576101008083540402835291602001916111a8565b820191906000526020600020905b81548152906001019060200180831161118b57829003601f168201915b5050505050905082565b6000818152600260205260408120546001600160a01b03168061051f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161061f565b600082815260126020526040812054821061124357600080fd5b600083815260126020526040902080548390811061126357611263612aff565b9060005260206000200154905092915050565b60006001600160a01b0382166112e15760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161061f565b506001600160a01b031660009081526003602052604090205490565b3361130661168c565b6001600160a01b03161461132c5760405162461bcd60e51b815260040161061f90612b15565b6113366000611e0e565b565b600b546001600160a01b0316331480611369575061135461168c565b6001600160a01b0316336001600160a01b0316145b61137257600080fd5b6000858152601060205260409020600301546113c75760405162461bcd60e51b8152602060048201526014602482015273185c9d1ddbdc9ac81a5cc81b9bdd08199bdd5b9960621b604482015260640161061f565b6000858152601060205260409020600301548311156114465760405162461bcd60e51b815260206004820152603560248201527f65646974696f6e206e756d62657220657863656564207468652065646974696f6044820152746e2073697a65206f662074686520617274776f726b60581b606482015260840161061f565b6001600160a01b0382166114945760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964206f776e6572206164647265737360581b604482015260640161061f565b60008481526013602052604090205460ff16156114ef5760405162461bcd60e51b8152602060048201526019602482015278189a5d1b585c9ac81a59081a185cc81c9959da5cdd195c9959603a1b604482015260640161061f565b6014816040516114ff9190612965565b9081526040519081900360200190205460ff161561152f5760405162461bcd60e51b815260040161061f90612981565b600061153b8487612b4a565b600081815260116020526040902054909150156115945760405162461bcd60e51b81526020600482015260176024820152761d1a194819591a5d1a5bdb881a5cc8195e1a5cdd195b9d604a1b604482015260640161061f565b60408051808201825282815260208082018581526000858152601183529390932082518155925180519293849390926115d49260018501929101906123b1565b505050600087815260126020908152604080832080546001818101835591855283852001869055898452601390925291829020805460ff1916821790559051601490611621908690612965565b908152604051908190036020019020805491151560ff1990921691909117905561164b8483611e60565b8187856001600160a01b03167f4f21e8cd53f1df1da42ec94ba03f881c1185607b26e4dcb81941535157d73dd460405160405180910390a450505050505050565b600a546001600160a01b031690565b600b546001600160a01b03163314806116cc57506116b761168c565b6001600160a01b0316336001600160a01b0316145b6116d557600080fd5b80516116e890600d9060208401906123b1565b5050565b6060600180546105349061292a565b6001600160a01b0382163314156117505760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015260640161061f565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006117c7600f5490565b82106118215760405162461bcd60e51b8152602060048201526024808201527f617274776f726b733a20676c6f62616c20696e646578206f7574206f6620626f604482015263756e647360e01b606482015260840161061f565b600f82815481106110fb576110fb612aff565b61183e3383611bab565b61185a5760405162461bcd60e51b815260040161061f90612a57565b6108a284848484611e7a565b606061187182611b20565b6118d55760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161061f565b6000600d80546118e49061292a565b80601f01602080910402602001604051908101604052809291908181526020018280546119109061292a565b801561195d5780601f106119325761010080835404028352916020019161195d565b820191906000526020600020905b81548152906001019060200180831161194057829003601f168201915b5050505050905080516000141561198e5750604080518082019091526007815266697066733a2f2f60c81b60208201525b80601160008581526020019081526020016000206001016040516020016119b6929190612b62565b604051602081830303815290604052915050919050565b336119d661168c565b6001600160a01b0316146119fc5760405162461bcd60e51b815260040161061f90612b15565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600e80546105349061292a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b33611a6461168c565b6001600160a01b031614611a8a5760405162461bcd60e51b815260040161061f90612b15565b6001600160a01b038116611aef5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161061f565b611af881611e0e565b50565b60006001600160e01b0319821663780e9d6360e01b148061051f575061051f82611ead565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b72826111b2565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611bb682611b20565b611c175760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161061f565b6000611c22836111b2565b9050806001600160a01b0316846001600160a01b03161480611c5d5750836001600160a01b0316611c52846105b7565b6001600160a01b0316145b80611c6d5750611c6d8185611a2d565b949350505050565b826001600160a01b0316611c88826111b2565b6001600160a01b031614611cf05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161061f565b6001600160a01b038216611d525760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161061f565b611d5d838383611efd565b611d68600082611b3d565b6001600160a01b0383166000908152600360205260408120805460019290611d91908490612ba0565b90915550506001600160a01b0382166000908152600360205260408120805460019290611dbf908490612b4a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038681169182179092559151849391871691600080516020612c7a83398151915291a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6116e8828260405180602001604052806000815250611fb5565b611e85848484611c75565b611e9184848484611fe8565b6108a25760405162461bcd60e51b815260040161061f90612bb7565b60006001600160e01b031982166380ac58cd60e01b1480611ede57506001600160e01b03198216635b5e139f60e01b145b8061051f57506301ffc9a760e01b6001600160e01b031983161461051f565b6001600160a01b038316611f5857611f5381600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611f7b565b816001600160a01b0316836001600160a01b031614611f7b57611f7b83826120f5565b6001600160a01b038216611f925761075081612192565b826001600160a01b0316826001600160a01b031614610750576107508282612241565b611fbf8383612285565b611fcc6000848484611fe8565b6107505760405162461bcd60e51b815260040161061f90612bb7565b60006001600160a01b0384163b156120ea57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061202c903390899088908890600401612c09565b602060405180830381600087803b15801561204657600080fd5b505af1925050508015612076575060408051601f3d908101601f1916820190925261207391810190612c46565b60015b6120d0573d8080156120a4576040519150601f19603f3d011682016040523d82523d6000602084013e6120a9565b606091505b5080516120c85760405162461bcd60e51b815260040161061f90612bb7565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c6d565b506001949350505050565b6000600161210284611276565b61210c9190612ba0565b60008381526007602052604090205490915080821461215f576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906121a490600190612ba0565b600083815260096020526040812054600880549394509092849081106121cc576121cc612aff565b9060005260206000200154905080600883815481106121ed576121ed612aff565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061222557612225612c63565b6001900381819060005260206000200160009055905550505050565b600061224c83611276565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166122db5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161061f565b6122e481611b20565b156123305760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b604482015260640161061f565b61233c60008383611efd565b6001600160a01b0382166000908152600360205260408120805460019290612365908490612b4a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020612c7a833981519152908290a45050565b8280546123bd9061292a565b90600052602060002090601f0160209004810192826123df5760008555612425565b82601f106123f857805160ff1916838001178555612425565b82800160010185558215612425579182015b8281111561242557825182559160200191906001019061240a565b50612431929150612435565b5090565b5b808211156124315760008155600101612436565b6001600160e01b031981168114611af857600080fd5b60006020828403121561247257600080fd5b813561247d8161244a565b9392505050565b60005b8381101561249f578181015183820152602001612487565b838111156108a25750506000910152565b600081518084526124c8816020860160208601612484565b601f01601f19169290920160200192915050565b60208152600061247d60208301846124b0565b60006020828403121561250157600080fd5b5035919050565b80356001600160a01b038116811461251f57600080fd5b919050565b6000806040838503121561253757600080fd5b61254083612508565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561257e5761257e61254e565b604051601f8501601f19908116603f011681019082821181831017156125a6576125a661254e565b816040528093508581528686860111156125bf57600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126125ea57600080fd5b61247d83833560208501612564565b6000806040838503121561260c57600080fd5b8235915060208301356001600160401b0381111561262957600080fd5b612635858286016125d9565b9150509250929050565b60008060006060848603121561265457600080fd5b61265d84612508565b925061266b60208501612508565b9150604084013590509250925092565b6000806040838503121561268e57600080fd5b50508035926020909101359150565b600080600080608085870312156126b357600080fd5b84356001600160401b03808211156126ca57600080fd5b6126d6888389016125d9565b955060208701359150808211156126ec57600080fd5b6126f8888389016125d9565b9450604087013591508082111561270e57600080fd5b5061271b878288016125d9565b949793965093946060013593505050565b60006020828403121561273e57600080fd5b61247d82612508565b60808152600061275a60808301876124b0565b828103602084015261276c81876124b0565b9050828103604084015261278081866124b0565b91505082606083015295945050505050565b828152604060208201526000611c6d60408301846124b0565b600080600080600060a086880312156127c357600080fd5b8535945060208601359350604086013592506127e160608701612508565b915060808601356001600160401b038111156127fc57600080fd5b612808888289016125d9565b9150509295509295909350565b60006020828403121561282757600080fd5b81356001600160401b0381111561283d57600080fd5b611c6d848285016125d9565b6000806040838503121561285c57600080fd5b61286583612508565b91506020830135801515811461287a57600080fd5b809150509250929050565b6000806000806080858703121561289b57600080fd5b6128a485612508565b93506128b260208601612508565b92506040850135915060608501356001600160401b038111156128d457600080fd5b8501601f810187136128e557600080fd5b6128f487823560208401612564565b91505092959194509250565b6000806040838503121561291357600080fd5b61291c83612508565b915061099060208401612508565b600181811c9082168061293e57607f821691505b6020821081141561295f57634e487b7160e01b600052602260045260246000fd5b50919050565b60008251612977818460208701612484565b9190910192915050565b6020808252601690820152751a5c199cc81a59081a185cc81c9959da5cdd195c995960521b604082015260600190565b8054600090600181811c90808316806129cb57607f831692505b60208084108214156129ed57634e487b7160e01b600052602260045260246000fd5b818015612a015760018114612a1257612a3f565b60ff19861689528489019650612a3f565b60008881526020902060005b86811015612a375781548b820152908501908301612a1e565b505084890196505b50505050505092915050565b600061247d82846129b1565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612ad857612ad8612aa8565b500290565b600082612afa57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115612b5d57612b5d612aa8565b500190565b60008351612b74818460208801612484565b612b80818401856129b1565b6d17b6b2ba30b230ba30973539b7b760911b8152600e0195945050505050565b600082821015612bb257612bb2612aa8565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612c3c908301846124b0565b9695505050505050565b600060208284031215612c5857600080fd5b815161247d8161244a565b634e487b7160e01b600052603160045260246000fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220e304bb68124c1ff10ed141c6a198ea86d28142b7c74981db5a534655c620505764736f6c63430008090033
{"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, 2581, 2683, 21486, 2575, 2546, 2629, 2497, 2509, 2546, 29097, 2620, 18939, 2683, 26976, 10354, 22203, 2683, 24087, 2509, 2278, 27531, 19481, 17788, 2050, 2629, 2497, 2487, 10354, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 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, 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,902
0x97932Bd4AF8a86751C944d1d9d22381ed506C558
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./SwapAdmin.sol"; contract SwapTokenLocker is SwapAdmin { using SafeMath for uint; struct LockInfo { uint256 amount; uint256 lockTimestamp; // lock time at block.timestamp uint256 lockHours; uint256 claimedAmount; uint256 lastUpdated; } mapping (address => mapping(address => LockInfo)) public lockData; mapping (address => address[]) public claimableTokens; constructor(address _admin) public SwapAdmin(_admin) {} function getLockData(address _user, address _tokenAddress) external view returns(uint256, uint256, uint256, uint256, uint256) { require(_user != address(0), "User address is invalid"); require(_tokenAddress != address(0), "Token address is invalid"); LockInfo storage _lockInfo = lockData[_user][_tokenAddress]; return (_lockInfo.amount, _lockInfo.lockTimestamp, _lockInfo.lockHours, _lockInfo.claimedAmount, _lockInfo.lastUpdated); } function getClaimableTokens(address _user) external view returns (address[] memory) { require(_user != address(0), "User address is invalid"); return claimableTokens[_user]; } function sendLockTokenMany( address[] calldata _users, address[] calldata _tokenAddresses, uint256[] calldata _amounts, uint256[] calldata _lockTimestamps, uint256[] calldata _lockHours, address[] calldata _allTokenAddresses, uint256[] calldata _sendAmounts ) external onlyAdmin { require(_users.length == _amounts.length, "array length not eq"); require(_users.length == _lockHours.length, "array length not eq"); require(_users.length == _lockTimestamps.length, "array length not eq"); require(_users.length == _tokenAddresses.length, "array length not eq"); require(_allTokenAddresses.length == _sendAmounts.length, "Send token address length and amounts length are not eq"); for (uint256 i = 0; i < _allTokenAddresses.length; i ++) { IERC20(_allTokenAddresses[i]).transferFrom(msg.sender, address(this), _sendAmounts[i]); } for (uint256 j = 0; j < _users.length; j++) { sendLockToken(_users[j], _tokenAddresses[j], _amounts[j], _lockTimestamps[j], _lockHours[j]); } } function sendLockToken( address _user, address _tokenAddress, uint256 _amount, uint256 _lockTimestamp, uint256 _lockHours ) internal { require(_amount > 0, "amount can not zero"); require(_lockHours > 0, "lock hours need more than zero"); require(_lockTimestamp > 0, "lock timestamp need more than zero"); require(_tokenAddress != address(0), "Token address is invalid"); require(lockData[_user][_tokenAddress].amount == 0, "this address has already locked"); LockInfo memory lockinfo = LockInfo({ amount: _amount, //lockTimestamp: block.timestamp, lockTimestamp: _lockTimestamp, lockHours: _lockHours, lastUpdated: block.timestamp, claimedAmount: 0 }); lockData[_user][_tokenAddress] = lockinfo; claimableTokens[_user].push(_tokenAddress); } function claimToken(uint256 _amount, address _tokenAddress) external returns (uint256) { require(_amount > 0, "Invalid parameter amount"); address _user = msg.sender; require(_tokenAddress != address(0), "Token address is invalid"); LockInfo storage _lockInfo = lockData[_user][_tokenAddress]; require(_lockInfo.lockTimestamp <= block.timestamp, "Vesting time is not started"); require(_lockInfo.amount > 0, "No lock token to claim"); uint256 passhours = block.timestamp.sub(_lockInfo.lockTimestamp).div(1 hours); require(passhours > 0, "need wait for one hour at least"); require((block.timestamp - _lockInfo.lastUpdated) > 1 hours, "You have to wait at least an hour to claim"); uint256 available = 0; if (passhours >= _lockInfo.lockHours) { available = _lockInfo.amount; } else { available = _lockInfo.amount.div(_lockInfo.lockHours).mul(passhours); } available = available.sub(_lockInfo.claimedAmount); require(available > 0, "not available claim"); uint256 claim = _amount; if (_amount > available) { // claim as much as possible claim = available; } _lockInfo.claimedAmount = _lockInfo.claimedAmount.add(claim); IERC20(_tokenAddress).transfer(_user, claim); _lockInfo.lastUpdated = block.timestamp; return claim; } } 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); } 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; contract SwapAdmin { address public admin; address public candidate; constructor(address _admin) public { require(_admin != address(0), "admin address cannot be 0"); admin = _admin; emit AdminChanged(address(0), _admin); } function setCandidate(address _candidate) external onlyAdmin { address old = candidate; candidate = _candidate; emit candidateChanged( old, candidate); } function becomeAdmin( ) external { require( msg.sender == candidate, "Only candidate can become admin"); address old = admin; admin = candidate; emit AdminChanged( old, admin ); } modifier onlyAdmin { require( (msg.sender == admin), "Only the contract admin can perform this action"); _; } event candidateChanged(address oldCandidate, address newCandidate ); event AdminChanged(address oldAdmin, address newAdmin); }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806384d349b81161006657806384d349b8146101c6578063c3a3694d146101f4578063c49662c514610442578063f53215c314610480578063f851a440146104ac5761009e565b806307880b7f146100a35780631b831ead146100cb578063259601361461014157806325971dff1461019a5780636c8381f8146101a2575b600080fd5b6100c9600480360360208110156100b957600080fd5b50356001600160a01b03166104b4565b005b6100f1600480360360208110156100e157600080fd5b50356001600160a01b031661055f565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561012d578181015183820152602001610115565b505050509050019250505060405180910390f35b61016f6004803603604081101561015757600080fd5b506001600160a01b038135811691602001351661062a565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6100c9610661565b6101aa610724565b604080516001600160a01b039092168252519081900360200190f35b61016f600480360360408110156101dc57600080fd5b506001600160a01b0381358116916020013516610733565b6100c9600480360360e081101561020a57600080fd5b810190602081018135600160201b81111561022457600080fd5b82018360208201111561023657600080fd5b803590602001918460208302840111600160201b8311171561025757600080fd5b919390929091602081019035600160201b81111561027457600080fd5b82018360208201111561028657600080fd5b803590602001918460208302840111600160201b831117156102a757600080fd5b919390929091602081019035600160201b8111156102c457600080fd5b8201836020820111156102d657600080fd5b803590602001918460208302840111600160201b831117156102f757600080fd5b919390929091602081019035600160201b81111561031457600080fd5b82018360208201111561032657600080fd5b803590602001918460208302840111600160201b8311171561034757600080fd5b919390929091602081019035600160201b81111561036457600080fd5b82018360208201111561037657600080fd5b803590602001918460208302840111600160201b8311171561039757600080fd5b919390929091602081019035600160201b8111156103b457600080fd5b8201836020820111156103c657600080fd5b803590602001918460208302840111600160201b831117156103e757600080fd5b919390929091602081019035600160201b81111561040457600080fd5b82018360208201111561041657600080fd5b803590602001918460208302840111600160201b8311171561043757600080fd5b509092509050610830565b61046e6004803603604081101561045857600080fd5b50803590602001356001600160a01b0316610b51565b60408051918252519081900360200190f35b6101aa6004803603604081101561049657600080fd5b506001600160a01b038135169060200135610ed1565b6101aa610f06565b6000546001600160a01b031633146104fd5760405162461bcd60e51b815260040180806020018281038252602f815260200180611433602f913960400191505060405180910390fd5b600180546001600160a01b038381166001600160a01b0319831617928390556040805192821680845293909116602083015280517f0faed18be9e8f4d4c05dfbcc80ea2c97a0be729614d766827778f60890c02cab9281900390910190a15050565b60606001600160a01b0382166105b6576040805162461bcd60e51b8152602060048201526017602482015276155cd95c881859191c995cdcc81a5cc81a5b9d985b1a59604a1b604482015290519081900360640190fd5b6001600160a01b0382166000908152600360209081526040918290208054835181840281018401909452808452909183018282801561061e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610600575b50505050509050919050565b6002602081815260009384526040808520909152918352912080546001820154928201546003830154600490930154919392909185565b6001546001600160a01b031633146106c0576040805162461bcd60e51b815260206004820152601f60248201527f4f6e6c792063616e6469646174652063616e206265636f6d652061646d696e00604482015290519081900360640190fd5b600080546001546001600160a01b031982166001600160a01b0391821617928390556040805192821680845293909116602083015280517f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f9281900390910190a150565b6001546001600160a01b031681565b6000808080806001600160a01b03871661078e576040805162461bcd60e51b8152602060048201526017602482015276155cd95c881859191c995cdcc81a5cc81a5b9d985b1a59604a1b604482015290519081900360640190fd5b6001600160a01b0386166107e4576040805162461bcd60e51b8152602060048201526018602482015277151bdad95b881859191c995cdcc81a5cc81a5b9d985b1a5960421b604482015290519081900360640190fd5b505050506001600160a01b039283166000908152600260208181526040808420959096168352939093529290922080546001820154928201546003830154600490930154919593945092565b6000546001600160a01b031633146108795760405162461bcd60e51b815260040180806020018281038252602f815260200180611433602f913960400191505060405180910390fd5b8c89146108c3576040805162461bcd60e51b81526020600482015260136024820152726172726179206c656e677468206e6f7420657160681b604482015290519081900360640190fd5b8c851461090d576040805162461bcd60e51b81526020600482015260136024820152726172726179206c656e677468206e6f7420657160681b604482015290519081900360640190fd5b8c8714610957576040805162461bcd60e51b81526020600482015260136024820152726172726179206c656e677468206e6f7420657160681b604482015290519081900360640190fd5b8c8b146109a1576040805162461bcd60e51b81526020600482015260136024820152726172726179206c656e677468206e6f7420657160681b604482015290519081900360640190fd5b8281146109df5760405162461bcd60e51b81526004018080602001828103825260378152602001806113db6037913960400191505060405180910390fd5b60005b83811015610ab3578484828181106109f657fe5b905060200201356001600160a01b03166001600160a01b03166323b872dd3330868686818110610a2257fe5b905060200201356040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b158015610a7f57600080fd5b505af1158015610a93573d6000803e3d6000fd5b505050506040513d6020811015610aa957600080fd5b50506001016109e2565b5060005b8d811015610b4057610b388f8f83818110610ace57fe5b905060200201356001600160a01b03168e8e84818110610aea57fe5b905060200201356001600160a01b03168d8d85818110610b0657fe5b905060200201358c8c86818110610b1957fe5b905060200201358b8b87818110610b2c57fe5b90506020020135610f15565b600101610ab7565b505050505050505050505050505050565b6000808311610ba7576040805162461bcd60e51b815260206004820152601860248201527f496e76616c696420706172616d6574657220616d6f756e740000000000000000604482015290519081900360640190fd5b336001600160a01b038316610bfe576040805162461bcd60e51b8152602060048201526018602482015277151bdad95b881859191c995cdcc81a5cc81a5b9d985b1a5960421b604482015290519081900360640190fd5b6001600160a01b0380821660009081526002602090815260408083209387168352929052206001810154421015610c7c576040805162461bcd60e51b815260206004820152601b60248201527f56657374696e672074696d65206973206e6f7420737461727465640000000000604482015290519081900360640190fd5b8054610cc8576040805162461bcd60e51b81526020600482015260166024820152754e6f206c6f636b20746f6b656e20746f20636c61696d60501b604482015290519081900360640190fd5b6000610ced610e10610ce784600101544261117190919063ffffffff16565b906111ba565b905060008111610d44576040805162461bcd60e51b815260206004820152601f60248201527f6e656564207761697420666f72206f6e6520686f7572206174206c6561737400604482015290519081900360640190fd5b610e108260040154420311610d8a5760405162461bcd60e51b815260040180806020018281038252602a815260200180611484602a913960400191505060405180910390fd5b600082600201548210610d9f57508154610dbe565b60028301548354610dbb918491610db5916111ba565b906111fc565b90505b6003830154610dce908290611171565b905060008111610e1b576040805162461bcd60e51b81526020600482015260136024820152726e6f7420617661696c61626c6520636c61696d60681b604482015290519081900360640190fd5b8681811115610e275750805b6003840154610e369082611255565b60038501556040805163a9059cbb60e01b81526001600160a01b0387811660048301526024820184905291519189169163a9059cbb916044808201926020929091908290030181600087803b158015610e8e57600080fd5b505af1158015610ea2573d6000803e3d6000fd5b505050506040513d6020811015610eb857600080fd5b5050426004909401939093555090925050505b92915050565b60036020528160005260406000208181548110610eea57fe5b6000918252602090912001546001600160a01b03169150829050565b6000546001600160a01b031681565b60008311610f60576040805162461bcd60e51b8152602060048201526013602482015272616d6f756e742063616e206e6f74207a65726f60681b604482015290519081900360640190fd5b60008111610fb5576040805162461bcd60e51b815260206004820152601e60248201527f6c6f636b20686f757273206e656564206d6f7265207468616e207a65726f0000604482015290519081900360640190fd5b60008211610ff45760405162461bcd60e51b81526004018080602001828103825260228152602001806114626022913960400191505060405180910390fd5b6001600160a01b03841661104a576040805162461bcd60e51b8152602060048201526018602482015277151bdad95b881859191c995cdcc81a5cc81a5b9d985b1a5960421b604482015290519081900360640190fd5b6001600160a01b03808616600090815260026020908152604080832093881683529290522054156110c2576040805162461bcd60e51b815260206004820152601f60248201527f7468697320616464726573732068617320616c7265616479206c6f636b656400604482015290519081900360640190fd5b6110ca6113ab565b506040805160a081018252938452602080850193845284820192835260006060860181815242608088019081526001600160a01b03998a1680845260028086528685209a909b168085529985528584209851895596516001808a0191909155955199880199909955516003808801919091559751600490960195909555928452948252938220805494850181558252902090910180546001600160a01b0319169091179055565b60006111b383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506112af565b9392505050565b60006111b383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611346565b60008261120b57506000610ecb565b8282028284828161121857fe5b04146111b35760405162461bcd60e51b81526004018080602001828103825260218152602001806114126021913960400191505060405180910390fd5b6000828201838110156111b3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000818484111561133e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113035781810151838201526020016112eb565b50505050905090810190601f1680156113305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836113955760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113035781810151838201526020016112eb565b5060008385816113a157fe5b0495945050505050565b6040518060a001604052806000815260200160008152602001600081526020016000815260200160008152509056fe53656e6420746f6b656e2061646472657373206c656e67746820616e6420616d6f756e7473206c656e67746820617265206e6f74206571536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f6e6c792074686520636f6e74726163742061646d696e2063616e20706572666f726d207468697320616374696f6e6c6f636b2074696d657374616d70206e656564206d6f7265207468616e207a65726f596f75206861766520746f2077616974206174206c6561737420616e20686f757220746f20636c61696da2646970667358221220b768e6eb2fd709daaf54c7229fe873288511ca769e8fbbdc5a09cea4b8474cd764736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 16703, 2497, 2094, 2549, 10354, 2620, 2050, 20842, 23352, 2487, 2278, 2683, 22932, 2094, 2487, 2094, 2683, 2094, 19317, 22025, 2487, 2098, 12376, 2575, 2278, 24087, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 28855, 14820, 1011, 7427, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 28855, 14820, 1011, 7427, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19948, 4215, 10020, 1012, 14017, 1000, 1025, 3206, 19948, 18715, 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,903
0x9794091c4161ae66aa775af0781379d1823016cf
library SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function GET_MAX_UINT256() pure internal returns(uint256){ return MAX_UINT256; } function mul(uint a, uint b) internal returns(uint){ uint c = a * b; assertSafe(a == 0 || c / a == b); return c; } function div(uint a, uint b) pure internal returns(uint){ // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint a, uint b) internal returns(uint){ assertSafe(b <= a); return a - b; } function add(uint a, uint b) internal returns(uint){ uint c = a + b; assertSafe(c >= a); return c; } function max64(uint64 a, uint64 b) internal view returns(uint64){ return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal view returns(uint64){ return a < b ? a : b; } function max256(uint256 a, uint256 b) internal view returns(uint256){ return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal view returns(uint256){ return a < b ? a : b; } function assertSafe(bool assertion) internal { if (!assertion) { revert(); } } } contract ERC223Interface { function balanceOf(address _who) view public returns (uint); function transfer(address _to, uint _value) public returns (bool success); function transfer(address _to, uint _value, bytes _data) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); function totalSupply() public view returns (uint256 supply); event Transfer(address indexed _from, address indexed _to, uint _value); event Transfer(address indexed _from, address indexed _to, uint _value, bytes _data); event Approval(address indexed _from, address indexed _spender, uint256 _value); } contract ERC223Token is ERC223Interface { using SafeMath for uint; mapping(address => uint) balances; // List of user balances. mapping (address => mapping (address => uint256)) private allowances; uint256 public supply; function ERC223Token(uint256 _totalSupply) public { supply = _totalSupply; } /** * @dev Transfer the specified amount of tokens to the specified address. * Invokes the `tokenFallback` function if the recipient is a contract. * The token transfer fails if the recipient is a contract * but does not implement the `tokenFallback` function * or the fallback function to receive funds. * * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transfer(address _to, uint _value, bytes _data) public returns (bool success){ // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . uint codeLength; assembly { // Retrieve the size of the code on target address, this needs assembly . codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if(codeLength>0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } emit Transfer(msg.sender, _to, _value, _data); emit Transfer (msg.sender, _to, _value); return true; } /** * @dev Transfer the specified amount of tokens to the specified address. * This function works the same with the previous one * but doesn't contain `_data` param. * Added due to backwards compatibility reasons. * * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. */ function transfer(address _to, uint _value) public returns (bool success){ uint codeLength; bytes memory empty; assembly { // Retrieve the size of the code on target address, this needs assembly . codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if(codeLength>0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, empty); } emit Transfer(msg.sender, _to, _value, empty); emit Transfer (msg.sender, _to, _value); return true; } /** * @dev Returns balance of the `_owner`. * * @param _owner The address whose balance will be returned. * @return balance Balance of the `_owner`. */ function balanceOf(address _owner) view public returns (uint balance) { return balances[_owner]; } /* ERC 20 compatible functions */ function transferFrom (address _from, address _to, uint256 _value) public returns (bool success) { if (allowances [_from][msg.sender] < _value) return false; if (balances [_from] < _value) return false; allowances [_from][msg.sender] = allowances [_from][msg.sender].sub(_value); if (_value > 0 && _from != _to) { balances [_from] = balances [_from].sub(_value); balances [_to] = balances [_to].add(_value); emit Transfer (_from, _to, _value); } return true; } function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } function allowance (address _owner, address _spender) view public returns (uint256 remaining) { return allowances [_owner][_spender]; } } contract ERC223ReceivingContract { /** * @dev Standard ERC223 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint _value, bytes _data) public; } contract LykkeTokenErc223Base is ERC223Token { address internal _issuer; string public standard; string public name; string public symbol; uint8 public decimals; function LykkeTokenErc223Base( address issuer, string tokenName, uint8 divisibility, string tokenSymbol, string version, uint256 totalSupply) ERC223Token(totalSupply) public{ symbol = tokenSymbol; standard = version; name = tokenName; decimals = divisibility; _issuer = issuer; } } contract EmissiveErc223Token is LykkeTokenErc223Base { using SafeMath for uint; function EmissiveErc223Token( address issuer, string tokenName, uint8 divisibility, string tokenSymbol, string version) LykkeTokenErc223Base(issuer, tokenName, divisibility, tokenSymbol, version, 0) public{ balances [_issuer] = SafeMath.GET_MAX_UINT256(); } function totalSupply () view public returns (uint256 supply) { return SafeMath.GET_MAX_UINT256().sub(balances [_issuer]); } function balanceOf (address _owner) view public returns (uint256 balance) { return _owner == _issuer ? 0 : ERC223Token.balanceOf (_owner); } } contract LyCI is EmissiveErc223Token { using SafeMath for uint; string public termsAndConditionsUrl; address public owner; function LyCI( address issuer, string tokenName, uint8 divisibility, string tokenSymbol, string version) EmissiveErc223Token(issuer, tokenName, divisibility, tokenSymbol, version) public{ owner = msg.sender; } function getTermsAndConditions () public view returns (string tc) { return termsAndConditionsUrl; } function setTermsAndConditions (string _newTc) public { if (msg.sender != owner){ revert("Only owner is allowed to change T & C"); } termsAndConditionsUrl = _newTc; } }
0x6080604052600436106100e55763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663047fc9aa81146100ea57806306fdde0314610111578063095ea7b31461019b57806318160ddd146101d357806323b872dd146101e8578063313ce56714610212578063524f22071461023d5780635a3b7e421461025257806370a08231146102675780638da5cb5b1461028857806395d89b41146102b9578063a9059cbb146102ce578063be45fd62146102f2578063dd62ed3e1461035b578063fd70813b14610382578063fe460201146103dd575b600080fd5b3480156100f657600080fd5b506100ff6103f2565b60408051918252519081900360200190f35b34801561011d57600080fd5b506101266103f8565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610160578181015183820152602001610148565b50505050905090810190601f16801561018d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101a757600080fd5b506101bf600160a060020a0360043516602435610486565b604080519115158252519081900360200190f35b3480156101df57600080fd5b506100ff6104ec565b3480156101f457600080fd5b506101bf600160a060020a0360043581169060243516604435610525565b34801561021e57600080fd5b506102276106bf565b6040805160ff9092168252519081900360200190f35b34801561024957600080fd5b506101266106c8565b34801561025e57600080fd5b50610126610723565b34801561027357600080fd5b506100ff600160a060020a036004351661077e565b34801561029457600080fd5b5061029d6107ad565b60408051600160a060020a039092168252519081900360200190f35b3480156102c557600080fd5b506101266107bc565b3480156102da57600080fd5b506101bf600160a060020a0360043516602435610817565b3480156102fe57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101bf948235600160a060020a0316946024803595369594606494920191908190840183828082843750949750610a849650505050505050565b34801561036757600080fd5b506100ff600160a060020a0360043581169060243516610c66565b34801561038e57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526103db943694929360249392840191908190840183828082843750949750610c919650505050505050565b005b3480156103e957600080fd5b50610126610d47565b60025481565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561047e5780601f106104535761010080835404028352916020019161047e565b820191906000526020600020905b81548152906001019060200180831161046157829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b600354600160a060020a031660009081526020819052604081205461051f90610513610ddd565b9063ffffffff610de316565b90505b90565b600160a060020a0383166000908152600160209081526040808320338452909152812054821115610558575060006106b8565b600160a060020a038416600090815260208190526040902054821115610580575060006106b8565b600160a060020a03841660009081526001602090815260408083203384529091529020546105b4908363ffffffff610de316565b600160a060020a0385166000908152600160209081526040808320338452909152812091909155821180156105fb575082600160a060020a031684600160a060020a031614155b156106b457600160a060020a038416600090815260208190526040902054610629908363ffffffff610de316565b600160a060020a03808616600090815260208190526040808220939093559085168152205461065e908363ffffffff610df716565b600160a060020a038085166000818152602081815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b5060015b9392505050565b60075460ff1681565b6008805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561047e5780601f106104535761010080835404028352916020019161047e565b6004805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561047e5780601f106104535761010080835404028352916020019161047e565b600354600090600160a060020a038381169116146107a45761079f82610e08565b6107a7565b60005b92915050565b600954600160a060020a031681565b6006805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561047e5780601f106104535761010080835404028352916020019161047e565b33600090815260208190526040812054833b90606090839061083f908663ffffffff610de316565b3360009081526020819052604080822092909255600160a060020a03881681522054610871908663ffffffff610df716565b600160a060020a03871660009081526020819052604081209190915583111561098357506040517fc0ee0b8a0000000000000000000000000000000000000000000000000000000081523360048201818152602483018790526060604484019081528451606485015284518994600160a060020a0386169463c0ee0b8a9490938b93899360840190602085019080838360005b8381101561091c578181015183820152602001610904565b50505050905090810190601f1680156109495780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561096a57600080fd5b505af115801561097e573d6000803e3d6000fd5b505050505b85600160a060020a031633600160a060020a03167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c1687856040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156109fd5781810151838201526020016109e5565b50505050905090810190601f168015610a2a5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a3604080518681529051600160a060020a0388169133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350600195945050505050565b33600090815260208190526040812054843b908290610aa9908663ffffffff610de316565b3360009081526020819052604080822092909255600160a060020a03881681522054610adb908663ffffffff610df716565b600160a060020a038716600090815260208190526040812091909155821115610bed57506040517fc0ee0b8a0000000000000000000000000000000000000000000000000000000081523360048201818152602483018790526060604484019081528651606485015286518994600160a060020a0386169463c0ee0b8a9490938b938b9360840190602085019080838360005b83811015610b86578181015183820152602001610b6e565b50505050905090810190601f168015610bb35780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015610bd457600080fd5b505af1158015610be8573d6000803e3d6000fd5b505050505b85600160a060020a031633600160a060020a03167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c168787604051808381526020018060200182810382528381815181526020019150805190602001908083836000838110156109fd5781810151838201526020016109e5565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b600954600160a060020a03163314610d3057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4f6e6c79206f776e657220697320616c6c6f77656420746f206368616e67652060448201527f5420262043000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b8051610d43906008906020840190610e32565b5050565b60088054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610dd35780601f10610da857610100808354040283529160200191610dd3565b820191906000526020600020905b815481529060010190602001808311610db657829003601f168201915b5050505050905090565b60001990565b6000610df183831115610e23565b50900390565b60008282016106b884821015610e23565b600160a060020a031660009081526020819052604090205490565b801515610e2f57600080fd5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610e7357805160ff1916838001178555610ea0565b82800160010185558215610ea0579182015b82811115610ea0578251825591602001919060010190610e85565b50610eac929150610eb0565b5090565b61052291905b80821115610eac5760008155600101610eb65600a165627a7a723058202069cbfba8f40e26997d6cec49a52a62405800f63b3f93b6daca13b7f4d8db640029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 12740, 2683, 2487, 2278, 23632, 2575, 2487, 6679, 28756, 11057, 2581, 23352, 10354, 2692, 2581, 2620, 17134, 2581, 2683, 2094, 15136, 21926, 24096, 2575, 2278, 2546, 3075, 3647, 18900, 2232, 1063, 21318, 3372, 17788, 2575, 5377, 2270, 4098, 1035, 21318, 3372, 17788, 2575, 1027, 1014, 2595, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 4246, 1025, 3853, 2131, 1035, 4098, 1035, 21318, 3372, 17788, 2575, 1006, 1007, 5760, 4722, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2709, 4098, 1035, 21318, 3372, 17788, 2575, 1025, 1065, 3853, 14163, 2140, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 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,904
0x97940C7aea99998da4c56922211ce012E7765395
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity =0.8.7; interface IERC20Like { function approve(address spender_, uint256 amount_) external returns (bool success_); function balanceOf(address account_) external view returns (uint256 balance_); function transfer(address recipient_, uint256 amount_) external returns (bool success_); function transferFrom(address owner_, address recipient_, uint256 amount_) external returns (bool success_); } interface ILenderLike { function poolDelegate() external view returns (address poolDelegate_); } interface IMapleGlobalsLike { function investorFee() external view returns (uint256 investorFee_); function mapleTreasury() external view returns (address mapleTreasury_); function protocolPaused() external view returns (bool paused_); function treasuryFee() external view returns (uint256 treasuryFee_); } interface IMapleProxyFactoryLike { function mapleGlobals() external view returns (address mapleGlobals_); function upgradeInstance(uint256 toVersion_, bytes calldata arguments_) external; } /// @title Small Library to standardize erc20 token interactions. library ERC20Helper { /**************************/ /*** Internal Functions ***/ /**************************/ function transfer(address token_, address to_, uint256 amount_) internal returns (bool success_) { return _call(token_, abi.encodeWithSelector(IERC20Like.transfer.selector, to_, amount_)); } function transferFrom(address token_, address from_, address to_, uint256 amount_) internal returns (bool success_) { return _call(token_, abi.encodeWithSelector(IERC20Like.transferFrom.selector, from_, to_, amount_)); } function approve(address token_, address spender_, uint256 amount_) internal returns (bool success_) { // If setting approval to zero fails, return false. if (!_call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, uint256(0)))) return false; // If `amount_` is zero, return true as the previous step already did this. if (amount_ == uint256(0)) return true; // Return the result of setting the approval to `amount_`. return _call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, amount_)); } function _call(address token_, bytes memory data_) private returns (bool success_) { if (token_.code.length == uint256(0)) return false; bytes memory returnData; ( success_, returnData ) = token_.call(data_); return success_ && (returnData.length == uint256(0) || abi.decode(returnData, (bool))); } } /// @title An implementation that is to be proxied, must implement IProxied. interface IProxied { /** * @dev The address of the proxy factory. */ function factory() external view returns (address factory_); /** * @dev The address of the implementation contract being proxied. */ function implementation() external view returns (address implementation_); /** * @dev Modifies the proxy's implementation address. * @param newImplementation_ The address of an implementation contract. */ function setImplementation(address newImplementation_) external; /** * @dev Modifies the proxy's storage by delegate-calling a migrator contract with some arguments. * Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled. * @param migrator_ The address of a migrator contract. * @param arguments_ Some encoded arguments to use for the migration. */ function migrate(address migrator_, bytes calldata arguments_) external; } /// @title A Maple implementation that is to be proxied, must implement IMapleProxied. interface IMapleProxied is IProxied { /** * @dev The instance was upgraded. * @param toVersion_ The new version of the loan. * @param arguments_ The upgrade arguments, if any. */ event Upgraded(uint256 toVersion_, bytes arguments_); /** * @dev Upgrades a contract implementation to a specific version. * Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled. * @param toVersion_ The version to upgrade to. * @param arguments_ Some encoded arguments to use for the upgrade. */ function upgrade(uint256 toVersion_, bytes calldata arguments_) external; } /// @title IMapleLoanEvents defines the events for a MapleLoan. interface IMapleLoanEvents { /** * @dev Borrower was accepted, and set to a new account. * @param borrower_ The address of the new borrower. */ event BorrowerAccepted(address indexed borrower_); /** * @dev Collateral was posted. * @param amount_ The amount of collateral posted. */ event CollateralPosted(uint256 amount_); /** * @dev Collateral was removed. * @param amount_ The amount of collateral removed. * @param destination_ The recipient of the collateral removed. */ event CollateralRemoved(uint256 amount_, address indexed destination_); /** * @dev The loan was funded. * @param lender_ The address of the lender. * @param amount_ The amount funded. * @param nextPaymentDueDate_ The due date of the next payment. */ event Funded(address indexed lender_, uint256 amount_, uint256 nextPaymentDueDate_); /** * @dev Funds were claimed. * @param amount_ The amount of funds claimed. * @param destination_ The recipient of the funds claimed. */ event FundsClaimed(uint256 amount_, address indexed destination_); /** * @dev Funds were drawn. * @param amount_ The amount of funds drawn. * @param destination_ The recipient of the funds drawn down. */ event FundsDrawnDown(uint256 amount_, address indexed destination_); /** * @dev Funds were redirected on an additional `fundLoan` call. * @param amount_ The amount of funds redirected. * @param destination_ The recipient of the redirected funds. */ event FundsRedirected(uint256 amount_, address indexed destination_); /** * @dev Funds were returned. * @param amount_ The amount of funds returned. */ event FundsReturned(uint256 amount_); /** * @dev The loan was initialized. * @param borrower_ The address of the borrower. * @param assets_ Array of asset addresses. * [0]: collateralAsset, * [1]: fundsAsset. * @param termDetails_ Array of loan parameters: * [0]: gracePeriod, * [1]: paymentInterval, * [2]: payments, * @param amounts_ Requested amounts: * [0]: collateralRequired, * [1]: principalRequested, * [2]: endingPrincipal. * @param rates_ Fee parameters: * [0]: interestRate, * [1]: earlyFeeRate, * [2]: lateFeeRate, * [3]: lateInterestPremium. */ event Initialized(address indexed borrower_, address[2] assets_, uint256[3] termDetails_, uint256[3] amounts_, uint256[4] rates_); /** * @dev Lender was accepted, and set to a new account. * @param lender_ The address of the new lender. */ event LenderAccepted(address indexed lender_); /** * @dev Loan was repaid early and closed. * @param principalPaid_ The portion of the total amount that went towards principal. * @param interestPaid_ The portion of the total amount that went towards interest fees. */ event LoanClosed(uint256 principalPaid_, uint256 interestPaid_); /** * @dev A refinance was proposed. * @param refinanceCommitment_ The hash of the refinancer and calls proposed. * @param refinancer_ The address that will execute the refinance. * @param calls_ The individual calls for the refinancer contract. */ event NewTermsAccepted(bytes32 refinanceCommitment_, address refinancer_, bytes[] calls_); /** * @dev A refinance was proposed. * @param refinanceCommitment_ The hash of the refinancer and calls proposed. * @param refinancer_ The address that will execute the refinance. * @param calls_ The individual calls for the refinancer contract. */ event NewTermsProposed(bytes32 refinanceCommitment_, address refinancer_, bytes[] calls_); /** * @dev Payments were made. * @param principalPaid_ The portion of the total amount that went towards principal. * @param interestPaid_ The portion of the total amount that went towards interest fees. */ event PaymentMade(uint256 principalPaid_, uint256 interestPaid_); /** * @dev Pending borrower was set. * @param pendingBorrower_ Address that can accept the borrower role. */ event PendingBorrowerSet(address pendingBorrower_); /** * @dev Pending lender was set. * @param pendingLender_ Address that can accept the lender role. */ event PendingLenderSet(address pendingLender_); /** * @dev The loan was in default and funds and collateral was repossessed by the lender. * @param collateralRepossessed_ The amount of collateral asset repossessed. * @param fundsRepossessed_ The amount of funds asset repossessed. * @param destination_ The recipient of the collateral and funds, if any. */ event Repossessed(uint256 collateralRepossessed_, uint256 fundsRepossessed_, address indexed destination_); /** * @dev Some token (neither fundsAsset nor collateralAsset) was removed from the loan. * @param token_ The address of the token contract. * @param amount_ The amount of token remove from the loan. * @param destination_ The recipient of the token. */ event Skimmed(address indexed token_, uint256 amount_, address indexed destination_); } /// @title MapleLoan implements a primitive loan with additional functionality, and is intended to be proxied. interface IMapleLoan is IMapleProxied, IMapleLoanEvents { /***********************/ /*** State Variables ***/ /***********************/ /** * @dev The borrower of the loan, responsible for repayments. */ function borrower() external view returns (address borrower_); /** * @dev The amount of funds that have yet to be claimed by the lender. */ function claimableFunds() external view returns (uint256 claimableFunds_); /** * @dev The amount of collateral posted against outstanding (drawn down) principal. */ function collateral() external view returns (uint256 collateral_); /** * @dev The address of the asset deposited by the borrower as collateral, if needed. */ function collateralAsset() external view returns (address collateralAsset_); /** * @dev The amount of collateral required if all of the principal required is drawn down. */ function collateralRequired() external view returns (uint256 collateralRequired_); /** * @dev The amount of funds that have yet to be drawn down by the borrower. */ function drawableFunds() external view returns (uint256 drawableFunds_); /** * @dev The rate charged at early payments. * This value should be configured so that it is less expensive to close a loan with more than one payment remaining, but * more expensive to close it if on the last payment. */ function earlyFeeRate() external view returns (uint256 earlyFeeRate_); /** * @dev The portion of principal to not be paid down as part of payment installments, which would need to be paid back upon final payment. * If endingPrincipal = principal, loan is interest-only. */ function endingPrincipal() external view returns (uint256 endingPrincipal_); /** * @dev The asset deposited by the lender to fund the loan. */ function fundsAsset() external view returns (address fundsAsset_); /** * @dev The amount of time the borrower has, after a payment is due, to make a payment before being in default. */ function gracePeriod() external view returns (uint256 gracePeriod_); /** * @dev The annualized interest rate (APR), in units of 1e18, (i.e. 1% is 0.01e18). */ function interestRate() external view returns (uint256 interestRate_); /** * @dev The rate charged at late payments. */ function lateFeeRate() external view returns (uint256 lateFeeRate_); /** * @dev The premium over the regular interest rate applied when paying late. */ function lateInterestPremium() external view returns (uint256 lateInterestPremium_); /** * @dev The lender of the Loan. */ function lender() external view returns (address lender_); /** * @dev The timestamp due date of the next payment. */ function nextPaymentDueDate() external view returns (uint256 nextPaymentDueDate_); /** * @dev The specified time between loan payments. */ function paymentInterval() external view returns (uint256 paymentInterval_); /** * @dev The number of payment installments remaining for the loan. */ function paymentsRemaining() external view returns (uint256 paymentsRemaining_); /** * @dev The address of the pending borrower. */ function pendingBorrower() external view returns (address pendingBorrower_); /** * @dev The address of the pending lender. */ function pendingLender() external view returns (address pendingLender_); /** * @dev The amount of principal owed (initially, the requested amount), which needs to be paid back. */ function principal() external view returns (uint256 principal_); /** * @dev The initial principal amount requested by the borrower. */ function principalRequested() external view returns (uint256 principalRequested_); /** * @dev The factory address that deployed this contract (necessary for PoolV1 integration). */ function superFactory() external view returns (address superFactory_); /********************************/ /*** State Changing Functions ***/ /********************************/ /** * @dev Accept the borrower role, must be called by pendingBorrower. */ function acceptBorrower() external; /** * @dev Accept the lender role, must be called by pendingLender. */ function acceptLender() external; /** * @dev Accept the proposed terms ans trigger refinance execution * @param refinancer_ The address of the refinancer contract. * @param calls_ The encoded arguments to be passed to refinancer. * @param amount_ An amount to pull from the caller, if any. */ function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external; /** * @dev Claim funds that have been paid (principal, interest, and late fees). * @param amount_ The amount to be claimed. * @param destination_ The address to send the funds. */ function claimFunds(uint256 amount_, address destination_) external; /** * @dev Repay all principal and fees and close a loan. * @param amount_ An amount to pull from the caller, if any. * @return principal_ The portion of the amount paid paying back principal. * @return interest_ The portion of the amount paid paying interest fees. */ function closeLoan(uint256 amount_) external returns (uint256 principal_, uint256 interest_); /** * @dev Draw down funds from the loan. * @param amount_ The amount to draw down. * @param destination_ The address to send the funds. * @return collateralPosted_ The amount of additional collateral posted, if any. */ function drawdownFunds(uint256 amount_, address destination_) external returns (uint256 collateralPosted_); /** * @dev Lend funds to the loan/borrower. * @param lender_ The address to be registered as the lender. * @param amount_ An amount to pull from the caller, if any. * @return fundsLent_ The amount funded. */ function fundLoan(address lender_, uint256 amount_) external returns (uint256 fundsLent_); /** * @dev Make a payment to the loan. * @param amount_ An amount to pull from the caller, if any. * @return principal_ The portion of the amount paid paying back principal. * @return interest_ The portion of the amount paid paying interest fees. */ function makePayment(uint256 amount_) external returns (uint256 principal_, uint256 interest_); /** * @dev Post collateral to the loan. * @param amount_ An amount to pull from the caller, if any. * @return collateralPosted_ The amount posted. */ function postCollateral(uint256 amount_) external returns (uint256 collateralPosted_); /** * @dev Propose new terms for refinance * @param refinancer_ The address of the refinancer contract. * @param calls_ The encoded arguments to be passed to refinancer. */ function proposeNewTerms(address refinancer_, bytes[] calldata calls_) external; /** * @dev Remove collateral from the loan (opposite of posting collateral). * @param amount_ The amount removed. * @param destination_ The destination to send the removed collateral. */ function removeCollateral(uint256 amount_, address destination_) external; /** * @dev Return funds to the loan (opposite of drawing down). * @param amount_ An amount to pull from the caller, if any. * @return fundsReturned_ The amount returned. */ function returnFunds(uint256 amount_) external returns (uint256 fundsReturned_); /** * @dev Repossess collateral, and any funds, for a loan in default. * @param destination_ The address where the collateral and funds asset is to be sent, if any. * @return collateralRepossessed_ The amount of collateral asset repossessed. * @return fundsRepossessed_ The amount of funds asset repossessed. */ function repossess(address destination_) external returns (uint256 collateralRepossessed_, uint256 fundsRepossessed_); /** * @dev Set the pendingBorrower to a new account. * @param pendingBorrower_ The address of the new pendingBorrower. */ function setPendingBorrower(address pendingBorrower_) external; /** * @dev Set the pendingLender to a new account. * @param pendingLender_ The address of the new pendingLender. */ function setPendingLender(address pendingLender_) external; /** * @dev Remove some token (neither fundsAsset nor collateralAsset) from the loan. * @param token_ The address of the token contract. * @param destination_ The recipient of the token. * @return skimmed_ The amount of token removed from the loan. */ function skim(address token_, address destination_) external returns (uint256 skimmed_); /**********************/ /*** View Functions ***/ /**********************/ /** * @dev Returns the excess collateral that can be removed. * @return excessCollateral_ The excess collateral that can be removed, if any. */ function excessCollateral() external view returns (uint256 excessCollateral_); /** * @dev Get the additional collateral to be posted to drawdown some amount. * @param drawdown_ The amount desired to be drawn down. * @return additionalCollateral_ The additional collateral that must be posted, if any. */ function getAdditionalCollateralRequiredFor(uint256 drawdown_) external view returns (uint256 additionalCollateral_); /** * @dev Get the breakdown of the total payment needed to satisfy an early repayment. * @return totalPrincipalAmount_ The portion of the total amount that will go towards principal. * @return totalInterestFees_ The portion of the total amount that will go towards interest fees. */ function getEarlyPaymentBreakdown() external view returns ( uint256 totalPrincipalAmount_, uint256 totalInterestFees_ ); /** * @dev Get the breakdown of the total payment needed to satisfy `numberOfPayments` payment installments. * @return totalPrincipalAmount_ The portion of the total amount that will go towards principal. * @return totalInterestFees_ The portion of the total amount that will go towards interest fees. */ function getNextPaymentBreakdown() external view returns ( uint256 totalPrincipalAmount_, uint256 totalInterestFees_ ); /** * @dev Returns whether the protocol is paused. * @return paused_ A boolean indicating if protocol is paused. */ function isProtocolPaused() external view returns (bool paused_); } abstract contract SlotManipulatable { function _getReferenceTypeSlot(bytes32 slot_, bytes32 key_) internal pure returns (bytes32 value_) { return keccak256(abi.encodePacked(key_, slot_)); } function _getSlotValue(bytes32 slot_) internal view returns (bytes32 value_) { assembly { value_ := sload(slot_) } } function _setSlotValue(bytes32 slot_, bytes32 value_) internal { assembly { sstore(slot_, value_) } } } /// @title An implementation that is to be proxied, will need ProxiedInternals. abstract contract ProxiedInternals is SlotManipulatable { /// @dev Storage slot with the address of the current factory. `keccak256('eip1967.proxy.factory') - 1`. bytes32 private constant FACTORY_SLOT = bytes32(0x7a45a402e4cb6e08ebc196f20f66d5d30e67285a2a8aa80503fa409e727a4af1); /// @dev Storage slot with the address of the current factory. `keccak256('eip1967.proxy.implementation') - 1`. bytes32 private constant IMPLEMENTATION_SLOT = bytes32(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc); /// @dev Delegatecalls to a migrator contract to manipulate storage during an initialization or migration. function _migrate(address migrator_, bytes calldata arguments_) internal virtual returns (bool success_) { uint256 size; assembly { size := extcodesize(migrator_) } if (size == uint256(0)) return false; ( success_, ) = migrator_.delegatecall(arguments_); } /// @dev Sets the factory address in storage. function _setFactory(address factory_) internal virtual returns (bool success_) { _setSlotValue(FACTORY_SLOT, bytes32(uint256(uint160(factory_)))); return true; } /// @dev Sets the implementation address in storage. function _setImplementation(address implementation_) internal virtual returns (bool success_) { _setSlotValue(IMPLEMENTATION_SLOT, bytes32(uint256(uint160(implementation_)))); return true; } /// @dev Returns the factory address. function _factory() internal view virtual returns (address factory_) { return address(uint160(uint256(_getSlotValue(FACTORY_SLOT)))); } /// @dev Returns the implementation address. function _implementation() internal view virtual returns (address implementation_) { return address(uint160(uint256(_getSlotValue(IMPLEMENTATION_SLOT)))); } } /// @title A Maple implementation that is to be proxied, will need MapleProxiedInternals. abstract contract MapleProxiedInternals is ProxiedInternals {} /// @title MapleLoanInternals defines the storage layout and internal logic of MapleLoan. abstract contract MapleLoanInternals is MapleProxiedInternals { uint256 private constant SCALED_ONE = uint256(10 ** 18); // Roles address internal _borrower; // The address of the borrower. address internal _lender; // The address of the lender. address internal _pendingBorrower; // The address of the pendingBorrower, the only address that can accept the borrower role. address internal _pendingLender; // The address of the pendingLender, the only address that can accept the lender role. // Assets address internal _collateralAsset; // The address of the asset used as collateral. address internal _fundsAsset; // The address of the asset used as funds. // Loan Term Parameters uint256 internal _gracePeriod; // The number of seconds a payment can be late. uint256 internal _paymentInterval; // The number of seconds between payments. // Rates uint256 internal _interestRate; // The annualized interest rate of the loan. uint256 internal _earlyFeeRate; // The fee rate for prematurely closing loans. uint256 internal _lateFeeRate; // The fee rate for late payments. uint256 internal _lateInterestPremium; // The amount to increase the interest rate by for late payments. // Requested Amounts uint256 internal _collateralRequired; // The collateral the borrower is expected to put up to draw down all _principalRequested. uint256 internal _principalRequested; // The funds the borrowers wants to borrow. uint256 internal _endingPrincipal; // The principal to remain at end of loan. // State uint256 internal _drawableFunds; // The amount of funds that can be drawn down. uint256 internal _claimableFunds; // The amount of funds that the lender can claim (principal repayments, interest, etc). uint256 internal _collateral; // The amount of collateral, in collateral asset, that is currently posted. uint256 internal _nextPaymentDueDate; // The timestamp of due date of next payment. uint256 internal _paymentsRemaining; // The number of payments remaining. uint256 internal _principal; // The amount of principal yet to be paid down. // Refinance bytes32 internal _refinanceCommitment; /**********************************/ /*** Internal General Functions ***/ /**********************************/ /// @dev Clears all state variables to end a loan, but keep borrower and lender withdrawal functionality intact. function _clearLoanAccounting() internal { _gracePeriod = uint256(0); _paymentInterval = uint256(0); _interestRate = uint256(0); _earlyFeeRate = uint256(0); _lateFeeRate = uint256(0); _lateInterestPremium = uint256(0); _endingPrincipal = uint256(0); _nextPaymentDueDate = uint256(0); _paymentsRemaining = uint256(0); _principal = uint256(0); } /** * @dev Initializes the loan. * @param borrower_ The address of the borrower. * @param assets_ Array of asset addresses. * [0]: collateralAsset, * [1]: fundsAsset. * @param termDetails_ Array of loan parameters: * [0]: gracePeriod, * [1]: paymentInterval, * [2]: payments, * @param amounts_ Requested amounts: * [0]: collateralRequired, * [1]: principalRequested, * [2]: endingPrincipal. * @param rates_ Fee parameters: * [0]: interestRate, * [1]: earlyFeeRate, * [2]: lateFeeRate, * [3]: lateInterestPremium. */ function _initialize( address borrower_, address[2] memory assets_, uint256[3] memory termDetails_, uint256[3] memory amounts_, uint256[4] memory rates_ ) internal { // Principal requested needs to be non-zero (see `_getCollateralRequiredFor` math). require(amounts_[1] > uint256(0), "MLI:I:INVALID_PRINCIPAL"); // Ending principal needs to be less than or equal to principal requested. require(amounts_[2] <= amounts_[1], "MLI:I:INVALID_ENDING_PRINCIPAL"); require((_borrower = borrower_) != address(0), "MLI:I:INVALID_BORROWER"); _collateralAsset = assets_[0]; _fundsAsset = assets_[1]; _gracePeriod = termDetails_[0]; _paymentInterval = termDetails_[1]; _paymentsRemaining = termDetails_[2]; _collateralRequired = amounts_[0]; _principalRequested = amounts_[1]; _endingPrincipal = amounts_[2]; _interestRate = rates_[0]; _earlyFeeRate = rates_[1]; _lateFeeRate = rates_[2]; _lateInterestPremium = rates_[3]; } /**************************************/ /*** Internal Borrow-side Functions ***/ /**************************************/ /// @dev Prematurely ends a loan by making all remaining payments. function _closeLoan() internal returns (uint256 principal_, uint256 interest_) { require(block.timestamp <= _nextPaymentDueDate, "MLI:CL:PAYMENT_IS_LATE"); ( principal_, interest_ ) = _getEarlyPaymentBreakdown(); uint256 totalPaid = principal_ + interest_; // The drawable funds are increased by the extra funds in the contract, minus the total needed for payment. _drawableFunds = _drawableFunds + _getUnaccountedAmount(_fundsAsset) - totalPaid; _claimableFunds += totalPaid; _clearLoanAccounting(); } /// @dev Sends `amount_` of `_drawableFunds` to `destination_`. function _drawdownFunds(uint256 amount_, address destination_) internal { _drawableFunds -= amount_; require(ERC20Helper.transfer(_fundsAsset, destination_, amount_), "MLI:DF:TRANSFER_FAILED"); require(_isCollateralMaintained(), "MLI:DF:INSUFFICIENT_COLLATERAL"); } /// @dev Makes a payment to progress the loan closer to maturity. function _makePayment() internal returns (uint256 principal_, uint256 interest_) { ( principal_, interest_ ) = _getNextPaymentBreakdown(); uint256 totalPaid = principal_ + interest_; // The drawable funds are increased by the extra funds in the contract, minus the total needed for payment. // NOTE: This line will revert if not enough funds were added for the full payment amount. _drawableFunds = (_drawableFunds + _getUnaccountedAmount(_fundsAsset)) - totalPaid; _claimableFunds += totalPaid; uint256 paymentsRemaining = _paymentsRemaining; if (paymentsRemaining == uint256(1)) { _clearLoanAccounting(); // Assumes `_getNextPaymentBreakdown` returns a `principal_` that is `_principal`. } else { _nextPaymentDueDate += _paymentInterval; _principal -= principal_; _paymentsRemaining = paymentsRemaining - uint256(1); } } /// @dev Registers the delivery of an amount of collateral to be posted. function _postCollateral() internal returns (uint256 collateralPosted_) { _collateral += (collateralPosted_ = _getUnaccountedAmount(_collateralAsset)); } /// @dev Sets refinance commitment given refinance operations. function _proposeNewTerms(address refinancer_, bytes[] calldata calls_) internal returns (bytes32 proposedRefinanceCommitment_) { // NOTE: There is no way to invalidate the `refinanceCommitment` (i.e. bytes32(0)) without explicitly setting it if `calls_.length` is 0. return _refinanceCommitment = calls_.length > uint256(0) ? _getRefinanceCommitment(refinancer_, calls_) : bytes32(0); } /// @dev Sends `amount_` of `_collateral` to `destination_`. function _removeCollateral(uint256 amount_, address destination_) internal { _collateral -= amount_; require(ERC20Helper.transfer(_collateralAsset, destination_, amount_), "MLI:RC:TRANSFER_FAILED"); require(_isCollateralMaintained(), "MLI:RC:INSUFFICIENT_COLLATERAL"); } /// @dev Registers the delivery of an amount of funds to be returned as `_drawableFunds`. function _returnFunds() internal returns (uint256 fundsReturned_) { _drawableFunds += (fundsReturned_ = _getUnaccountedAmount(_fundsAsset)); } /************************************/ /*** Internal Lend-side Functions ***/ /************************************/ /// @dev Processes refinance operations. function _acceptNewTerms(address refinancer_, bytes[] calldata calls_) internal returns (bytes32 acceptedRefinanceCommitment_) { // NOTE: A zero refinancer address and/or empty calls array will never (probabilistically) match a refinance commitment in storage. require(_refinanceCommitment == (acceptedRefinanceCommitment_ = _getRefinanceCommitment(refinancer_, calls_)), "MLI:ANT:COMMITMENT_MISMATCH"); require(refinancer_.code.length != uint256(0), "MLI:ANT:INVALID_REFINANCER"); // Clear refinance commitment to prevent implications of re-acceptance of another call to `_acceptNewTerms`. _refinanceCommitment = bytes32(0); uint256 callCount = calls_.length; for (uint256 i; i < callCount; ++i) { ( bool success, ) = refinancer_.delegatecall(calls_[i]); require(success, "MLI:ANT:FAILED"); } // Ensure that collateral is maintained after changes made. require(_isCollateralMaintained(), "MLI:ANT:INSUFFICIENT_COLLATERAL"); } /// @dev Sends `amount_` of `_claimableFunds` to `destination_`. /// If `amount_` is higher than `_claimableFunds` the transaction will underflow and revert. function _claimFunds(uint256 amount_, address destination_) internal { _claimableFunds -= amount_; require(ERC20Helper.transfer(_fundsAsset, destination_, amount_), "MLI:CF:TRANSFER_FAILED"); } /// @dev Fund the loan and kick off the repayment requirements. function _fundLoan(address lender_) internal returns (uint256 fundsLent_) { uint256 paymentsRemaining = _paymentsRemaining; // Can only fund loan if there are payments remaining (as defined by the initialization) and no payment is due yet (as set by a funding). require((_nextPaymentDueDate == uint256(0)) && (paymentsRemaining != uint256(0)), "MLI:FL:LOAN_ACTIVE"); uint256 paymentInterval = _paymentInterval; // NOTE: Don't need to check if lender_ is nonzero or valid, since it is done implicitly in calls to `lender_` below. _lender = lender_; _nextPaymentDueDate = block.timestamp + paymentInterval; // Amount funded and principal are as requested. fundsLent_ = _principal = _principalRequested; address fundsAsset = _fundsAsset; // Cannot under-fund loan, but over-funding results in additional funds left unaccounted for. require(_getUnaccountedAmount(fundsAsset) >= fundsLent_, "MLI:FL:WRONG_FUND_AMOUNT"); IMapleGlobalsLike globals = IMapleGlobalsLike(IMapleProxyFactoryLike(_factory()).mapleGlobals()); // Transfer the annualized treasury fee, if any, to the Maple treasury, and decrement drawable funds. uint256 treasuryFee = (fundsLent_ * globals.treasuryFee() * paymentInterval * paymentsRemaining) / uint256(365 days * 10_000); // Transfer delegate fee, if any, to the pool delegate, and decrement drawable funds. uint256 delegateFee = (fundsLent_ * globals.investorFee() * paymentInterval * paymentsRemaining) / uint256(365 days * 10_000); // Drawable funds is the amount funded, minus any fees. _drawableFunds = fundsLent_ - treasuryFee - delegateFee; require( treasuryFee == uint256(0) || ERC20Helper.transfer(fundsAsset, globals.mapleTreasury(), treasuryFee), "MLI:FL:T_TRANSFER_FAILED" ); require( delegateFee == uint256(0) || ERC20Helper.transfer(fundsAsset, ILenderLike(lender_).poolDelegate(), delegateFee), "MLI:FL:PD_TRANSFER_FAILED" ); } /// @dev Reset all state variables in order to release funds and collateral of a loan in default. function _repossess(address destination_) internal returns (uint256 collateralRepossessed_, uint256 fundsRepossessed_) { uint256 nextPaymentDueDate = _nextPaymentDueDate; require( nextPaymentDueDate != uint256(0) && (block.timestamp > nextPaymentDueDate + _gracePeriod), "MLI:R:NOT_IN_DEFAULT" ); _clearLoanAccounting(); // Uniquely in `_repossess`, stop accounting for all funds so that they can be swept. _collateral = uint256(0); _claimableFunds = uint256(0); _drawableFunds = uint256(0); address collateralAsset = _collateralAsset; // Either there is no collateral to repossess, or the transfer of the collateral succeeds. require( (collateralRepossessed_ = _getUnaccountedAmount(collateralAsset)) == uint256(0) || ERC20Helper.transfer(collateralAsset, destination_, collateralRepossessed_), "MLI:R:C_TRANSFER_FAILED" ); address fundsAsset = _fundsAsset; // Either there are no funds to repossess, or the transfer of the funds succeeds. require( (fundsRepossessed_ = _getUnaccountedAmount(fundsAsset)) == uint256(0) || ERC20Helper.transfer(fundsAsset, destination_, fundsRepossessed_), "MLI:R:F_TRANSFER_FAILED" ); } /*******************************/ /*** Internal View Functions ***/ /*******************************/ /// @dev Returns whether the amount of collateral posted is commensurate with the amount of drawn down (outstanding) principal. function _isCollateralMaintained() internal view returns (bool isMaintained_) { return _collateral >= _getCollateralRequiredFor(_principal, _drawableFunds, _principalRequested, _collateralRequired); } /// @dev Get principal and interest breakdown for paying off the entire loan early. function _getEarlyPaymentBreakdown() internal view returns (uint256 principal_, uint256 interest_) { interest_ = ((principal_ = _principal) * _earlyFeeRate) / SCALED_ONE; } /// @dev Get principal and interest breakdown for next standard payment. function _getNextPaymentBreakdown() internal view returns (uint256 principal_, uint256 interest_) { ( principal_, interest_ ) = _getPaymentBreakdown( block.timestamp, _nextPaymentDueDate, _paymentInterval, _principal, _endingPrincipal, _paymentsRemaining, _interestRate, _lateFeeRate, _lateInterestPremium ); } /// @dev Returns the amount of an `asset_` that this contract owns, which is not currently accounted for by its state variables. function _getUnaccountedAmount(address asset_) internal view virtual returns (uint256 unaccountedAmount_) { return IERC20Like(asset_).balanceOf(address(this)) - (asset_ == _collateralAsset ? _collateral : uint256(0)) // `_collateral` is `_collateralAsset` accounted for. - (asset_ == _fundsAsset ? _claimableFunds + _drawableFunds : uint256(0)); // `_claimableFunds` and `_drawableFunds` are `_fundsAsset` accounted for. } /*******************************/ /*** Internal Pure Functions ***/ /*******************************/ /// @dev Returns the total collateral to be posted for some drawn down (outstanding) principal and overall collateral ratio requirement. function _getCollateralRequiredFor( uint256 principal_, uint256 drawableFunds_, uint256 principalRequested_, uint256 collateralRequired_ ) internal pure returns (uint256 collateral_) { // Where (collateral / outstandingPrincipal) should be greater or equal to (collateralRequired / principalRequested). // NOTE: principalRequested_ cannot be 0, which is reasonable, since it means this was never a loan. return principal_ <= drawableFunds_ ? uint256(0) : (collateralRequired_ * (principal_ - drawableFunds_)) / principalRequested_; } /// @dev Returns principal and interest portions of a payment instalment, given generic, stateless loan parameters. function _getInstallment(uint256 principal_, uint256 endingPrincipal_, uint256 interestRate_, uint256 paymentInterval_, uint256 totalPayments_) internal pure virtual returns (uint256 principalAmount_, uint256 interestAmount_) { /*************************************************************************************************\ * | * * A = installment amount | / \ / R \ * * P = principal remaining | | / \ | | ----------------------- | * * R = interest rate | A = | | P * ( 1 + R ) ^ N | - E | * | / \ | * * N = payments remaining | | \ / | | | ( 1 + R ) ^ N | - 1 | * * E = ending principal target | \ / \ \ / / * * | * * |---------------------------------------------------------------- * * * * - Where R is `periodicRate` * * - Where (1 + R) ^ N is `raisedRate` * * - Both of these rates are scaled by 1e18 (e.g., 12% => 0.12 * 10 ** 18) * \*************************************************************************************************/ uint256 periodicRate = _getPeriodicInterestRate(interestRate_, paymentInterval_); uint256 raisedRate = _scaledExponent(SCALED_ONE + periodicRate, totalPayments_, SCALED_ONE); // NOTE: If a lack of precision in `_scaledExponent` results in a `raisedRate` smaller than one, assume it to be one and simplify the equation. if (raisedRate <= SCALED_ONE) return ((principal_ - endingPrincipal_) / totalPayments_, uint256(0)); uint256 total = ((((principal_ * raisedRate) / SCALED_ONE) - endingPrincipal_) * periodicRate) / (raisedRate - SCALED_ONE); interestAmount_ = _getInterest(principal_, interestRate_, paymentInterval_); principalAmount_ = total >= interestAmount_ ? total - interestAmount_ : uint256(0); } /// @dev Returns an amount by applying an annualized and scaled interest rate, to a principal, over an interval of time. function _getInterest(uint256 principal_, uint256 interestRate_, uint256 interval_) internal pure virtual returns (uint256 interest_) { return (principal_ * _getPeriodicInterestRate(interestRate_, interval_)) / SCALED_ONE; } /// @dev Returns total principal and interest portion of a number of payments, given generic, stateless loan parameters and loan state. function _getPaymentBreakdown( uint256 currentTime_, uint256 nextPaymentDueDate_, uint256 paymentInterval_, uint256 principal_, uint256 endingPrincipal_, uint256 paymentsRemaining_, uint256 interestRate_, uint256 lateFeeRate_, uint256 lateInterestPremium_ ) internal pure virtual returns (uint256 principalAmount_, uint256 interestAmount_) { ( principalAmount_, interestAmount_ ) = _getInstallment( principal_, endingPrincipal_, interestRate_, paymentInterval_, paymentsRemaining_ ); principalAmount_ = paymentsRemaining_ == uint256(1) ? principal_ : principalAmount_; if (currentTime_ > nextPaymentDueDate_) { uint256 daysLate = (((currentTime_ - nextPaymentDueDate_ - 1) / 1 days) + 1) * 1 days; interestAmount_ += _getInterest(principal_, interestRate_ + lateInterestPremium_, daysLate); interestAmount_ += (lateFeeRate_ * principal_) / SCALED_ONE; } } /// @dev Returns the interest rate over an interval, given an annualized interest rate. function _getPeriodicInterestRate(uint256 interestRate_, uint256 interval_) internal pure virtual returns (uint256 periodicInterestRate_) { return (interestRate_ * interval_) / uint256(365 days); } /// @dev Returns refinance commitment given refinance parameters. function _getRefinanceCommitment(address refinancer_, bytes[] calldata calls_) internal pure returns (bytes32 refinanceCommitment_) { return keccak256(abi.encode(refinancer_, calls_)); } /** * @dev Returns exponentiation of a scaled base value. * * Walk through example: * LINE | base_ | exponent_ | one_ | result_ * | 3_00 | 18 | 1_00 | 0_00 * A | 3_00 | 18 | 1_00 | 1_00 * B | 3_00 | 9 | 1_00 | 1_00 * C | 9_00 | 9 | 1_00 | 1_00 * D | 9_00 | 9 | 1_00 | 9_00 * B | 9_00 | 4 | 1_00 | 9_00 * C | 81_00 | 4 | 1_00 | 9_00 * B | 81_00 | 2 | 1_00 | 9_00 * C | 6_561_00 | 2 | 1_00 | 9_00 * B | 6_561_00 | 1 | 1_00 | 9_00 * C | 43_046_721_00 | 1 | 1_00 | 9_00 * D | 43_046_721_00 | 1 | 1_00 | 387_420_489_00 * B | 43_046_721_00 | 0 | 1_00 | 387_420_489_00 * * Another implementation of this algorithm can be found in Dapphub's DSMath contract: * https://github.com/dapphub/ds-math/blob/ce67c0fa9f8262ecd3d76b9e4c026cda6045e96c/src/math.sol#L77 */ function _scaledExponent(uint256 base_, uint256 exponent_, uint256 one_) internal pure returns (uint256 result_) { // If exponent_ is odd, set result_ to base_, else set to one_. result_ = exponent_ & uint256(1) != uint256(0) ? base_ : one_; // A // Divide exponent_ by 2 (overwriting itself) and proceed if not zero. while ((exponent_ >>= uint256(1)) != uint256(0)) { // B base_ = (base_ * base_) / one_; // C // If exponent_ is even, go back to top. if (exponent_ & uint256(1) == uint256(0)) continue; // If exponent_ is odd, multiply result_ is multiplied by base_. result_ = (result_ * base_) / one_; // D } } } /// @title MapleLoan implements a primitive loan with additional functionality, and is intended to be proxied. contract MapleLoan is IMapleLoan, MapleLoanInternals { modifier whenProtocolNotPaused() { require(!isProtocolPaused(), "ML:PROTOCOL_PAUSED"); _; } /********************************/ /*** Administrative Functions ***/ /********************************/ function migrate(address migrator_, bytes calldata arguments_) external override { require(msg.sender == _factory(), "ML:M:NOT_FACTORY"); require(_migrate(migrator_, arguments_), "ML:M:FAILED"); } function setImplementation(address newImplementation_) external override { require(msg.sender == _factory(), "ML:SI:NOT_FACTORY"); require(_setImplementation(newImplementation_), "ML:SI:FAILED"); } function upgrade(uint256 toVersion_, bytes calldata arguments_) external override { require(msg.sender == _borrower, "ML:U:NOT_BORROWER"); emit Upgraded(toVersion_, arguments_); IMapleProxyFactoryLike(_factory()).upgradeInstance(toVersion_, arguments_); } /************************/ /*** Borrow Functions ***/ /************************/ function acceptBorrower() external override { require(msg.sender == _pendingBorrower, "ML:AB:NOT_PENDING_BORROWER"); _pendingBorrower = address(0); emit BorrowerAccepted(_borrower = msg.sender); } function closeLoan(uint256 amount_) external override returns (uint256 principal_, uint256 interest_) { // The amount specified is an optional amount to be transfer from the caller, as a convenience for EOAs. require(amount_ == uint256(0) || ERC20Helper.transferFrom(_fundsAsset, msg.sender, address(this), amount_), "ML:CL:TRANSFER_FROM_FAILED"); // If the caller is not the borrower, require that the transferred amount be sufficient to close the loan without touching `_drawableFunds`. if (msg.sender != _borrower) { ( principal_, interest_ ) = _getEarlyPaymentBreakdown(); require(_getUnaccountedAmount(_fundsAsset) >= principal_ + interest_, "ML:CL:CANNOT_USE_DRAWABLE"); } ( principal_, interest_ ) = _closeLoan(); emit LoanClosed(principal_, interest_); } function drawdownFunds(uint256 amount_, address destination_) external override whenProtocolNotPaused returns (uint256 collateralPosted_) { require(msg.sender == _borrower, "ML:DF:NOT_BORROWER"); emit FundsDrawnDown(amount_, destination_); // Post additional collateral required to facilitate this drawdown, if needed. uint256 additionalCollateralRequired = getAdditionalCollateralRequiredFor(amount_); if (additionalCollateralRequired > uint256(0)) { // Determine collateral currently unaccounted for. uint256 unaccountedCollateral = _getUnaccountedAmount(_collateralAsset); // Post required collateral, specifying then amount lacking as the optional amount to be transferred from. collateralPosted_ = postCollateral( additionalCollateralRequired > unaccountedCollateral ? additionalCollateralRequired - unaccountedCollateral : uint256(0) ); } _drawdownFunds(amount_, destination_); } function makePayment(uint256 amount_) external override returns (uint256 principal_, uint256 interest_) { // The amount specified is an optional amount to be transfer from the caller, as a convenience for EOAs. require(amount_ == uint256(0) || ERC20Helper.transferFrom(_fundsAsset, msg.sender, address(this), amount_), "ML:MP:TRANSFER_FROM_FAILED"); // If the caller is not the borrower, require that the transferred amount be sufficient to make a payment without touching `_drawableFunds`. if (msg.sender != _borrower) { ( principal_, interest_ ) = _getNextPaymentBreakdown(); require(_getUnaccountedAmount(_fundsAsset) >= principal_ + interest_, "ML:MP:CANNOT_USE_DRAWABLE"); } ( principal_, interest_ ) = _makePayment(); emit PaymentMade(principal_, interest_); } function postCollateral(uint256 amount_) public override whenProtocolNotPaused returns (uint256 collateralPosted_) { // The amount specified is an optional amount to be transfer from the caller, as a convenience for EOAs. require( amount_ == uint256(0) || ERC20Helper.transferFrom(_collateralAsset, msg.sender, address(this), amount_), "ML:PC:TRANSFER_FROM_FAILED" ); emit CollateralPosted(collateralPosted_ = _postCollateral()); } function proposeNewTerms(address refinancer_, bytes[] calldata calls_) external override whenProtocolNotPaused { require(msg.sender == _borrower, "ML:PNT:NOT_BORROWER"); emit NewTermsProposed(_proposeNewTerms(refinancer_, calls_), refinancer_, calls_); } function removeCollateral(uint256 amount_, address destination_) external override whenProtocolNotPaused { require(msg.sender == _borrower, "ML:RC:NOT_BORROWER"); emit CollateralRemoved(amount_, destination_); _removeCollateral(amount_, destination_); } function returnFunds(uint256 amount_) external override whenProtocolNotPaused returns (uint256 fundsReturned_) { // The amount specified is an optional amount to be transfer from the caller, as a convenience for EOAs. require(amount_ == uint256(0) || ERC20Helper.transferFrom(_fundsAsset, msg.sender, address(this), amount_), "ML:RF:TRANSFER_FROM_FAILED"); emit FundsReturned(fundsReturned_ = _returnFunds()); } function setPendingBorrower(address pendingBorrower_) external override { require(msg.sender == _borrower, "ML:SPB:NOT_BORROWER"); emit PendingBorrowerSet(_pendingBorrower = pendingBorrower_); } /**********************/ /*** Lend Functions ***/ /**********************/ function acceptLender() external override { require(msg.sender == _pendingLender, "ML:AL:NOT_PENDING_LENDER"); _pendingLender = address(0); emit LenderAccepted(_lender = msg.sender); } function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external override whenProtocolNotPaused { address lenderAddress = _lender; require(msg.sender == lenderAddress, "ML:ANT:NOT_LENDER"); address fundsAssetAddress = _fundsAsset; // The amount specified is an optional amount to be transfer from the caller, as a convenience for EOAs. require(amount_ == uint256(0) || ERC20Helper.transferFrom(fundsAssetAddress, msg.sender, address(this), amount_), "ML:ACT:TRANSFER_FROM_FAILED"); emit NewTermsAccepted(_acceptNewTerms(refinancer_, calls_), refinancer_, calls_); uint256 extra = _getUnaccountedAmount(fundsAssetAddress); // NOTE: This block ensures unaccounted funds (pre-existing or due to over-funding) gets redirected to the lender. if (extra > uint256(0)) { emit FundsRedirected(extra, lenderAddress); require(ERC20Helper.transfer(fundsAssetAddress, lenderAddress, extra), "ML:ANT:TRANSFER_FAILED"); } } function claimFunds(uint256 amount_, address destination_) external override whenProtocolNotPaused { require(msg.sender == _lender, "ML:CF:NOT_LENDER"); emit FundsClaimed(amount_, destination_); _claimFunds(amount_, destination_); } function fundLoan(address lender_, uint256 amount_) external override whenProtocolNotPaused returns (uint256 fundsLent_) { address fundsAssetAddress = _fundsAsset; // The amount specified is an optional amount to be transferred from the caller, as a convenience for EOAs. require(amount_ == uint256(0) || ERC20Helper.transferFrom(fundsAssetAddress, msg.sender, address(this), amount_), "ML:FL:TRANSFER_FROM_FAILED"); // If the loan is not active, fund it. if (_nextPaymentDueDate == uint256(0)) { // NOTE: `_nextPaymentDueDate` emitted in event is updated by `_fundLoan`. emit Funded(lender_, fundsLent_ = _fundLoan(lender_), _nextPaymentDueDate); } uint256 extra = _getUnaccountedAmount(fundsAssetAddress); address lenderAddress = _lender; // NOTE: This block is not only a stopgap solution to allow a LiquidityLockerV1 to send funds to a DebtLocker, while maintaining PoolV1 accounting, // but also ensures unaccounted funds (pre-existing or due to over-funding) gets redirected to the lender. if (extra > uint256(0)) { emit FundsRedirected(extra, lenderAddress); require(ERC20Helper.transfer(fundsAssetAddress, lenderAddress, extra), "ML:FL:TRANSFER_FAILED"); } } function repossess(address destination_) external override whenProtocolNotPaused returns (uint256 collateralRepossessed_, uint256 fundsRepossessed_) { require(msg.sender == _lender, "ML:R:NOT_LENDER"); ( collateralRepossessed_, fundsRepossessed_ ) = _repossess(destination_); emit Repossessed(collateralRepossessed_, fundsRepossessed_, destination_); } function setPendingLender(address pendingLender_) external override { require(msg.sender == _lender, "ML:SPL:NOT_LENDER"); emit PendingLenderSet(_pendingLender = pendingLender_); } /*******************************/ /*** Miscellaneous Functions ***/ /*******************************/ function skim(address token_, address destination_) external override whenProtocolNotPaused returns (uint256 skimmed_) { require((msg.sender == _borrower) || (msg.sender == _lender), "L:S:NO_AUTH"); require((token_ != _fundsAsset) && (token_ != _collateralAsset), "L:S:INVALID_TOKEN"); emit Skimmed(token_, skimmed_ = IERC20Like(token_).balanceOf(address(this)), destination_); require(ERC20Helper.transfer(token_, destination_, skimmed_), "L:S:TRANSFER_FAILED"); } /**********************/ /*** View Functions ***/ /**********************/ function getAdditionalCollateralRequiredFor(uint256 drawdown_) public view override returns (uint256 collateral_) { // Determine the collateral needed in the contract for a reduced drawable funds amount. uint256 collateralNeeded = _getCollateralRequiredFor(_principal, _drawableFunds - drawdown_, _principalRequested, _collateralRequired); uint256 currentCollateral = _collateral; return collateralNeeded > currentCollateral ? collateralNeeded - currentCollateral : uint256(0); } function getEarlyPaymentBreakdown() external view override returns (uint256 principal_, uint256 interest_) { ( principal_, interest_ ) = _getEarlyPaymentBreakdown(); } function getNextPaymentBreakdown() external view override returns (uint256 principal_, uint256 interest_) { ( principal_, interest_ ) = _getNextPaymentBreakdown(); } function isProtocolPaused() public view override returns (bool paused_) { return IMapleGlobalsLike(IMapleProxyFactoryLike(_factory()).mapleGlobals()).protocolPaused(); } /****************************/ /*** State View Functions ***/ /****************************/ function borrower() external view override returns (address borrower_) { return _borrower; } function claimableFunds() external view override returns (uint256 claimableFunds_) { return _claimableFunds; } function collateral() external view override returns (uint256 collateral_) { return _collateral; } function collateralAsset() external view override returns (address collateralAsset_) { return _collateralAsset; } function collateralRequired() external view override returns (uint256 collateralRequired_) { return _collateralRequired; } function drawableFunds() external view override returns (uint256 drawableFunds_) { return _drawableFunds; } function earlyFeeRate() external view override returns (uint256 earlyFeeRate_) { return _earlyFeeRate; } function endingPrincipal() external view override returns (uint256 endingPrincipal_) { return _endingPrincipal; } function excessCollateral() external view override returns (uint256 excessCollateral_) { uint256 collateralNeeded = _getCollateralRequiredFor(_principal, _drawableFunds, _principalRequested, _collateralRequired); uint256 currentCollateral = _collateral; return currentCollateral > collateralNeeded ? currentCollateral - collateralNeeded : uint256(0); } function factory() external view override returns (address factory_) { return _factory(); } function fundsAsset() external view override returns (address fundsAsset_) { return _fundsAsset; } function gracePeriod() external view override returns (uint256 gracePeriod_) { return _gracePeriod; } function implementation() external view override returns (address implementation_) { return _implementation(); } function interestRate() external view override returns (uint256 interestRate_) { return _interestRate; } function lateFeeRate() external view override returns (uint256 lateFeeRate_) { return _lateFeeRate; } function lateInterestPremium() external view override returns (uint256 lateInterestPremium_) { return _lateInterestPremium; } function lender() external view override returns (address lender_) { return _lender; } function nextPaymentDueDate() external view override returns (uint256 nextPaymentDueDate_) { return _nextPaymentDueDate; } function paymentInterval() external view override returns (uint256 paymentInterval_) { return _paymentInterval; } function paymentsRemaining() external view override returns (uint256 paymentsRemaining_) { return _paymentsRemaining; } function pendingBorrower() external view override returns (address pendingBorrower_) { return _pendingBorrower; } function pendingLender() external view override returns (address pendingLender_) { return _pendingLender; } function principalRequested() external view override returns (uint256 principalRequested_) { return _principalRequested; } function principal() external view override returns (uint256 principal_) { return _principal; } // NOTE: This is needed for `fundLoan` call from PoolV1. function superFactory() external view override returns (address superFactory_) { return _factory(); } }
0x608060405234801561001057600080fd5b50600436106102a05760003560e01c806375a2067611610167578063bcead63e116100ce578063d784d42611610087578063d784d42614610506578063d8dfeb4514610519578063dac8856114610521578063e1176b9914610539578063e44b38751461054c578063e920b1e11461055457600080fd5b8063bcead63e146104a9578063c3fbb6fd146104ba578063c45a0155146102c6578063ccc04484146104cd578063d05951a0146104e0578063d41ddc96146104f357600080fd5b8063a06db7dc11610120578063a06db7dc14610470578063aabaecd614610478578063b86a513e14610489578063b96b5c9914610491578063b9b1f4e314610499578063ba5d3078146104a157600080fd5b806375a206761461043757806377b3c55c1461043f5780637a0e6fa1146104475780637c3a00fd1461044f5780637df1f1b9146104575780638ffc92151461046857600080fd5b80633b99bcee1161020b5780635114cb52116101c45780635114cb52146103df5780635c60da1b146103f25780635eeb53b4146103fa57806369458ba71461040b578063700f500614610413578063712b772f1461042457600080fd5b80633b99bcee146103635780634003f34d1461037657806345755dd61461037e57806347350e9f146103915780634eac4235146103b957806350f2012f146103cc57600080fd5b8063267f4ac31161025d578063267f4ac3146103095780632ead10981461031c57806330fea1ce14610324578063368d0d2b1461032c578063390d68551461033f57806339ba9f861461035257600080fd5b806301daa38f146102a55780630895326f146102af5780630d49b38c146102c65780630fe3d9b7146102e65780631cc1cf46146102ee5780631f3f19ab146102f6575b600080fd5b6102ad610567565b005b6013545b6040519081526020015b60405180910390f35b6102ce61060d565b6040516001600160a01b0390911681526020016102bd565b6102ad61061c565b6007546102b3565b6102ad610304366004612c61565b6106bf565b6102ad610317366004612c61565b610764565b600b546102b3565b6009546102b3565b6102ad61033a366004612cd4565b610800565b6102ad61034d366004612e4d565b6108c1565b6005546001600160a01b03166102ce565b6102ad610371366004612e72565b610984565b6012546102b3565b6102b361038c366004612e1b565b610a7b565b6103a461039f366004612c61565b610b50565b604080519283526020830191909152016102bd565b6102b36103c7366004612e1b565b610c1c565b6102b36103da366004612e1b565b610c64565b6103a46103ed366004612e1b565b610d20565b6102ce610e68565b6003546001600160a01b03166102ce565b6103a4610e72565b6002546001600160a01b03166102ce565b6102b3610432366004612c9b565b610e86565b600c546102b3565b600a546102b3565b6102b361107d565b6008546102b3565b6000546001600160a01b03166102ce565b600d546102b3565b6006546102b3565b6004546001600160a01b03166102ce565b600e546102b3565b6103a46110b9565b600f546102b3565b6014546102b3565b6001546001600160a01b03166102ce565b6102ad6104c8366004612d85565b6110c4565b6102b36104db366004612e4d565b611169565b6103a46104ee366004612e1b565b61127f565b6102ad610501366004612e4d565b6113be565b6102ad610514366004612c61565b61147f565b6011546102b3565b61052961150b565b60405190151581526020016102bd565b6102ad610547366004612d29565b6115f5565b6010546102b3565b6102b3610562366004612dcd565b6117c2565b6002546001600160a01b031633146105c65760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a41423a4e4f545f50454e44494e475f424f52524f57455200000000000060448201526064015b60405180910390fd5b600280546001600160a01b031990811690915560008054339216821781556040517f29bac0ac2b15405bfcc160bb74b6ae7a559b7674ce33db80785ada73e38204d29190a2565b600061061761196a565b905090565b6003546001600160a01b031633146106765760405162461bcd60e51b815260206004820152601860248201527f4d4c3a414c3a4e4f545f50454e44494e475f4c454e444552000000000000000060448201526064016105bd565b600380546001600160a01b031990811690915560018054339216821790556040517fd6165838d2e3db87aa1002b548048673fc6427eefbd1b914e100f3a0deae23e390600090a2565b6000546001600160a01b0316331461070f5760405162461bcd60e51b815260206004820152601360248201527226a61d29a8211d2727aa2fa127a92927aba2a960691b60448201526064016105bd565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f10f06072822ef73860fedb88933f968d20bb4aadce8a8d360d1124cb6ce1e0b2906020015b60405180910390a150565b6001546001600160a01b031633146107b25760405162461bcd60e51b815260206004820152601160248201527026a61d29a8261d2727aa2fa622a72222a960791b60448201526064016105bd565b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fa3ab02442c80a4102475683f16513c9139a89142be9db9804edfcfbb379fc49290602001610759565b61080861150b565b156108255760405162461bcd60e51b81526004016105bd90613001565b6000546001600160a01b031633146108755760405162461bcd60e51b815260206004820152601360248201527226a61d28272a1d2727aa2fa127a92927aba2a960691b60448201526064016105bd565b7f441b8aabc18c8ac7ede4e3fd48191f874ed7222d0b9feabbba65b9c0fdc4aa636108a1848484611999565b8484846040516108b49493929190612fcc565b60405180910390a1505050565b6108c961150b565b156108e65760405162461bcd60e51b81526004016105bd90613001565b6001546001600160a01b031633146109335760405162461bcd60e51b815260206004820152601060248201526f26a61d21a31d2727aa2fa622a72222a960811b60448201526064016105bd565b806001600160a01b03167f6bd56533ce1c8ea03f7b858ac441b5a86d140a793a7c9e3faecbbe517c2c87918360405161096e91815260200190565b60405180910390a261098082826119c1565b5050565b6000546001600160a01b031633146109d25760405162461bcd60e51b815260206004820152601160248201527026a61d2a9d2727aa2fa127a92927aba2a960791b60448201526064016105bd565b7faaaa7ee6b0c2f4ee1fa7312c7d5b3623a434da5a1a9ce3cb6e629caa23454ab6838383604051610a059392919061302d565b60405180910390a1610a1561196a565b6001600160a01b031663fe69f7088484846040518463ffffffff1660e01b8152600401610a449392919061302d565b600060405180830381600087803b158015610a5e57600080fd5b505af1158015610a72573d6000803e3d6000fd5b50505050505050565b6000610a8561150b565b15610aa25760405162461bcd60e51b81526004016105bd90613001565b811580610ac25750600554610ac2906001600160a01b0316333085611a34565b610b0e5760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a52463a5452414e534645525f46524f4d5f4641494c454400000000000060448201526064016105bd565b7f278e51d3323fbf18b9fb8df3f8b97e31b145bc1146c52e764cf4aa1bfc4ba17d610b37611aab565b60405181815290925060200160405180910390a1919050565b600080610b5b61150b565b15610b785760405162461bcd60e51b81526004016105bd90613001565b6001546001600160a01b03163314610bc45760405162461bcd60e51b815260206004820152600f60248201526e26a61d291d2727aa2fa622a72222a960891b60448201526064016105bd565b610bcd83611ae1565b60408051838152602081018390529294509092506001600160a01b038516917f027e623aab0b174da270ff529cad1c54f09182651e07437d2ac557929b9e5b49910160405180910390a2915091565b600080610c3e60145484600f54610c3391906130e7565b600d54600c54611c56565b601154909150808211610c52576000610c5c565b610c5c81836130e7565b949350505050565b6000610c6e61150b565b15610c8b5760405162461bcd60e51b81526004016105bd90613001565b811580610cab5750600454610cab906001600160a01b0316333085611a34565b610cf75760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a50433a5452414e534645525f46524f4d5f4641494c454400000000000060448201526064016105bd565b7f437d44b2c697fb69e2b2f25f57fd844e376c25ed28ed5a9c4be88aa1e5c87d12610b37611c8f565b600080821580610d435750600554610d43906001600160a01b0316333086611a34565b610d8f5760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a4d503a5452414e534645525f46524f4d5f4641494c454400000000000060448201526064016105bd565b6000546001600160a01b03163314610e1b57610da9611cbb565b9092509050610db8818361308e565b600554610dcd906001600160a01b0316611cdf565b1015610e1b5760405162461bcd60e51b815260206004820152601960248201527f4d4c3a4d503a43414e4e4f545f5553455f4452415741424c450000000000000060448201526064016105bd565b610e23611db9565b60408051838152602081018390529294509092507f0e9e4ec6fa83fe2a2893fd5d6517a890df20f72cc0ba40495b21e65d1222350391015b60405180910390a1915091565b6000610617611e84565b600080610e7d611eae565b90939092509050565b6000610e9061150b565b15610ead5760405162461bcd60e51b81526004016105bd90613001565b6000546001600160a01b0316331480610ed057506001546001600160a01b031633145b610f0a5760405162461bcd60e51b815260206004820152600b60248201526a09874a6749c9ebe82aaa8960ab1b60448201526064016105bd565b6005546001600160a01b03848116911614801590610f3657506004546001600160a01b03848116911614155b610f765760405162461bcd60e51b8152602060048201526011602482015270261d299d24a72b20a624a22faa27a5a2a760791b60448201526064016105bd565b6040516370a0823160e01b81523060048201526001600160a01b0380841691908516907ff1f6a55e7ad487ac8dd8e1d4517348d3b410a7a0bc405ef87b09078dc51b23b69082906370a082319060240160206040518083038186803b158015610fde57600080fd5b505afa158015610ff2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110169190612e34565b60405181815290945060200160405180910390a3611035838383611edc565b6110775760405162461bcd60e51b8152602060048201526013602482015272130e94ce9514905394d1915497d19052531151606a1b60448201526064016105bd565b92915050565b600080611094601454600f54600d54600c54611c56565b6011549091508181116110a85760006110b2565b6110b282826130e7565b9250505090565b600080610e7d611cbb565b6110cc61196a565b6001600160a01b0316336001600160a01b03161461111f5760405162461bcd60e51b815260206004820152601060248201526f4d4c3a4d3a4e4f545f464143544f525960801b60448201526064016105bd565b61112a838383611f0f565b6111645760405162461bcd60e51b815260206004820152600b60248201526a13530e934e91905253115160aa1b60448201526064016105bd565b505050565b600061117361150b565b156111905760405162461bcd60e51b81526004016105bd90613001565b6000546001600160a01b031633146111df5760405162461bcd60e51b815260206004820152601260248201527126a61d22231d2727aa2fa127a92927aba2a960711b60448201526064016105bd565b816001600160a01b03167f7578fe8c4d9f6fc38fdad20d219b0ce47d38bbf8a72bdb26867809f24119363d8460405161121a91815260200190565b60405180910390a2600061122d84610c1c565b9050801561126e5760045460009061124d906001600160a01b0316611cdf565b905061126a818311611260576000610c64565b6103da82846130e7565b9250505b6112788484611f88565b5092915050565b6000808215806112a257506005546112a2906001600160a01b0316333086611a34565b6112ee5760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a434c3a5452414e534645525f46524f4d5f4641494c454400000000000060448201526064016105bd565b6000546001600160a01b0316331461137a57611308611eae565b9092509050611317818361308e565b60055461132c906001600160a01b0316611cdf565b101561137a5760405162461bcd60e51b815260206004820152601960248201527f4d4c3a434c3a43414e4e4f545f5553455f4452415741424c450000000000000060448201526064016105bd565b61138261204f565b60408051838152602081018390529294509092507ffaf789d29e2eac56fdd8f04cd37414d6775115259a9cfed131d9cecf041681939101610e5b565b6113c661150b565b156113e35760405162461bcd60e51b81526004016105bd90613001565b6000546001600160a01b031633146114325760405162461bcd60e51b815260206004820152601260248201527126a61d29219d2727aa2fa127a92927aba2a960711b60448201526064016105bd565b806001600160a01b03167f97b446ee2df422b7273fe6d658674835f9de3319d131c229f9a2f8ed62a761938360405161146d91815260200190565b60405180910390a26109808282612112565b61148761196a565b6001600160a01b0316336001600160a01b0316146114db5760405162461bcd60e51b81526020600482015260116024820152704d4c3a53493a4e4f545f464143544f525960781b60448201526064016105bd565b6001600160a01b03167f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b50565b600061151561196a565b6001600160a01b0316633a60339a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561154d57600080fd5b505afa158015611561573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115859190612c7e565b6001600160a01b031663425fad586040518163ffffffff1660e01b815260040160206040518083038186803b1580156115bd57600080fd5b505afa1580156115d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106179190612df9565b6115fd61150b565b1561161a5760405162461bcd60e51b81526004016105bd90613001565b6001546001600160a01b03163381146116695760405162461bcd60e51b815260206004820152601160248201527026a61d20a72a1d2727aa2fa622a72222a960791b60448201526064016105bd565b6005546001600160a01b0316821580611689575061168981333086611a34565b6116d55760405162461bcd60e51b815260206004820152601b60248201527f4d4c3a4143543a5452414e534645525f46524f4d5f4641494c4544000000000060448201526064016105bd565b7f86aef1c188b271def2f7144000e562c7199de8c16279e38bebc13e09137639b86117018787876121d9565b8787876040516117149493929190612fcc565b60405180910390a1600061172782611cdf565b90508015610a7257826001600160a01b03167ff505854d1244de20a434e0eca67ec8de6d69504f7f85594c61102ab4d9a278f38260405161176a91815260200190565b60405180910390a261177d828483611edc565b610a725760405162461bcd60e51b815260206004820152601660248201527513530e9053950e9514905394d1915497d1905253115160521b60448201526064016105bd565b60006117cc61150b565b156117e95760405162461bcd60e51b81526004016105bd90613001565b6005546001600160a01b0316821580611809575061180981333086611a34565b6118555760405162461bcd60e51b815260206004820152601a60248201527f4d4c3a464c3a5452414e534645525f46524f4d5f4641494c454400000000000060448201526064016105bd565b6012546118af57836001600160a01b03167fcd909ec339185c4598a4096e174308fbdf136d117f230960f873a2f2e81f63af611890866123d0565b6012546040805183815260208101929092529195500160405180910390a25b60006118ba82611cdf565b6001549091506001600160a01b0316811561196157806001600160a01b03167ff505854d1244de20a434e0eca67ec8de6d69504f7f85594c61102ab4d9a278f38360405161190a91815260200190565b60405180910390a261191d838284611edc565b6119615760405162461bcd60e51b815260206004820152601560248201527413530e91930e9514905394d1915497d19052531151605a1b60448201526064016105bd565b50505092915050565b60006119947f7a45a402e4cb6e08ebc196f20f66d5d30e67285a2a8aa80503fa409e727a4af15490565b919050565b6000816119a75760006119b2565b6119b2848484612848565b601581905590505b9392505050565b81601060008282546119d391906130e7565b90915550506005546119ef906001600160a01b03168284611edc565b6109805760405162461bcd60e51b81526020600482015260166024820152751353124e90d18e9514905394d1915497d1905253115160521b60448201526064016105bd565b6040516001600160a01b0380851660248301528316604482015260648101829052600090611aa29086906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261287e565b95945050505050565b600554600090611ac3906001600160a01b0316611cdf565b905080600f6000828254611ad7919061308e565b9250508190555090565b60125460009081908015801590611b035750600654611b00908261308e565b42115b611b465760405162461bcd60e51b81526020600482015260146024820152731353124e948e9393d517d25397d111519055531560621b60448201526064016105bd565b611b4e61291e565b600060118190556010819055600f8190556004546001600160a01b031690611b7582611cdf565b9450841480611b8a5750611b8a818686611edc565b611bd65760405162461bcd60e51b815260206004820152601760248201527f4d4c493a523a435f5452414e534645525f4641494c454400000000000000000060448201526064016105bd565b6005546001600160a01b03166000611bed82611cdf565b9450841480611c025750611c02818786611edc565b611c4e5760405162461bcd60e51b815260206004820152601760248201527f4d4c493a523a465f5452414e534645525f4641494c454400000000000000000060448201526064016105bd565b505050915091565b600083851115611c845782611c6b85876130e7565b611c7590846130c8565b611c7f91906130a6565b611aa2565b506000949350505050565b600454600090611ca7906001600160a01b0316611cdf565b90508060116000828254611ad7919061308e565b600080610e7d42601254600754601454600e54601354600854600a54600b54612952565b6005546000906001600160a01b03838116911614611cfe576000611d0e565b600f54601054611d0e919061308e565b6004546001600160a01b03848116911614611d2a576000611d2e565b6011545b6040516370a0823160e01b81523060048201526001600160a01b038516906370a082319060240160206040518083038186803b158015611d6d57600080fd5b505afa158015611d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da59190612e34565b611daf91906130e7565b61107791906130e7565b600080611dc4611cbb565b90925090506000611dd5828461308e565b6005549091508190611def906001600160a01b0316611cdf565b600f54611dfc919061308e565b611e0691906130e7565b600f819055508060106000828254611e1e919061308e565b90915550506013546001811415611e3c57611e3761291e565b611e7e565b60075460126000828254611e50919061308e565b925050819055508360146000828254611e6991906130e7565b90915550611e7a90506001826130e7565b6013555b50509091565b60006119947f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b60095460145490600090670de0b6b3a764000090611ecc90846130c8565b611ed691906130a6565b90509091565b6040516001600160a01b038316602482015260448101829052600090610c5c90859063a9059cbb60e01b90606401611a6b565b6000833b80611f225760009150506119ba565b846001600160a01b03168484604051611f3c929190612f5c565b600060405180830381855af49150503d8060008114611f77576040519150601f19603f3d011682016040523d82523d6000602084013e611f7c565b606091505b50909695505050505050565b81600f6000828254611f9a91906130e7565b9091555050600554611fb6906001600160a01b03168284611edc565b611ffb5760405162461bcd60e51b81526020600482015260166024820152751353124e91118e9514905394d1915497d1905253115160521b60448201526064016105bd565b612003612a1a565b6109805760405162461bcd60e51b815260206004820152601e60248201527f4d4c493a44463a494e53554646494349454e545f434f4c4c41544552414c000060448201526064016105bd565b60008060125442111561209d5760405162461bcd60e51b81526020600482015260166024820152754d4c493a434c3a5041594d454e545f49535f4c41544560501b60448201526064016105bd565b6120a5611eae565b909250905060006120b6828461308e565b60055490915081906120d0906001600160a01b0316611cdf565b600f546120dd919061308e565b6120e791906130e7565b600f8190555080601060008282546120ff919061308e565b9091555061210d905061291e565b509091565b816011600082825461212491906130e7565b9091555050600454612140906001600160a01b03168284611edc565b6121855760405162461bcd60e51b81526020600482015260166024820152751353124e9490ce9514905394d1915497d1905253115160521b60448201526064016105bd565b61218d612a1a565b6109805760405162461bcd60e51b815260206004820152601e60248201527f4d4c493a52433a494e53554646494349454e545f434f4c4c41544552414c000060448201526064016105bd565b60006121e6848484612848565b905080601554146122395760405162461bcd60e51b815260206004820152601b60248201527f4d4c493a414e543a434f4d4d49544d454e545f4d49534d41544348000000000060448201526064016105bd565b6001600160a01b0384163b6122905760405162461bcd60e51b815260206004820152601a60248201527f4d4c493a414e543a494e56414c49445f524546494e414e43455200000000000060448201526064016105bd565b6000601581905582905b81811015612373576000866001600160a01b03168686848181106122c0576122c061312f565b90506020028101906122d29190613047565b6040516122e0929190612f5c565b600060405180830381855af49150503d806000811461231b576040519150601f19603f3d011682016040523d82523d6000602084013e612320565b606091505b50509050806123625760405162461bcd60e51b815260206004820152600e60248201526d1353124e9053950e91905253115160921b60448201526064016105bd565b5061236c816130fe565b905061229a565b5061237c612a1a565b6123c85760405162461bcd60e51b815260206004820152601f60248201527f4d4c493a414e543a494e53554646494349454e545f434f4c4c41544552414c0060448201526064016105bd565b509392505050565b601354601254600091901580156123e657508015155b6124275760405162461bcd60e51b81526020600482015260126024820152714d4c493a464c3a4c4f414e5f41435449564560701b60448201526064016105bd565b600754600180546001600160a01b0319166001600160a01b03861617905561244f814261308e565b601255600d5460148190556005549093506001600160a01b03168361247382611cdf565b10156124c15760405162461bcd60e51b815260206004820152601860248201527f4d4c493a464c3a57524f4e475f46554e445f414d4f554e54000000000000000060448201526064016105bd565b60006124cb61196a565b6001600160a01b0316633a60339a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561250357600080fd5b505afa158015612517573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253b9190612c7e565b9050600064496cebb8008585846001600160a01b031663cc32d1766040518163ffffffff1660e01b815260040160206040518083038186803b15801561258057600080fd5b505afa158015612594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b89190612e34565b6125c2908a6130c8565b6125cc91906130c8565b6125d691906130c8565b6125e091906130a6565b9050600064496cebb8008686856001600160a01b03166316a12d7a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561262557600080fd5b505afa158015612639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265d9190612e34565b612667908b6130c8565b61267191906130c8565b61267b91906130c8565b61268591906130a6565b90508061269283896130e7565b61269c91906130e7565b600f55811580612722575061272284846001600160a01b031663a5a276056040518163ffffffff1660e01b815260040160206040518083038186803b1580156126e457600080fd5b505afa1580156126f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271c9190612c7e565b84611edc565b61276e5760405162461bcd60e51b815260206004820152601860248201527f4d4c493a464c3a545f5452414e534645525f4641494c4544000000000000000060448201526064016105bd565b8015806127f157506127f184896001600160a01b0316634046af2b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156127b357600080fd5b505afa1580156127c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127eb9190612c7e565b83611edc565b61283d5760405162461bcd60e51b815260206004820152601960248201527f4d4c493a464c3a50445f5452414e534645525f4641494c45440000000000000060448201526064016105bd565b505050505050919050565b600083838360405160200161285f93929190612fa7565b6040516020818303038152906040528051906020012090509392505050565b60006001600160a01b0383163b61289757506000611077565b6060836001600160a01b0316836040516128b19190612f6c565b6000604051808303816000865af19150503d80600081146128ee576040519150601f19603f3d011682016040523d82523d6000602084013e6128f3565b606091505b509092509050818015610c5c575080511580610c5c575080806020019051810190610c5c9190612df9565b60006006819055600781905560088190556009819055600a819055600b819055600e81905560128190556013819055601455565b6000806129628888878c8a612a3a565b9092509050600186146129755781612977565b875b9150898b1115612a0c5760006201518060016129938d8f6130e7565b61299d91906130e7565b6129a791906130a6565b6129b290600161308e565b6129bf90620151806130c8565b90506129d5896129cf868961308e565b83612b2d565b6129df908361308e565b9150670de0b6b3a76400006129f48a876130c8565b6129fe91906130a6565b612a08908361308e565b9150505b995099975050505050505050565b6000612a30601454600f54600d54600c54611c56565b6011541015905090565b6000806000612a498686612b56565b90506000612a71612a6283670de0b6b3a764000061308e565b86670de0b6b3a7640000612b71565b9050670de0b6b3a76400008111612aa45784612a8d898b6130e7565b612a9791906130a6565b6000935093505050612b23565b6000612ab8670de0b6b3a7640000836130e7565b838a670de0b6b3a7640000612acd868f6130c8565b612ad791906130a6565b612ae191906130e7565b612aeb91906130c8565b612af591906130a6565b9050612b028a8989612b2d565b935083811015612b13576000612b1d565b612b1d84826130e7565b94505050505b9550959350505050565b6000670de0b6b3a7640000612b428484612b56565b612b4c90866130c8565b610c5c91906130a6565b60006301e13380612b6783856130c8565b6119ba91906130a6565b600060018316612b815781612b83565b835b90505b60019290921c9182156119ba5781612b9e85806130c8565b612ba891906130a6565b935060018316612bb757612b86565b81612bc285836130c8565b612bcc91906130a6565b9050612b86565b60008083601f840112612be557600080fd5b50813567ffffffffffffffff811115612bfd57600080fd5b6020830191508360208260051b8501011115612c1857600080fd5b9250929050565b60008083601f840112612c3157600080fd5b50813567ffffffffffffffff811115612c4957600080fd5b602083019150836020828501011115612c1857600080fd5b600060208284031215612c7357600080fd5b81356119ba81613145565b600060208284031215612c9057600080fd5b81516119ba81613145565b60008060408385031215612cae57600080fd5b8235612cb981613145565b91506020830135612cc981613145565b809150509250929050565b600080600060408486031215612ce957600080fd5b8335612cf481613145565b9250602084013567ffffffffffffffff811115612d1057600080fd5b612d1c86828701612bd3565b9497909650939450505050565b60008060008060608587031215612d3f57600080fd5b8435612d4a81613145565b9350602085013567ffffffffffffffff811115612d6657600080fd5b612d7287828801612bd3565b9598909750949560400135949350505050565b600080600060408486031215612d9a57600080fd5b8335612da581613145565b9250602084013567ffffffffffffffff811115612dc157600080fd5b612d1c86828701612c1f565b60008060408385031215612de057600080fd5b8235612deb81613145565b946020939093013593505050565b600060208284031215612e0b57600080fd5b815180151581146119ba57600080fd5b600060208284031215612e2d57600080fd5b5035919050565b600060208284031215612e4657600080fd5b5051919050565b60008060408385031215612e6057600080fd5b823591506020830135612cc981613145565b600080600060408486031215612e8757600080fd5b83359250602084013567ffffffffffffffff811115612dc157600080fd5b818352600060208085019450848460051b86018460005b87811015612f265783830389528135601e19883603018112612edd57600080fd5b8701803567ffffffffffffffff811115612ef657600080fd5b803603891315612f0557600080fd5b612f128582898501612f33565b9a87019a9450505090840190600101612ebc565b5090979650505050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8183823760009101908152919050565b6000825160005b81811015612f8d5760208186018101518583015201612f73565b81811115612f9c576000828501525b509190910192915050565b6001600160a01b0384168152604060208201819052600090611aa29083018486612ea5565b8481526001600160a01b0384166020820152606060408201819052600090612ff79083018486612ea5565b9695505050505050565b60208082526012908201527113530e941493d513d0d3d317d4105554d15160721b604082015260600190565b838152604060208201526000611aa2604083018486612f33565b6000808335601e1984360301811261305e57600080fd5b83018035915067ffffffffffffffff82111561307957600080fd5b602001915036819003821315612c1857600080fd5b600082198211156130a1576130a1613119565b500190565b6000826130c357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156130e2576130e2613119565b500290565b6000828210156130f9576130f9613119565b500390565b600060001982141561311257613112613119565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461150857600080fdfea164736f6c6343000807000a
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 12740, 2278, 2581, 21996, 2683, 2683, 2683, 2683, 2620, 2850, 2549, 2278, 26976, 2683, 19317, 17465, 2487, 3401, 24096, 2475, 2063, 2581, 2581, 26187, 23499, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1022, 1012, 1021, 1025, 8278, 29464, 11890, 11387, 10359, 1063, 3853, 14300, 1006, 4769, 5247, 2121, 1035, 1010, 21318, 3372, 17788, 2575, 3815, 1035, 1007, 6327, 5651, 1006, 22017, 2140, 3112, 1035, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1035, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 5703, 1035, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1035, 1010, 21318, 3372, 17788, 2575, 3815, 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,905
0x9795631f5d2083c020856f98f12db35b834a1677
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Stories after Dark /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████▌ ▓██████` ╙██████████████ █████████████▌ ▀█████▌ ████████ // // ████████▌ █████ ████ ,███████████▀█ █████████████ ██████▌ ████████ // // ████████▌ ████▌ █████████████████▌██ ████████████ , ██████ ████████ // // ████████▌ █████▄ █████████████┌███ ▀██████████▌ ██ █████ j████████ // // ████████▌ ████████▄ ██████████▌▀█▀▀ ██████████⌐ ██ ████▌ ████████ // // ████████▌ ███████████ █████████╒█████▌ █████████▌ ┌████⌐ ████████ // // ████████Γ ╒█████ "████▀ ███▀▀███ ███████ ███▀▀███▌ ╓█████ ████████ // // ████████ '▀▀███, ▄████ ,███████████ ╟██ ,███ ,┌▓███████ ████████ // // ████████▄,,,,╓█████████████████████████████████████████████████████,,,,▄████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ██████████████████████████████████████▀▀╩╩▓▓████████████████████████████████████ // // ███████████████████████████████████▓▒▒ ,╠╫████████████████████████████████████ // // ███████████████████████████████████████▓████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ███████████████████████████████████████▓▓▓██████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////// contract SAD is ERC721Creator { constructor() ERC721Creator("Stories after Dark", "SAD") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203bf635cc98f96e7c4dd637fab31c4131c65772f0f87c735717bd9cfcb0e37fcd64736f6c63430008070033
{"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, 2581, 2683, 26976, 21486, 2546, 2629, 2094, 11387, 2620, 2509, 2278, 2692, 11387, 27531, 2575, 2546, 2683, 2620, 2546, 12521, 18939, 19481, 2497, 2620, 22022, 27717, 2575, 2581, 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, 1013, 1013, 1013, 1030, 2516, 1024, 3441, 2044, 2601, 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, 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,906
0x9795676af4d2f7fb9FE181efC8E1e51b8D8C00AB
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.6; import "./ownable.sol"; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { 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); } } } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract Leafty 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 = 100000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Leafty'; string private _symbol = 'LEAFTY'; uint8 private _decimals = 9; // Tax and charity fees will start at 0 so we don't have a big impact when deploying to Uniswap // Charity wallet address is null but the method to set the address is exposed uint256 private _taxFee = 1; uint256 private _charityFee = 7; uint256 private _previousTaxFee = _taxFee; uint256 private _previousCharityFee = _charityFee; address payable public _charityWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 10000000000000 * 10**9; // We will set a minimum amount of tokens to be swaped => 500k uint256 private _numOfTokensToExchangeForCharity = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable charityWalletAddress) { _charityWalletAddress = charityWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; // Exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function charityMin() public view returns (uint256) { return _numOfTokensToExchangeForCharity; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _charityFee == 0) return; _previousTaxFee = _taxFee; _previousCharityFee = _charityFee; _taxFee = 0; _charityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _charityFee = _previousCharityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap? // also, don't get caught in a circular charity event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForCharity; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the charity wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToCharity(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and charity fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToCharity(uint256 amount) private { _charityWalletAddress.transfer(amount); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 500k becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToCharity(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner() { swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _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 tCharity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _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 tCharity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeCharity(tCharity); _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 tCharity) = _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); _takeCharity(tCharity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeCharity(uint256 tCharity) private { uint256 currentRate = _getRate(); uint256 rCharity = tCharity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rCharity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tCharity); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getTValues(tAmount, _taxFee, _charityFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCharity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 charityFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tCharity = tAmount.mul(charityFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tCharity); return (tTransferAmount, tFee, tCharity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10'); _taxFee = taxFee; } function _setCharityFee(uint256 charityFee) external onlyOwner() { require(charityFee >= 1 && charityFee <= 99, 'charityFee should be in 1 - 99'); _charityFee = charityFee; } function _setCharityMin(uint256 scharityMin) external onlyOwner() { _numOfTokensToExchangeForCharity = scharityMin; } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount >= 10000000000000e9 , 'maxTxAmount should be greater than 10000000000000e9'); _maxTxAmount = maxTxAmount; } }
0x60806040526004361061021e5760003560e01c806370a0823111610123578063cba0e996116100ab578063f2cc0c181161006f578063f2cc0c1814610818578063f2fde38b14610841578063f42938901461086a578063f815a84214610881578063f84354f1146108ac57610225565b8063cba0e99614610721578063ccd8a6991461075e578063d047e4b714610789578063dd62ed3e146107b2578063e01af92c146107ef57610225565b806395d89b41116100f257806395d89b411461062a578063a24a8d0f14610655578063a457c2d71461067e578063a9059cbb146106bb578063af9549e0146106f857610225565b806370a0823114610580578063715018a6146105bd57806376d4ab99146105d45780638da5cb5b146105ff57610225565b8063313ce567116101a657806349bd5a5e1161017557806349bd5a5e146104ad57806351bc3c85146104d85780635342acb4146104ef5780635880b8731461052c5780636ddd17131461055557610225565b8063313ce567146103df578063395093511461040a5780633bd5d173146104475780634549b0391461047057610225565b806318160ddd116101ed57806318160ddd146102e85780631bbae6e01461031357806323b872dd1461033c5780632d838119146103795780632df669e8146103b657610225565b806306fdde031461022a578063095ea7b31461025557806313114a9d146102925780631694505e146102bd57610225565b3661022557005b600080fd5b34801561023657600080fd5b5061023f6108d5565b60405161024c919061450d565b60405180910390f35b34801561026157600080fd5b5061027c6004803603810190610277919061402a565b610967565b60405161028991906144d7565b60405180910390f35b34801561029e57600080fd5b506102a7610985565b6040516102b4919061476f565b60405180910390f35b3480156102c957600080fd5b506102d261098f565b6040516102df91906144f2565b60405180910390f35b3480156102f457600080fd5b506102fd6109b3565b60405161030a919061476f565b60405180910390f35b34801561031f57600080fd5b5061033a60048036038101906103359190614097565b6109bd565b005b34801561034857600080fd5b50610363600480360381019061035e9190613f97565b610a90565b60405161037091906144d7565b60405180910390f35b34801561038557600080fd5b506103a0600480360381019061039b9190614097565b610b69565b6040516103ad919061476f565b60405180910390f35b3480156103c257600080fd5b506103dd60048036038101906103d89190614097565b610bd7565b005b3480156103eb57600080fd5b506103f4610c5d565b60405161040191906147e4565b60405180910390f35b34801561041657600080fd5b50610431600480360381019061042c919061402a565b610c74565b60405161043e91906144d7565b60405180910390f35b34801561045357600080fd5b5061046e60048036038101906104699190614097565b610d27565b005b34801561047c57600080fd5b50610497600480360381019061049291906140c4565b610ea2565b6040516104a4919061476f565b60405180910390f35b3480156104b957600080fd5b506104c2610f26565b6040516104cf91906144a1565b60405180910390f35b3480156104e457600080fd5b506104ed610f4a565b005b3480156104fb57600080fd5b5061051660048036038101906105119190613ed0565b610fdf565b60405161052391906144d7565b60405180910390f35b34801561053857600080fd5b50610553600480360381019061054e9190614097565b611035565b005b34801561056157600080fd5b5061056a61110c565b60405161057791906144d7565b60405180910390f35b34801561058c57600080fd5b506105a760048036038101906105a29190613ed0565b61111f565b6040516105b4919061476f565b60405180910390f35b3480156105c957600080fd5b506105d261120a565b005b3480156105e057600080fd5b506105e9611292565b6040516105f691906144bc565b60405180910390f35b34801561060b57600080fd5b506106146112b8565b60405161062191906144a1565b60405180910390f35b34801561063657600080fd5b5061063f6112e1565b60405161064c919061450d565b60405180910390f35b34801561066157600080fd5b5061067c60048036038101906106779190614097565b611373565b005b34801561068a57600080fd5b506106a560048036038101906106a0919061402a565b61144a565b6040516106b291906144d7565b60405180910390f35b3480156106c757600080fd5b506106e260048036038101906106dd919061402a565b611517565b6040516106ef91906144d7565b60405180910390f35b34801561070457600080fd5b5061071f600480360381019061071a9190613fea565b611535565b005b34801561072d57600080fd5b5061074860048036038101906107439190613ed0565b61160c565b60405161075591906144d7565b60405180910390f35b34801561076a57600080fd5b50610773611662565b604051610780919061476f565b60405180910390f35b34801561079557600080fd5b506107b060048036038101906107ab9190613f2a565b61166c565b005b3480156107be57600080fd5b506107d960048036038101906107d49190613f57565b61172c565b6040516107e6919061476f565b60405180910390f35b3480156107fb57600080fd5b506108166004803603810190610811919061406a565b6117b3565b005b34801561082457600080fd5b5061083f600480360381019061083a9190613ed0565b61184c565b005b34801561084d57600080fd5b5061086860048036038101906108639190613ed0565b611b6a565b005b34801561087657600080fd5b5061087f611c62565b005b34801561088d57600080fd5b50610896611cef565b6040516108a3919061476f565b60405180910390f35b3480156108b857600080fd5b506108d360048036038101906108ce9190613ed0565b611cf7565b005b6060600a80546108e490614a39565b80601f016020809104026020016040519081016040528092919081815260200182805461091090614a39565b801561095d5780601f106109325761010080835404028352916020019161095d565b820191906000526020600020905b81548152906001019060200180831161094057829003601f168201915b5050505050905090565b600061097b61097461202d565b8484612035565b6001905092915050565b6000600954905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600754905090565b6109c561202d565b73ffffffffffffffffffffffffffffffffffffffff166109e36112b8565b73ffffffffffffffffffffffffffffffffffffffff1614610a39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a309061468f565b60405180910390fd5b69021e19e0c9bab2400000811015610a86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7d906145cf565b60405180910390fd5b8060128190555050565b6000610a9d848484612200565b610b5e84610aa961202d565b610b59856040518060600160405280602881526020016150eb60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b0f61202d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546125819092919063ffffffff16565b612035565b600190509392505050565b6000600854821115610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba79061454f565b60405180910390fd5b6000610bba6125e5565b9050610bcf818461261090919063ffffffff16565b915050919050565b610bdf61202d565b73ffffffffffffffffffffffffffffffffffffffff16610bfd6112b8565b73ffffffffffffffffffffffffffffffffffffffff1614610c53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4a9061468f565b60405180910390fd5b8060138190555050565b6000600c60009054906101000a900460ff16905090565b6000610d1d610c8161202d565b84610d188560036000610c9261202d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b612035565b6001905092915050565b6000610d3161202d565b9050600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610dc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db79061474f565b60405180910390fd5b6000610dcb836126b8565b50505050509050610e2481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c8160085461271f90919063ffffffff16565b600881905550610e978360095461265a90919063ffffffff16565b600981905550505050565b6000600754831115610ee9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee09061460f565b60405180910390fd5b81610f09576000610ef9846126b8565b5050505050905080915050610f20565b6000610f14846126b8565b50505050915050809150505b92915050565b7f0000000000000000000000008c8f6735c64c14a5dc88d55b7d7c1b594ba1c32181565b610f5261202d565b73ffffffffffffffffffffffffffffffffffffffff16610f706112b8565b73ffffffffffffffffffffffffffffffffffffffff1614610fc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbd9061468f565b60405180910390fd5b6000610fd13061111f565b9050610fdc81612769565b50565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b61103d61202d565b73ffffffffffffffffffffffffffffffffffffffff1661105b6112b8565b73ffffffffffffffffffffffffffffffffffffffff16146110b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a89061468f565b60405180910390fd5b600181101580156110c35750600a8111155b611102576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f99061464f565b60405180910390fd5b80600d8190555050565b601160159054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156111ba57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611205565b611202600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b69565b90505b919050565b61121261202d565b73ffffffffffffffffffffffffffffffffffffffff166112306112b8565b73ffffffffffffffffffffffffffffffffffffffff1614611286576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127d9061468f565b60405180910390fd5b61129060006129eb565b565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600b80546112f090614a39565b80601f016020809104026020016040519081016040528092919081815260200182805461131c90614a39565b80156113695780601f1061133e57610100808354040283529160200191611369565b820191906000526020600020905b81548152906001019060200180831161134c57829003601f168201915b5050505050905090565b61137b61202d565b73ffffffffffffffffffffffffffffffffffffffff166113996112b8565b73ffffffffffffffffffffffffffffffffffffffff16146113ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e69061468f565b60405180910390fd5b60018110158015611401575060638111155b611440576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611437906146cf565b60405180910390fd5b80600e8190555050565b600061150d61145761202d565b8461150885604051806060016040528060258152602001615113602591396003600061148161202d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546125819092919063ffffffff16565b612035565b6001905092915050565b600061152b61152461202d565b8484612200565b6001905092915050565b61153d61202d565b73ffffffffffffffffffffffffffffffffffffffff1661155b6112b8565b73ffffffffffffffffffffffffffffffffffffffff16146115b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a89061468f565b60405180910390fd5b80600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000601354905090565b61167461202d565b73ffffffffffffffffffffffffffffffffffffffff166116926112b8565b73ffffffffffffffffffffffffffffffffffffffff16146116e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116df9061468f565b60405180910390fd5b80601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6117bb61202d565b73ffffffffffffffffffffffffffffffffffffffff166117d96112b8565b73ffffffffffffffffffffffffffffffffffffffff161461182f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118269061468f565b60405180910390fd5b80601160156101000a81548160ff02191690831515021790555050565b61185461202d565b73ffffffffffffffffffffffffffffffffffffffff166118726112b8565b73ffffffffffffffffffffffffffffffffffffffff16146118c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118bf9061468f565b60405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561194b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119429061472f565b60405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156119d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119cf906145ef565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611aac57611a68600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b69565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506006819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611b7261202d565b73ffffffffffffffffffffffffffffffffffffffff16611b906112b8565b73ffffffffffffffffffffffffffffffffffffffff1614611be6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bdd9061468f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4d9061456f565b60405180910390fd5b611c5f816129eb565b50565b611c6a61202d565b73ffffffffffffffffffffffffffffffffffffffff16611c886112b8565b73ffffffffffffffffffffffffffffffffffffffff1614611cde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd59061468f565b60405180910390fd5b6000479050611cec81612aaf565b50565b600047905090565b611cff61202d565b73ffffffffffffffffffffffffffffffffffffffff16611d1d6112b8565b73ffffffffffffffffffffffffffffffffffffffff1614611d73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6a9061468f565b60405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611dff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611df6906145ef565b60405180910390fd5b60005b600680549050811015612029578173ffffffffffffffffffffffffffffffffffffffff1660068281548110611e3a57611e39614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156120165760066001600680549050611e959190614935565b81548110611ea657611ea5614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660068281548110611ee557611ee4614b70565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506006805480611fdc57611fdb614b41565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055612029565b808061202190614a6b565b915050611e02565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156120a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209c9061470f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210c9061458f565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516121f3919061476f565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612270576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612267906146ef565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156122e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d79061452f565b60405180910390fd5b60008111612323576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231a906146af565b60405180910390fd5b61232b6112b8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561239957506123696112b8565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156123e4576012548111156123e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123da9061462f565b60405180910390fd5b5b60006123ef3061111f565b905060125481106124005760125490505b60006013548210159050601160149054906101000a900460ff161580156124335750601160159054906101000a900460ff165b801561243c5750805b801561249457507f0000000000000000000000008c8f6735c64c14a5dc88d55b7d7c1b594ba1c32173ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b156124bc576124a282612769565b600047905060008111156124ba576124b947612aaf565b5b505b600060019050600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806125635750600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561256d57600090505b61257986868684612b1b565b505050505050565b60008383111582906125c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125c0919061450d565b60405180910390fd5b50600083856125d89190614935565b9050809150509392505050565b60008060006125f2612e2c565b91509150612609818361261090919063ffffffff16565b9250505090565b600061265283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506130df565b905092915050565b60008082846126699190614854565b9050838110156126ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126a5906145af565b60405180910390fd5b8091505092915050565b60008060008060008060008060006126d58a600d54600e54613142565b92509250925060006126e56125e5565b905060008060006126f78e87866131d8565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061276183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612581565b905092915050565b6001601160146101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156127a1576127a0614b9f565b5b6040519080825280602002602001820160405280156127cf5781602001602082028036833780820191505090505b50905030816000815181106127e7576127e6614b70565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561288757600080fd5b505afa15801561289b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bf9190613efd565b816001815181106128d3576128d2614b70565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050612938307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612035565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161299a95949392919061478a565b600060405180830381600087803b1580156129b457600080fd5b505af11580156129c8573d6000803e3d6000fd5b50505050506000601160146101000a81548160ff02191690831515021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015612b17573d6000803e3d6000fd5b5050565b80612b2957612b28613236565b5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612bcc5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612be157612bdc848484613279565b612e18565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612c845750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612c9957612c948484846134d9565b612e17565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612d3d5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612d5257612d4d848484613739565b612e16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612df45750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612e0957612e04848484613904565b612e15565b612e14848484613739565b5b5b5b5b80612e2657612e25613bf9565b5b50505050565b600080600060085490506000600754905060005b6006805490508110156130a257826001600060068481548110612e6657612e65614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612f545750816002600060068481548110612eec57612eeb614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612f6b57600854600754945094505050506130db565b612ffb6001600060068481548110612f8657612f85614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461271f90919063ffffffff16565b925061308d600260006006848154811061301857613017614b70565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361271f90919063ffffffff16565b9150808061309a90614a6b565b915050612e40565b506130ba60075460085461261090919063ffffffff16565b8210156130d2576008546007549350935050506130db565b81819350935050505b9091565b60008083118290613126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161311d919061450d565b60405180910390fd5b506000838561313591906148aa565b9050809150509392505050565b60008060008061316e6064613160888a613c0d90919063ffffffff16565b61261090919063ffffffff16565b90506000613198606461318a888b613c0d90919063ffffffff16565b61261090919063ffffffff16565b905060006131c1826131b3858c61271f90919063ffffffff16565b61271f90919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806131f18588613c0d90919063ffffffff16565b905060006132088688613c0d90919063ffffffff16565b9050600061321f828461271f90919063ffffffff16565b905082818395509550955050505093509350939050565b6000600d5414801561324a57506000600e54145b1561325457613277565b600d54600f81905550600e546010819055506000600d819055506000600e819055505b565b60008060008060008061328b876126b8565b9550955095509550955095506132e987600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061337e86600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061341385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061345f81613c88565b6134698483613e2d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516134c6919061476f565b60405180910390a3505050505050505050565b6000806000806000806134eb876126b8565b95509550955095509550955061354986600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506135de83600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061367385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506136bf81613c88565b6136c98483613e2d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051613726919061476f565b60405180910390a3505050505050505050565b60008060008060008061374b876126b8565b9550955095509550955095506137a986600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061383e85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061388a81613c88565b6138948483613e2d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516138f1919061476f565b60405180910390a3505050505050505050565b600080600080600080613916876126b8565b95509550955095509550955061397487600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613a0986600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271f90919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613a9e83600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b3385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b7f81613c88565b613b898483613e2d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051613be6919061476f565b60405180910390a3505050505050505050565b600f54600d81905550601054600e81905550565b600080831415613c205760009050613c82565b60008284613c2e91906148db565b9050828482613c3d91906148aa565b14613c7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c749061466f565b60405180910390fd5b809150505b92915050565b6000613c926125e5565b90506000613ca98284613c0d90919063ffffffff16565b9050613cfd81600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615613e2857613de483600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265a90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b613e428260085461271f90919063ffffffff16565b600881905550613e5d8160095461265a90919063ffffffff16565b6009819055505050565b600081359050613e768161508e565b92915050565b600081519050613e8b8161508e565b92915050565b600081359050613ea0816150a5565b92915050565b600081359050613eb5816150bc565b92915050565b600081359050613eca816150d3565b92915050565b600060208284031215613ee657613ee5614bce565b5b6000613ef484828501613e67565b91505092915050565b600060208284031215613f1357613f12614bce565b5b6000613f2184828501613e7c565b91505092915050565b600060208284031215613f4057613f3f614bce565b5b6000613f4e84828501613e91565b91505092915050565b60008060408385031215613f6e57613f6d614bce565b5b6000613f7c85828601613e67565b9250506020613f8d85828601613e67565b9150509250929050565b600080600060608486031215613fb057613faf614bce565b5b6000613fbe86828701613e67565b9350506020613fcf86828701613e67565b9250506040613fe086828701613ebb565b9150509250925092565b6000806040838503121561400157614000614bce565b5b600061400f85828601613e67565b925050602061402085828601613ea6565b9150509250929050565b6000806040838503121561404157614040614bce565b5b600061404f85828601613e67565b925050602061406085828601613ebb565b9150509250929050565b6000602082840312156140805761407f614bce565b5b600061408e84828501613ea6565b91505092915050565b6000602082840312156140ad576140ac614bce565b5b60006140bb84828501613ebb565b91505092915050565b600080604083850312156140db576140da614bce565b5b60006140e985828601613ebb565b92505060206140fa85828601613ea6565b9150509250929050565b6000614110838361412b565b60208301905092915050565b6141258161497b565b82525050565b61413481614969565b82525050565b61414381614969565b82525050565b60006141548261480f565b61415e8185614832565b9350614169836147ff565b8060005b8381101561419a5781516141818882614104565b975061418c83614825565b92505060018101905061416d565b5085935050505092915050565b6141b08161498d565b82525050565b6141bf816149d0565b82525050565b6141ce816149f4565b82525050565b60006141df8261481a565b6141e98185614843565b93506141f9818560208601614a06565b61420281614bd3565b840191505092915050565b600061421a602383614843565b915061422582614be4565b604082019050919050565b600061423d602a83614843565b915061424882614c33565b604082019050919050565b6000614260602683614843565b915061426b82614c82565b604082019050919050565b6000614283602283614843565b915061428e82614cd1565b604082019050919050565b60006142a6601b83614843565b91506142b182614d20565b602082019050919050565b60006142c9603383614843565b91506142d482614d49565b604082019050919050565b60006142ec601b83614843565b91506142f782614d98565b602082019050919050565b600061430f601f83614843565b915061431a82614dc1565b602082019050919050565b6000614332602883614843565b915061433d82614dea565b604082019050919050565b6000614355601a83614843565b915061436082614e39565b602082019050919050565b6000614378602183614843565b915061438382614e62565b604082019050919050565b600061439b602083614843565b91506143a682614eb1565b602082019050919050565b60006143be602983614843565b91506143c982614eda565b604082019050919050565b60006143e1601e83614843565b91506143ec82614f29565b602082019050919050565b6000614404602583614843565b915061440f82614f52565b604082019050919050565b6000614427602483614843565b915061443282614fa1565b604082019050919050565b600061444a602283614843565b915061445582614ff0565b604082019050919050565b600061446d602c83614843565b91506144788261503f565b604082019050919050565b61448c816149b9565b82525050565b61449b816149c3565b82525050565b60006020820190506144b6600083018461413a565b92915050565b60006020820190506144d1600083018461411c565b92915050565b60006020820190506144ec60008301846141a7565b92915050565b600060208201905061450760008301846141b6565b92915050565b6000602082019050818103600083015261452781846141d4565b905092915050565b600060208201905081810360008301526145488161420d565b9050919050565b6000602082019050818103600083015261456881614230565b9050919050565b6000602082019050818103600083015261458881614253565b9050919050565b600060208201905081810360008301526145a881614276565b9050919050565b600060208201905081810360008301526145c881614299565b9050919050565b600060208201905081810360008301526145e8816142bc565b9050919050565b60006020820190508181036000830152614608816142df565b9050919050565b6000602082019050818103600083015261462881614302565b9050919050565b6000602082019050818103600083015261464881614325565b9050919050565b6000602082019050818103600083015261466881614348565b9050919050565b600060208201905081810360008301526146888161436b565b9050919050565b600060208201905081810360008301526146a88161438e565b9050919050565b600060208201905081810360008301526146c8816143b1565b9050919050565b600060208201905081810360008301526146e8816143d4565b9050919050565b60006020820190508181036000830152614708816143f7565b9050919050565b600060208201905081810360008301526147288161441a565b9050919050565b600060208201905081810360008301526147488161443d565b9050919050565b6000602082019050818103600083015261476881614460565b9050919050565b60006020820190506147846000830184614483565b92915050565b600060a08201905061479f6000830188614483565b6147ac60208301876141c5565b81810360408301526147be8186614149565b90506147cd606083018561413a565b6147da6080830184614483565b9695505050505050565b60006020820190506147f96000830184614492565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061485f826149b9565b915061486a836149b9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561489f5761489e614ab4565b5b828201905092915050565b60006148b5826149b9565b91506148c0836149b9565b9250826148d0576148cf614ae3565b5b828204905092915050565b60006148e6826149b9565b91506148f1836149b9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561492a57614929614ab4565b5b828202905092915050565b6000614940826149b9565b915061494b836149b9565b92508282101561495e5761495d614ab4565b5b828203905092915050565b600061497482614999565b9050919050565b600061498682614999565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006149db826149e2565b9050919050565b60006149ed82614999565b9050919050565b60006149ff826149b9565b9050919050565b60005b83811015614a24578082015181840152602081019050614a09565b83811115614a33576000848401525b50505050565b60006002820490506001821680614a5157607f821691505b60208210811415614a6557614a64614b12565b5b50919050565b6000614a76826149b9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614aa957614aa8614ab4565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f6d61785478416d6f756e742073686f756c64206265206772656174657220746860008201527f616e203130303030303030303030303030653900000000000000000000000000602082015250565b7f4163636f756e7420697320616c7265616479206578636c756465640000000000600082015250565b7f416d6f756e74206d757374206265206c657373207468616e20737570706c7900600082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f7461784665652073686f756c6420626520696e2031202d203130000000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f636861726974794665652073686f756c6420626520696e2031202d2039390000600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f57652063616e206e6f74206578636c75646520556e697377617020726f75746560008201527f722e000000000000000000000000000000000000000000000000000000000000602082015250565b7f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460008201527f6869732066756e6374696f6e0000000000000000000000000000000000000000602082015250565b61509781614969565b81146150a257600080fd5b50565b6150ae8161497b565b81146150b957600080fd5b50565b6150c58161498d565b81146150d057600080fd5b50565b6150dc816149b9565b81146150e757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122039d977cccf01c373688d656fb00b433ec87818d1695994dda5b4023e26833a0164736f6c63430008060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 26976, 2581, 2575, 10354, 2549, 2094, 2475, 2546, 2581, 26337, 2683, 7959, 15136, 2487, 12879, 2278, 2620, 2063, 2487, 2063, 22203, 2497, 2620, 2094, 2620, 2278, 8889, 7875, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1020, 1025, 12324, 1000, 1012, 1013, 2219, 3085, 1012, 14017, 1000, 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, 3079, 2011, 1036, 4070, 1036, 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,907
0x97958fe320fa98d0cb8cda0efb647212b15ace2e
pragma solidity ^0.4.20; contract quiz_quest { function Try(string _response) external payable { require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value > 3 ether) { msg.sender.transfer(this.balance); } } string public question; address questionSender; bytes32 responseHash; function set_game(string _question,string _response) public payable { if(responseHash==0x0) { responseHash = keccak256(_response); question = _question; questionSender = msg.sender; } } function StopGame() public payable { require(msg.sender==questionSender); msg.sender.transfer(this.balance); } function NewQuestion(string _question, bytes32 _responseHash) public payable { if(msg.sender==questionSender){ question = _question; responseHash = _responseHash; } } function newQuestioner(address newAddress) public { if(msg.sender==questionSender)questionSender = newAddress; } function() public payable{} }
0x6060604052600436106100775763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633853682c81146100795780633e3ee8591461008c5780633fad9ae0146100d457806359988dce1461015e578063f50ab2471461017d578063fd26c46014610185575b005b610077600480356024810191013561020d565b61007760046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965050933593506102a892505050565b34156100df57600080fd5b6100e76102d9565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561012357808201518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016957600080fd5b610077600160a060020a0360043516610377565b6100776103ba565b61007760046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052818152929190602084018383808284375094965061041495505050505050565b32600160a060020a031633600160a060020a031614151561022d57600080fd5b81816040518083838082843782019150509250505060405190819003902060025414801561026257506729a2241af62c000034115b156102a45733600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f1935050505015156102a457600080fd5b5050565b60015433600160a060020a03908116911614156102a45760008280516102d29291602001906104bd565b5060025550565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561036f5780601f106103445761010080835404028352916020019161036f565b820191906000526020600020905b81548152906001019060200180831161035257829003601f168201915b505050505081565b60015433600160a060020a03908116911614156103b7576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b60015433600160a060020a039081169116146103d557600080fd5b33600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f19350505050151561041257600080fd5b565b60025415156102a457806040518082805190602001908083835b6020831061044d5780518252601f19909201916020918201910161042e565b6001836020036101000a038019825116818451161790925250505091909101925060409150505190819003902060025560008280516104909291602001906104bd565b50506001805473ffffffffffffffffffffffffffffffffffffffff191633600160a060020a031617905550565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104fe57805160ff191683800117855561052b565b8280016001018555821561052b579182015b8281111561052b578251825591602001919060010190610510565b5061053792915061053b565b5090565b61055591905b808211156105375760008155600101610541565b905600a165627a7a723058203f8e2c428e94539d1edbcefb0365563cd1525f0fac7b504c167de8dfc220c4ff0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 27814, 7959, 16703, 2692, 7011, 2683, 2620, 2094, 2692, 27421, 2620, 19797, 2050, 2692, 12879, 2497, 21084, 2581, 17465, 2475, 2497, 16068, 10732, 2475, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2322, 1025, 3206, 19461, 1035, 8795, 1063, 3853, 3046, 1006, 5164, 1035, 3433, 1007, 6327, 3477, 3085, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 19067, 1012, 4761, 1007, 1025, 2065, 1006, 3433, 14949, 2232, 1027, 1027, 17710, 16665, 2243, 17788, 2575, 1006, 1035, 3433, 1007, 1004, 1004, 5796, 2290, 1012, 3643, 1028, 1017, 28855, 1007, 1063, 5796, 2290, 1012, 4604, 2121, 1012, 4651, 1006, 2023, 1012, 5703, 1007, 1025, 1065, 1065, 5164, 2270, 3160, 1025, 4769, 3980, 10497, 2121, 1025, 27507, 16703, 3433, 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,908
0x9795c571F5A6E7CceDa3CBb86633eacc1B2e2000
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract Fattie is ERC721, Ownable { uint256 public totalSupply; mapping (uint256 => string) private _tokenURIs; event MintFattie(address to, uint256 totalSupply); constructor( string memory _name, string memory _symbol ) ERC721(_name, _symbol) {} function setTokenURI(uint256 tokenId, string memory _tokenURI) public onlyOwner{ require(_exists(tokenId), "URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[_tokenId]; return _tokenURI; } function mint(address _to, string memory _tokenURI) public onlyOwner { _mint(_to, totalSupply); setTokenURI(totalSupply, _tokenURI); emit MintFattie(_to, totalSupply); totalSupply += 1; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c806370a08231116100ad578063b88d4fde11610071578063b88d4fde146102f4578063c87b56dd14610310578063d0def52114610340578063e985e9c51461035c578063f2fde38b1461038c57610121565b806370a0823114610262578063715018a6146102925780638da5cb5b1461029c57806395d89b41146102ba578063a22cb465146102d857610121565b8063162094c4116100f4578063162094c4146101c057806318160ddd146101dc57806323b872dd146101fa57806342842e0e146102165780636352211e1461023257610121565b806301ffc9a71461012657806306fdde0314610156578063081812fc14610174578063095ea7b3146101a4575b600080fd5b610140600480360381019061013b9190611da7565b6103a8565b60405161014d919061220c565b60405180910390f35b61015e61048a565b60405161016b9190612227565b60405180910390f35b61018e60048036038101906101899190611e01565b61051c565b60405161019b919061217c565b60405180910390f35b6101be60048036038101906101b99190611d67565b6105a1565b005b6101da60048036038101906101d59190611e2e565b6106b9565b005b6101e46107a9565b6040516101f19190612469565b60405180910390f35b610214600480360381019061020f9190611bf5565b6107af565b005b610230600480360381019061022b9190611bf5565b61080f565b005b61024c60048036038101906102479190611e01565b61082f565b604051610259919061217c565b60405180910390f35b61027c60048036038101906102779190611b88565b6108e1565b6040516102899190612469565b60405180910390f35b61029a610999565b005b6102a4610a21565b6040516102b1919061217c565b60405180910390f35b6102c2610a4b565b6040516102cf9190612227565b60405180910390f35b6102f260048036038101906102ed9190611ccb565b610add565b005b61030e60048036038101906103099190611c48565b610c5e565b005b61032a60048036038101906103259190611e01565b610cc0565b6040516103379190612227565b60405180910390f35b61035a60048036038101906103559190611d0b565b610db3565b005b61037660048036038101906103719190611bb5565b610ea0565b604051610383919061220c565b60405180910390f35b6103a660048036038101906103a19190611b88565b610f34565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061047357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061048357506104828261102c565b5b9050919050565b60606000805461049990612683565b80601f01602080910402602001604051908101604052809291908181526020018280546104c590612683565b80156105125780601f106104e757610100808354040283529160200191610512565b820191906000526020600020905b8154815290600101906020018083116104f557829003601f168201915b5050505050905090565b600061052782611096565b610566576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055d906123a9565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006105ac8261082f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561061d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061490612429565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661063c611102565b73ffffffffffffffffffffffffffffffffffffffff16148061066b575061066a81610665611102565b610ea0565b5b6106aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a190612329565b60405180910390fd5b6106b4838361110a565b505050565b6106c1611102565b73ffffffffffffffffffffffffffffffffffffffff166106df610a21565b73ffffffffffffffffffffffffffffffffffffffff1614610735576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072c906123c9565b60405180910390fd5b61073e82611096565b61077d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077490612409565b60405180910390fd5b806008600084815260200190815260200160002090805190602001906107a492919061199c565b505050565b60075481565b6107c06107ba611102565b826111c3565b6107ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f690612449565b60405180910390fd5b61080a8383836112a1565b505050565b61082a83838360405180602001604052806000815250610c5e565b505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156108d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108cf90612369565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610952576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094990612349565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109a1611102565b73ffffffffffffffffffffffffffffffffffffffff166109bf610a21565b73ffffffffffffffffffffffffffffffffffffffff1614610a15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0c906123c9565b60405180910390fd5b610a1f60006114fd565b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610a5a90612683565b80601f0160208091040260200160405190810160405280929190818152602001828054610a8690612683565b8015610ad35780601f10610aa857610100808354040283529160200191610ad3565b820191906000526020600020905b815481529060010190602001808311610ab657829003601f168201915b5050505050905090565b610ae5611102565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4a906122e9565b60405180910390fd5b8060056000610b60611102565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610c0d611102565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c52919061220c565b60405180910390a35050565b610c6f610c69611102565b836111c3565b610cae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca590612449565b60405180910390fd5b610cba848484846115c3565b50505050565b6060610ccb82611096565b610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190612249565b60405180910390fd5b6000600860008481526020019081526020016000208054610d2a90612683565b80601f0160208091040260200160405190810160405280929190818152602001828054610d5690612683565b8015610da35780601f10610d7857610100808354040283529160200191610da3565b820191906000526020600020905b815481529060010190602001808311610d8657829003601f168201915b5050505050905080915050919050565b610dbb611102565b73ffffffffffffffffffffffffffffffffffffffff16610dd9610a21565b73ffffffffffffffffffffffffffffffffffffffff1614610e2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e26906123c9565b60405180910390fd5b610e3b8260075461161f565b610e47600754826106b9565b7f6950dfc20256e610812465083e77de24236674cceeda68a140c9f4f2b3d02d0f82600754604051610e7a9291906121e3565b60405180910390a1600160076000828254610e959190612543565b925050819055505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b610f3c611102565b73ffffffffffffffffffffffffffffffffffffffff16610f5a610a21565b73ffffffffffffffffffffffffffffffffffffffff1614610fb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa7906123c9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611020576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101790612289565b60405180910390fd5b611029816114fd565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661117d8361082f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006111ce82611096565b61120d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120490612309565b60405180910390fd5b60006112188361082f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061128757508373ffffffffffffffffffffffffffffffffffffffff1661126f8461051c565b73ffffffffffffffffffffffffffffffffffffffff16145b8061129857506112978185610ea0565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166112c18261082f565b73ffffffffffffffffffffffffffffffffffffffff1614611317576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130e906123e9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137e906122c9565b60405180910390fd5b6113928383836117ed565b61139d60008261110a565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546113ed9190612599565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114449190612543565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6115ce8484846112a1565b6115da848484846117f2565b611619576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161090612269565b60405180910390fd5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561168f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168690612389565b60405180910390fd5b61169881611096565b156116d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116cf906122a9565b60405180910390fd5b6116e4600083836117ed565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117349190612543565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b60006118138473ffffffffffffffffffffffffffffffffffffffff16611989565b1561197c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261183c611102565b8786866040518563ffffffff1660e01b815260040161185e9493929190612197565b602060405180830381600087803b15801561187857600080fd5b505af19250505080156118a957506040513d601f19601f820116820180604052508101906118a69190611dd4565b60015b61192c573d80600081146118d9576040519150601f19603f3d011682016040523d82523d6000602084013e6118de565b606091505b50600081511415611924576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191b90612269565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611981565b600190505b949350505050565b600080823b905060008111915050919050565b8280546119a890612683565b90600052602060002090601f0160209004810192826119ca5760008555611a11565b82601f106119e357805160ff1916838001178555611a11565b82800160010185558215611a11579182015b82811115611a105782518255916020019190600101906119f5565b5b509050611a1e9190611a22565b5090565b5b80821115611a3b576000816000905550600101611a23565b5090565b6000611a52611a4d846124a9565b612484565b905082815260208101848484011115611a6e57611a6d612778565b5b611a79848285612641565b509392505050565b6000611a94611a8f846124da565b612484565b905082815260208101848484011115611ab057611aaf612778565b5b611abb848285612641565b509392505050565b600081359050611ad281612bf3565b92915050565b600081359050611ae781612c0a565b92915050565b600081359050611afc81612c21565b92915050565b600081519050611b1181612c21565b92915050565b600082601f830112611b2c57611b2b612773565b5b8135611b3c848260208601611a3f565b91505092915050565b600082601f830112611b5a57611b59612773565b5b8135611b6a848260208601611a81565b91505092915050565b600081359050611b8281612c38565b92915050565b600060208284031215611b9e57611b9d612782565b5b6000611bac84828501611ac3565b91505092915050565b60008060408385031215611bcc57611bcb612782565b5b6000611bda85828601611ac3565b9250506020611beb85828601611ac3565b9150509250929050565b600080600060608486031215611c0e57611c0d612782565b5b6000611c1c86828701611ac3565b9350506020611c2d86828701611ac3565b9250506040611c3e86828701611b73565b9150509250925092565b60008060008060808587031215611c6257611c61612782565b5b6000611c7087828801611ac3565b9450506020611c8187828801611ac3565b9350506040611c9287828801611b73565b925050606085013567ffffffffffffffff811115611cb357611cb261277d565b5b611cbf87828801611b17565b91505092959194509250565b60008060408385031215611ce257611ce1612782565b5b6000611cf085828601611ac3565b9250506020611d0185828601611ad8565b9150509250929050565b60008060408385031215611d2257611d21612782565b5b6000611d3085828601611ac3565b925050602083013567ffffffffffffffff811115611d5157611d5061277d565b5b611d5d85828601611b45565b9150509250929050565b60008060408385031215611d7e57611d7d612782565b5b6000611d8c85828601611ac3565b9250506020611d9d85828601611b73565b9150509250929050565b600060208284031215611dbd57611dbc612782565b5b6000611dcb84828501611aed565b91505092915050565b600060208284031215611dea57611de9612782565b5b6000611df884828501611b02565b91505092915050565b600060208284031215611e1757611e16612782565b5b6000611e2584828501611b73565b91505092915050565b60008060408385031215611e4557611e44612782565b5b6000611e5385828601611b73565b925050602083013567ffffffffffffffff811115611e7457611e7361277d565b5b611e8085828601611b45565b9150509250929050565b611e93816125cd565b82525050565b611ea2816125df565b82525050565b6000611eb38261250b565b611ebd8185612521565b9350611ecd818560208601612650565b611ed681612787565b840191505092915050565b6000611eec82612516565b611ef68185612532565b9350611f06818560208601612650565b611f0f81612787565b840191505092915050565b6000611f27601f83612532565b9150611f3282612798565b602082019050919050565b6000611f4a603283612532565b9150611f55826127c1565b604082019050919050565b6000611f6d602683612532565b9150611f7882612810565b604082019050919050565b6000611f90601c83612532565b9150611f9b8261285f565b602082019050919050565b6000611fb3602483612532565b9150611fbe82612888565b604082019050919050565b6000611fd6601983612532565b9150611fe1826128d7565b602082019050919050565b6000611ff9602c83612532565b915061200482612900565b604082019050919050565b600061201c603883612532565b91506120278261294f565b604082019050919050565b600061203f602a83612532565b915061204a8261299e565b604082019050919050565b6000612062602983612532565b915061206d826129ed565b604082019050919050565b6000612085602083612532565b915061209082612a3c565b602082019050919050565b60006120a8602c83612532565b91506120b382612a65565b604082019050919050565b60006120cb602083612532565b91506120d682612ab4565b602082019050919050565b60006120ee602983612532565b91506120f982612add565b604082019050919050565b6000612111601c83612532565b915061211c82612b2c565b602082019050919050565b6000612134602183612532565b915061213f82612b55565b604082019050919050565b6000612157603183612532565b915061216282612ba4565b604082019050919050565b61217681612637565b82525050565b60006020820190506121916000830184611e8a565b92915050565b60006080820190506121ac6000830187611e8a565b6121b96020830186611e8a565b6121c6604083018561216d565b81810360608301526121d88184611ea8565b905095945050505050565b60006040820190506121f86000830185611e8a565b612205602083018461216d565b9392505050565b60006020820190506122216000830184611e99565b92915050565b600060208201905081810360008301526122418184611ee1565b905092915050565b6000602082019050818103600083015261226281611f1a565b9050919050565b6000602082019050818103600083015261228281611f3d565b9050919050565b600060208201905081810360008301526122a281611f60565b9050919050565b600060208201905081810360008301526122c281611f83565b9050919050565b600060208201905081810360008301526122e281611fa6565b9050919050565b6000602082019050818103600083015261230281611fc9565b9050919050565b6000602082019050818103600083015261232281611fec565b9050919050565b600060208201905081810360008301526123428161200f565b9050919050565b6000602082019050818103600083015261236281612032565b9050919050565b6000602082019050818103600083015261238281612055565b9050919050565b600060208201905081810360008301526123a281612078565b9050919050565b600060208201905081810360008301526123c28161209b565b9050919050565b600060208201905081810360008301526123e2816120be565b9050919050565b60006020820190508181036000830152612402816120e1565b9050919050565b6000602082019050818103600083015261242281612104565b9050919050565b6000602082019050818103600083015261244281612127565b9050919050565b600060208201905081810360008301526124628161214a565b9050919050565b600060208201905061247e600083018461216d565b92915050565b600061248e61249f565b905061249a82826126b5565b919050565b6000604051905090565b600067ffffffffffffffff8211156124c4576124c3612744565b5b6124cd82612787565b9050602081019050919050565b600067ffffffffffffffff8211156124f5576124f4612744565b5b6124fe82612787565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061254e82612637565b915061255983612637565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561258e5761258d6126e6565b5b828201905092915050565b60006125a482612637565b91506125af83612637565b9250828210156125c2576125c16126e6565b5b828203905092915050565b60006125d882612617565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561266e578082015181840152602081019050612653565b8381111561267d576000848401525b50505050565b6000600282049050600182168061269b57607f821691505b602082108114156126af576126ae612715565b5b50919050565b6126be82612787565b810181811067ffffffffffffffff821117156126dd576126dc612744565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f55524920717565727920666f72206e6f6e6578697374656e7420746f6b656e00600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f55524920736574206f66206e6f6e6578697374656e7420746f6b656e00000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b612bfc816125cd565b8114612c0757600080fd5b50565b612c13816125df565b8114612c1e57600080fd5b50565b612c2a816125eb565b8114612c3557600080fd5b50565b612c4181612637565b8114612c4c57600080fd5b5056fea26469706673582212208e6b8f5dd93996e325eb8b14696811c68988e0fa348c41221aff01088ea59b8a64736f6c63430008070033
{"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, 2581, 2683, 2629, 2278, 28311, 2487, 2546, 2629, 2050, 2575, 2063, 2581, 9468, 11960, 2509, 27421, 2497, 20842, 2575, 22394, 5243, 9468, 2487, 2497, 2475, 2063, 28332, 2692, 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, 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, 6638, 9515, 2003, 9413, 2278, 2581, 17465, 1010, 2219, 3085, 1063, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 12375, 1006, 21318, 3372, 17788, 2575, 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,909
0x97967c25f5a0de5cdc3c9d687ec3036c7b15252f
pragma solidity ^0.4.23; // https://www.pennyether.com /******* USING Registry ************************** Gives the inherting contract access to: .addressOf(bytes32): returns current address mapped to the name. [modifier] .fromOwner(): requires the sender is owner. *************************************************/ // Returned by .getRegistry() interface IRegistry { function owner() external view returns (address _addr); function addressOf(bytes32 _name) external view returns (address _addr); } contract UsingRegistry { IRegistry private registry; modifier fromOwner(){ require(msg.sender == getOwner()); _; } constructor(address _registry) public { require(_registry != 0); registry = IRegistry(_registry); } function addressOf(bytes32 _name) internal view returns(address _addr) { return registry.addressOf(_name); } function getOwner() public view returns (address _addr) { return registry.owner(); } function getRegistry() public view returns (IRegistry _addr) { return registry; } } /******* USING ADMIN *********************** Gives the inherting contract access to: .getAdmin(): returns the current address of the admin [modifier] .fromAdmin: requires the sender is the admin *************************************************/ contract UsingAdmin is UsingRegistry { constructor(address _registry) UsingRegistry(_registry) public {} modifier fromAdmin(){ require(msg.sender == getAdmin()); _; } function getAdmin() public constant returns (address _addr) { return addressOf("ADMIN"); } } /******* USING TREASURY ************************** Gives the inherting contract access to: .getTreasury(): returns current ITreasury instance [modifier] .fromTreasury(): requires the sender is current Treasury *************************************************/ // Returned by .getTreasury() interface ITreasury { function issueDividend() external returns (uint _profits); function profitsSendable() external view returns (uint _profits); } contract UsingTreasury is UsingRegistry { constructor(address _registry) UsingRegistry(_registry) public {} modifier fromTreasury(){ require(msg.sender == address(getTreasury())); _; } function getTreasury() public view returns (ITreasury) { return ITreasury(addressOf("TREASURY")); } } /** This is a simple class that maintains a doubly linked list of address => uint amounts. Address balances can be added to or removed from via add() and subtract(). All balances can be obtain by calling balances(). If an address has a 0 amount, it is removed from the Ledger. Note: THIS DOES NOT TEST FOR OVERFLOWS, but it's safe to use to track Ether balances. Public methods: - [fromOwner] add() - [fromOwner] subtract() Public views: - total() - size() - balanceOf() - balances() - entries() [to manually iterate] */ contract Ledger { uint public total; // Total amount in Ledger struct Entry { // Doubly linked list tracks amount per address uint balance; address next; address prev; } mapping (address => Entry) public entries; address public owner; modifier fromOwner() { require(msg.sender==owner); _; } // Constructor sets the owner constructor(address _owner) public { owner = _owner; } /******************************************************/ /*************** OWNER METHODS ************************/ /******************************************************/ function add(address _address, uint _amt) fromOwner public { if (_address == address(0) || _amt == 0) return; Entry storage entry = entries[_address]; // If new entry, replace first entry with this one. if (entry.balance == 0) { entry.next = entries[0x0].next; entries[entries[0x0].next].prev = _address; entries[0x0].next = _address; } // Update stats. total += _amt; entry.balance += _amt; } function subtract(address _address, uint _amt) fromOwner public returns (uint _amtRemoved) { if (_address == address(0) || _amt == 0) return; Entry storage entry = entries[_address]; uint _maxAmt = entry.balance; if (_maxAmt == 0) return; if (_amt >= _maxAmt) { // Subtract the max amount, and delete entry. total -= _maxAmt; entries[entry.prev].next = entry.next; entries[entry.next].prev = entry.prev; delete entries[_address]; return _maxAmt; } else { // Subtract the amount from entry. total -= _amt; entry.balance -= _amt; return _amt; } } /******************************************************/ /*************** PUBLIC VIEWS *************************/ /******************************************************/ function size() public view returns (uint _size) { // Loop once to get the total count. Entry memory _curEntry = entries[0x0]; while (_curEntry.next > 0) { _curEntry = entries[_curEntry.next]; _size++; } return _size; } function balanceOf(address _address) public view returns (uint _balance) { return entries[_address].balance; } function balances() public view returns (address[] _addresses, uint[] _balances) { // Populate names and addresses uint _size = size(); _addresses = new address[](_size); _balances = new uint[](_size); uint _i = 0; Entry memory _curEntry = entries[0x0]; while (_curEntry.next > 0) { _addresses[_i] = _curEntry.next; _balances[_i] = entries[_curEntry.next].balance; _curEntry = entries[_curEntry.next]; _i++; } return (_addresses, _balances); } } /** This is a simple class that maintains a doubly linked list of addresses it has seen. Addresses can be added and removed from the set, and a full list of addresses can be obtained. Methods: - [fromOwner] .add() - [fromOwner] .remove() Views: - .size() - .has() - .addresses() */ contract AddressSet { struct Entry { // Doubly linked list bool exists; address next; address prev; } mapping (address => Entry) public entries; address public owner; modifier fromOwner() { require(msg.sender==owner); _; } // Constructor sets the owner. constructor(address _owner) public { owner = _owner; } /******************************************************/ /*************** OWNER METHODS ************************/ /******************************************************/ function add(address _address) fromOwner public returns (bool _didCreate) { // Do not allow the adding of HEAD. if (_address == address(0)) return; Entry storage entry = entries[_address]; // If already exists, do nothing. Otherwise set it. if (entry.exists) return; else entry.exists = true; // Replace first entry with this one. // Before: HEAD <-> X <-> Y // After: HEAD <-> THIS <-> X <-> Y // do: THIS.NEXT = [0].next; [0].next.prev = THIS; [0].next = THIS; THIS.prev = 0; Entry storage HEAD = entries[0x0]; entry.next = HEAD.next; entries[HEAD.next].prev = _address; HEAD.next = _address; return true; } function remove(address _address) fromOwner public returns (bool _didExist) { // Do not allow the removal of HEAD. if (_address == address(0)) return; Entry storage entry = entries[_address]; // If it doesn't exist already, there is nothing to do. if (!entry.exists) return; // Stitch together next and prev, delete entry. // Before: X <-> THIS <-> Y // After: X <-> Y // do: THIS.next.prev = this.prev; THIS.prev.next = THIS.next; entries[entry.prev].next = entry.next; entries[entry.next].prev = entry.prev; delete entries[_address]; return true; } /******************************************************/ /*************** PUBLIC VIEWS *************************/ /******************************************************/ function size() public view returns (uint _size) { // Loop once to get the total count. Entry memory _curEntry = entries[0x0]; while (_curEntry.next > 0) { _curEntry = entries[_curEntry.next]; _size++; } return _size; } function has(address _address) public view returns (bool _exists) { return entries[_address].exists; } function addresses() public view returns (address[] _addresses) { // Populate names and addresses uint _size = size(); _addresses = new address[](_size); // Iterate forward through all entries until the end. uint _i = 0; Entry memory _curEntry = entries[0x0]; while (_curEntry.next > 0) { _addresses[_i] = _curEntry.next; _curEntry = entries[_curEntry.next]; _i++; } return _addresses; } } /** A simple class that manages bankroll, and maintains collateral. This class only ever sends profits the Treasury. No exceptions. - Anybody can add funding (according to whitelist) - Anybody can tell profits (balance - (funding + collateral)) to go to Treasury. - Anyone can remove their funding, so long as balance >= collateral. - Whitelist is managed by getWhitelistOwner() -- typically Admin. Exposes the following: Public Methods - addBankroll - removeBankroll - sendProfits Public Views - getCollateral - profits - profitsSent - profitsTotal - bankroll - bankrollAvailable - bankrolledBy - bankrollerTable */ contract Bankrollable is UsingTreasury { // How much profits have been sent. uint public profitsSent; // Ledger keeps track of who has bankrolled us, and for how much Ledger public ledger; // This is a copy of ledger.total(), to save gas in .bankrollAvailable() uint public bankroll; // This is the whitelist of who can call .addBankroll() AddressSet public whitelist; modifier fromWhitelistOwner(){ require(msg.sender == getWhitelistOwner()); _; } event BankrollAdded(uint time, address indexed bankroller, uint amount, uint bankroll); event BankrollRemoved(uint time, address indexed bankroller, uint amount, uint bankroll); event ProfitsSent(uint time, address indexed treasury, uint amount); event AddedToWhitelist(uint time, address indexed addr, address indexed wlOwner); event RemovedFromWhitelist(uint time, address indexed addr, address indexed wlOwner); // Constructor creates the ledger and whitelist, with self as owner. constructor(address _registry) UsingTreasury(_registry) public { ledger = new Ledger(this); whitelist = new AddressSet(this); } /*****************************************************/ /************** WHITELIST MGMT ***********************/ /*****************************************************/ function addToWhitelist(address _addr) fromWhitelistOwner public { bool _didAdd = whitelist.add(_addr); if (_didAdd) emit AddedToWhitelist(now, _addr, msg.sender); } function removeFromWhitelist(address _addr) fromWhitelistOwner public { bool _didRemove = whitelist.remove(_addr); if (_didRemove) emit RemovedFromWhitelist(now, _addr, msg.sender); } /*****************************************************/ /************** PUBLIC FUNCTIONS *********************/ /*****************************************************/ // Bankrollable contracts should be payable (to receive revenue) function () public payable {} // Increase funding by whatever value is sent function addBankroll() public payable { require(whitelist.size()==0 || whitelist.has(msg.sender)); ledger.add(msg.sender, msg.value); bankroll = ledger.total(); emit BankrollAdded(now, msg.sender, msg.value, bankroll); } // Removes up to _amount from Ledger, and sends it to msg.sender._callbackFn function removeBankroll(uint _amount, string _callbackFn) public returns (uint _recalled) { // cap amount at the balance minus collateral, or nothing at all. address _bankroller = msg.sender; uint _collateral = getCollateral(); uint _balance = address(this).balance; uint _available = _balance > _collateral ? _balance - _collateral : 0; if (_amount > _available) _amount = _available; // Try to remove _amount from ledger, get actual _amount removed. _amount = ledger.subtract(_bankroller, _amount); bankroll = ledger.total(); if (_amount == 0) return; bytes4 _sig = bytes4(keccak256(_callbackFn)); require(_bankroller.call.value(_amount)(_sig)); emit BankrollRemoved(now, _bankroller, _amount, bankroll); return _amount; } // Send any excess profits to treasury. function sendProfits() public returns (uint _profits) { int _p = profits(); if (_p <= 0) return; _profits = uint(_p); profitsSent += _profits; // Send profits to Treasury address _tr = getTreasury(); require(_tr.call.value(_profits)()); emit ProfitsSent(now, _tr, _profits); } /*****************************************************/ /************** PUBLIC VIEWS *************************/ /*****************************************************/ // Function must be overridden by inheritors to ensure collateral is kept. function getCollateral() public view returns (uint _amount); // Function must be overridden by inheritors to enable whitelist control. function getWhitelistOwner() public view returns (address _addr); // Profits are the difference between balance and threshold function profits() public view returns (int _profits) { int _balance = int(address(this).balance); int _threshold = int(bankroll + getCollateral()); return _balance - _threshold; } // How profitable this contract is, overall function profitsTotal() public view returns (int _profits) { return int(profitsSent) + profits(); } // Returns the amount that can currently be bankrolled. // - 0 if balance < collateral // - If profits: full bankroll // - If no profits: remaning bankroll: balance - collateral function bankrollAvailable() public view returns (uint _amount) { uint _balance = address(this).balance; uint _bankroll = bankroll; uint _collat = getCollateral(); // Balance is below collateral! if (_balance <= _collat) return 0; // No profits, but we have a balance over collateral. else if (_balance < _collat + _bankroll) return _balance - _collat; // Profits. Return only _bankroll else return _bankroll; } function bankrolledBy(address _addr) public view returns (uint _amount) { return ledger.balanceOf(_addr); } function bankrollerTable() public view returns (address[], uint[]) { return ledger.balances(); } } contract VideoPokerUtils { uint constant HAND_UNDEFINED = 0; uint constant HAND_RF = 1; uint constant HAND_SF = 2; uint constant HAND_FK = 3; uint constant HAND_FH = 4; uint constant HAND_FL = 5; uint constant HAND_ST = 6; uint constant HAND_TK = 7; uint constant HAND_TP = 8; uint constant HAND_JB = 9; uint constant HAND_HC = 10; uint constant HAND_NOT_COMPUTABLE = 11; /*****************************************************/ /********** PUBLIC PURE FUNCTIONS ********************/ /*****************************************************/ // Gets a new 5-card hand, stored in uint32 // Gas Cost: 3k function getHand(uint256 _hash) public pure returns (uint32) { // Return the cards as a hand. return uint32(getCardsFromHash(_hash, 5, 0)); } // Both _hand and _draws store the first card in the // rightmost position. _hand uses chunks of 6 bits. // // In the below example, hand is [9,18,35,12,32], and // the cards 18 and 35 will be replaced. // // _hand: [9,18,35,12,32] // encoding: XX 100000 001100 100011 010010 001001 // chunks: 32 12 35 18 9 // order: card5, card4, card3, card2, card1 // decimal: 540161161 // // _draws: card2 and card4 // encoding: XXX 0 0 1 1 0 // order: card5, card4, card3, card2, card1 // decimal: 6 // // Gas Cost: Fixed 6k gas. function drawToHand(uint256 _hash, uint32 _hand, uint _draws) public pure returns (uint32) { // Draws must be valid. If no hand, must draw all 5 cards. assert(_draws <= 31); assert(_hand != 0 || _draws == 31); // Shortcuts. Return _hand on no draws, or 5 cards on full draw. if (_draws == 0) return _hand; if (_draws == 31) return uint32(getCardsFromHash(_hash, 5, handToBitmap(_hand))); // Create a mask of 1's where new cards should go. uint _newMask; for (uint _i=0; _i<5; _i++) { if (_draws & 2**_i == 0) continue; _newMask |= 63 * (2**(6*_i)); } // Create a mask of 0's where new cards should go. // Be sure to use only first 30 bits (5 cards x 6 bits) uint _discardMask = ~_newMask & (2**31-1); // Select from _newHand, discard from _hand, and combine. uint _newHand = getCardsFromHash(_hash, 5, handToBitmap(_hand)); _newHand &= _newMask; _newHand |= _hand & _discardMask; return uint32(_newHand); } // Looks at a hand of 5-cards, determines strictly the HandRank. // Gas Cost: up to 7k depending on hand. function getHandRank(uint32 _hand) public pure returns (uint) { if (_hand == 0) return HAND_NOT_COMPUTABLE; uint _card; uint[] memory _valCounts = new uint[](13); uint[] memory _suitCounts = new uint[](5); uint _pairVal; uint _minNonAce = 100; uint _maxNonAce = 0; uint _numPairs; uint _maxSet; bool _hasFlush; bool _hasAce; // Set all the values above. // Note: // _hasTwoPair will be true even if one pair is Trips. // Likewise, _hasTrips will be true even if there are Quads. uint _i; uint _val; for (_i=0; _i<5; _i++) { _card = readFromCards(_hand, _i); if (_card > 51) return HAND_NOT_COMPUTABLE; // update val and suit counts, and if it's a flush _val = _card % 13; _valCounts[_val]++; _suitCounts[_card/13]++; if (_suitCounts[_card/13] == 5) _hasFlush = true; // update _hasAce, and min/max value if (_val == 0) { _hasAce = true; } else { if (_val < _minNonAce) _minNonAce = _val; if (_val > _maxNonAce) _maxNonAce = _val; } // update _pairVal, _numPairs, _maxSet if (_valCounts[_val] == 2) { if (_numPairs==0) _pairVal = _val; _numPairs++; } else if (_valCounts[_val] == 3) { _maxSet = 3; } else if (_valCounts[_val] == 4) { _maxSet = 4; } } if (_numPairs > 0){ // If they have quads, they can't have royal flush, so we can return. if (_maxSet==4) return HAND_FK; // One of the two pairs was the trips, so it's a full house. if (_maxSet==3 && _numPairs==2) return HAND_FH; // Trips is their best hand (no straight or flush possible) if (_maxSet==3) return HAND_TK; // Two pair is their best hand (no straight or flush possible) if (_numPairs==2) return HAND_TP; // One pair is their best hand (no straight or flush possible) if (_numPairs == 1 && (_pairVal >= 10 || _pairVal==0)) return HAND_JB; // They have a low pair (no straight or flush possible) return HAND_HC; } // They have no pair. Do they have a straight? bool _hasStraight = _hasAce // Check for: A,1,2,3,4 or 9,10,11,12,A ? _maxNonAce == 4 || _minNonAce == 9 // Check for X,X+1,X+2,X+3,X+4 : _maxNonAce - _minNonAce == 4; // Check for hands in order of rank. if (_hasStraight && _hasFlush && _minNonAce==9) return HAND_RF; if (_hasStraight && _hasFlush) return HAND_SF; if (_hasFlush) return HAND_FL; if (_hasStraight) return HAND_ST; return HAND_HC; } // Not used anywhere, but added for convenience function handToCards(uint32 _hand) public pure returns (uint8[5] _cards) { uint32 _mask; for (uint _i=0; _i<5; _i++){ _mask = uint32(63 * 2**(6*_i)); _cards[_i] = uint8((_hand & _mask) / (2**(6*_i))); } } /*****************************************************/ /********** PRIVATE INTERNAL FUNCTIONS ***************/ /*****************************************************/ function readFromCards(uint _cards, uint _index) internal pure returns (uint) { uint _offset = 2**(6*_index); uint _oneBits = 2**6 - 1; return (_cards & (_oneBits * _offset)) / _offset; } // Returns a bitmap to represent the set of cards in _hand. function handToBitmap(uint32 _hand) internal pure returns (uint _bitmap) { if (_hand == 0) return 0; uint _mask; uint _card; for (uint _i=0; _i<5; _i++){ _mask = 63 * 2**(6*_i); _card = (_hand & _mask) / (2**(6*_i)); _bitmap |= 2**_card; } } // Returns numCards from a uint256 (eg, keccak256) seed hash. // Returns cards as one uint, with each card being 6 bits. function getCardsFromHash(uint256 _hash, uint _numCards, uint _usedBitmap) internal pure returns (uint _cards) { // Return early if we don't need to pick any cards. if (_numCards == 0) return; uint _cardIdx = 0; // index of currentCard uint _card; // current chosen card uint _usedMask; // mask of current card while (true) { _card = _hash % 52; // Generate card from hash _usedMask = 2**_card; // Create mask for the card // If card is not used, add it to _cards and _usedBitmap // Return if we have enough cards. if (_usedBitmap & _usedMask == 0) { _cards |= (_card * 2**(_cardIdx*6)); _usedBitmap |= _usedMask; _cardIdx++; if (_cardIdx == _numCards) return _cards; } // Generate hash used to pick next card. _hash = uint256(keccak256(_hash)); } } } contract VideoPoker is VideoPokerUtils, Bankrollable, UsingAdmin { // All the data needed for each game. struct Game { // [1st 256-bit block] uint32 userId; uint64 bet; // max of 18 Ether (set on bet) uint16 payTableId; // the PayTable used (set on bet) uint32 iBlock; // initial hand block (set on bet) uint32 iHand; // initial hand (set on draw/finalize) uint8 draws; // bitmap of which cards to draw (set on draw/finalize) uint32 dBlock; // block of the dHand (set on draw/finalize) uint32 dHand; // hand after draws (set on finalize) uint8 handRank; // result of the hand (set on finalize) } // These variables change on each bet and finalization. // We put them in a struct with the hopes that optimizer // will do one write if any/all of them change. struct Vars { // [1st 256-bit block] uint32 curId; // (changes on bet) uint64 totalWageredGwei; // (changes on bet) uint32 curUserId; // (changes on bet, maybe) uint128 empty1; // intentionally left empty, so the below // updates occur in the same update // [2nd 256-bit block] uint64 totalWonGwei; // (changes on finalization win) uint88 totalCredits; // (changes on finalization win) uint8 empty2; // set to true to normalize gas cost } struct Settings { uint64 minBet; uint64 maxBet; uint16 curPayTableId; uint16 numPayTables; uint32 lastDayAdded; } Settings settings; Vars vars; // A Mapping of all games mapping(uint32 => Game) public games; // Credits we owe the user mapping(address => uint) public credits; // Store a two-way mapping of address <=> userId // If we've seen a user before, betting will be just 1 write // per Game struct vs 2 writes. // The trade-off is 3 writes for new users. Seems fair. mapping (address => uint32) public userIds; mapping (uint32 => address) public userAddresses; // Note: Pay tables cannot be changed once added. // However, admin can change the current PayTable mapping(uint16=>uint16[12]) payTables; // version of the game uint8 public constant version = 2; uint8 constant WARN_IHAND_TIMEOUT = 1; // "Initial hand not available. Drawing 5 new cards." uint8 constant WARN_DHAND_TIMEOUT = 2; // "Draw cards not available. Using initial hand." uint8 constant WARN_BOTH_TIMEOUT = 3; // "Draw cards not available, and no initial hand." // Admin Events event Created(uint time); event PayTableAdded(uint time, address admin, uint payTableId); event SettingsChanged(uint time, address admin); // Game Events event BetSuccess(uint time, address indexed user, uint32 indexed id, uint bet, uint payTableId); event BetFailure(uint time, address indexed user, uint bet, string msg); event DrawSuccess(uint time, address indexed user, uint32 indexed id, uint32 iHand, uint8 draws, uint8 warnCode); event DrawFailure(uint time, address indexed user, uint32 indexed id, uint8 draws, string msg); event FinalizeSuccess(uint time, address indexed user, uint32 indexed id, uint32 dHand, uint8 handRank, uint payout, uint8 warnCode); event FinalizeFailure(uint time, address indexed user, uint32 indexed id, string msg); // Credits event CreditsAdded(uint time, address indexed user, uint32 indexed id, uint amount); event CreditsUsed(uint time, address indexed user, uint32 indexed id, uint amount); event CreditsCashedout(uint time, address indexed user, uint amount); constructor(address _registry) Bankrollable(_registry) UsingAdmin(_registry) public { // Add the default PayTable. _addPayTable(800, 50, 25, 9, 6, 4, 3, 2, 1); // write to vars, to lower gas-cost for the first game. // vars.empty1 = 1; // vars.empty2 = 1; // initialze stats to last settings vars.curId = 293; vars.totalWageredGwei =2864600000; vars.curUserId = 38; vars.totalWonGwei = 2450400000; // initialize settings settings.minBet = .001 ether; settings.maxBet = .375 ether; emit Created(now); } /************************************************************/ /******************** ADMIN FUNCTIONS ***********************/ /************************************************************/ // Allows admin to change minBet, maxBet, and curPayTableId function changeSettings(uint64 _minBet, uint64 _maxBet, uint8 _payTableId) public fromAdmin { require(_maxBet <= .375 ether); require(_payTableId < settings.numPayTables); settings.minBet = _minBet; settings.maxBet = _maxBet; settings.curPayTableId = _payTableId; emit SettingsChanged(now, msg.sender); } // Allows admin to permanently add a PayTable (once per day) function addPayTable( uint16 _rf, uint16 _sf, uint16 _fk, uint16 _fh, uint16 _fl, uint16 _st, uint16 _tk, uint16 _tp, uint16 _jb ) public fromAdmin { uint32 _today = uint32(block.timestamp / 1 days); require(settings.lastDayAdded < _today); settings.lastDayAdded = _today; _addPayTable(_rf, _sf, _fk, _fh, _fl, _st, _tk, _tp, _jb); emit PayTableAdded(now, msg.sender, settings.numPayTables-1); } /************************************************************/ /****************** PUBLIC FUNCTIONS ************************/ /************************************************************/ // Allows a user to add credits to their account. function addCredits() public payable { _creditUser(msg.sender, msg.value, 0); } // Allows the user to cashout an amt (or their whole balance) function cashOut(uint _amt) public { _uncreditUser(msg.sender, _amt); } // Allows a user to create a game from Ether sent. // // Gas Cost: 55k (prev player), 95k (new player) // - 22k: tx overhead // - 26k, 66k: see _createNewGame() // - 3k: event // - 2k: curMaxBet() // - 2k: SLOAD, execution function bet() public payable { uint _bet = msg.value; if (_bet > settings.maxBet) return _betFailure("Bet too large.", _bet, true); if (_bet < settings.minBet) return _betFailure("Bet too small.", _bet, true); if (_bet > curMaxBet()) return _betFailure("The bankroll is too low.", _bet, true); // no uint64 overflow: _bet < maxBet < .625 ETH < 2e64 uint32 _id = _createNewGame(uint64(_bet)); emit BetSuccess(now, msg.sender, _id, _bet, settings.curPayTableId); } // Allows a user to create a game from Credits. // // Gas Cost: 61k // - 22k: tx overhead // - 26k: see _createNewGame() // - 3k: event // - 2k: curMaxBet() // - 2k: 1 event: CreditsUsed // - 5k: update credits[user] // - 1k: SLOAD, execution function betWithCredits(uint64 _bet) public { if (_bet > settings.maxBet) return _betFailure("Bet too large.", _bet, false); if (_bet < settings.minBet) return _betFailure("Bet too small.", _bet, false); if (_bet > curMaxBet()) return _betFailure("The bankroll is too low.", _bet, false); if (_bet > credits[msg.sender]) return _betFailure("Insufficient credits", _bet, false); uint32 _id = _createNewGame(uint64(_bet)); vars.totalCredits -= uint88(_bet); credits[msg.sender] -= _bet; emit CreditsUsed(now, msg.sender, _id, _bet); emit BetSuccess(now, msg.sender, _id, _bet, settings.curPayTableId); } function betFromGame(uint32 _id, bytes32 _hashCheck) public { bool _didFinalize = finalize(_id, _hashCheck); uint64 _bet = games[_id].bet; if (!_didFinalize) return _betFailure("Failed to finalize prior game.", _bet, false); betWithCredits(_bet); } // Logs an error, and optionally refunds user the _bet function _betFailure(string _msg, uint _bet, bool _doRefund) private { if (_doRefund) require(msg.sender.call.value(_bet)()); emit BetFailure(now, msg.sender, _bet, _msg); } // Resolves the initial hand (if possible) and sets the users draws. // Users cannot draw 0 cards. They should instead use finalize(). // // Notes: // - If user unable to resolve initial hand, sets draws to 5 // - This always sets game.dBlock // // Gas Cost: ~38k // - 23k: tx // - 13k: see _draw() // - 2k: SLOADs, execution function draw(uint32 _id, uint8 _draws, bytes32 _hashCheck) public { Game storage _game = games[_id]; address _user = userAddresses[_game.userId]; if (_game.iBlock == 0) return _drawFailure(_id, _draws, "Invalid game Id."); if (_user != msg.sender) return _drawFailure(_id, _draws, "This is not your game."); if (_game.iBlock == block.number) return _drawFailure(_id, _draws, "Initial cards not available."); if (_game.dBlock != 0) return _drawFailure(_id, _draws, "Cards already drawn."); if (_draws > 31) return _drawFailure(_id, _draws, "Invalid draws."); if (_draws == 0) return _drawFailure(_id, _draws, "Cannot draw 0 cards. Use finalize instead."); if (_game.handRank != HAND_UNDEFINED) return _drawFailure(_id, _draws, "Game already finalized."); _draw(_game, _id, _draws, _hashCheck); } function _drawFailure(uint32 _id, uint8 _draws, string _msg) private { emit DrawFailure(now, msg.sender, _id, _draws, _msg); } // Callable any time after the initial hand. Will assume // no draws if called directly after new hand. // // Gas Cost: 44k (loss), 59k (win, has credits), 72k (win, no credits) // - 22k: tx overhead // - 21k, 36k, 49k: see _finalize() // - 1k: SLOADs, execution function finalize(uint32 _id, bytes32 _hashCheck) public returns (bool _didFinalize) { Game storage _game = games[_id]; address _user = userAddresses[_game.userId]; if (_game.iBlock == 0) return _finalizeFailure(_id, "Invalid game Id."); if (_user != msg.sender) return _finalizeFailure(_id, "This is not your game."); if (_game.iBlock == block.number) return _finalizeFailure(_id, "Initial hand not avaiable."); if (_game.dBlock == block.number) return _finalizeFailure(_id, "Drawn cards not available."); if (_game.handRank != HAND_UNDEFINED) return _finalizeFailure(_id, "Game already finalized."); _finalize(_game, _id, _hashCheck); return true; } function _finalizeFailure(uint32 _id, string _msg) private returns (bool) { emit FinalizeFailure(now, msg.sender, _id, _msg); return false; } /************************************************************/ /****************** PRIVATE FUNCTIONS ***********************/ /************************************************************/ // Appends a PayTable to the mapping. // It ensures sane values. (Double the defaults) function _addPayTable( uint16 _rf, uint16 _sf, uint16 _fk, uint16 _fh, uint16 _fl, uint16 _st, uint16 _tk, uint16 _tp, uint16 _jb ) private { require(_rf<=1600 && _sf<=100 && _fk<=50 && _fh<=18 && _fl<=12 && _st<=8 && _tk<=6 && _tp<=4 && _jb<=2); uint16[12] memory _pt; _pt[HAND_UNDEFINED] = 0; _pt[HAND_RF] = _rf; _pt[HAND_SF] = _sf; _pt[HAND_FK] = _fk; _pt[HAND_FH] = _fh; _pt[HAND_FL] = _fl; _pt[HAND_ST] = _st; _pt[HAND_TK] = _tk; _pt[HAND_TP] = _tp; _pt[HAND_JB] = _jb; _pt[HAND_HC] = 0; _pt[HAND_NOT_COMPUTABLE] = 0; payTables[settings.numPayTables] = _pt; settings.numPayTables++; } // Increases totalCredits and credits[user] // Optionally increases totalWonGwei stat. function _creditUser(address _user, uint _amt, uint32 _gameId) private { if (_amt == 0) return; uint64 _incr = _gameId == 0 ? 0 : uint64(_amt / 1e9); uint88 _totalCredits = vars.totalCredits + uint88(_amt); uint64 _totalWonGwei = vars.totalWonGwei + _incr; vars.totalCredits = _totalCredits; vars.totalWonGwei = _totalWonGwei; credits[_user] += _amt; emit CreditsAdded(now, _user, _gameId, _amt); } // Lowers totalCredits and credits[user]. // Sends to user, using unlimited gas. function _uncreditUser(address _user, uint _amt) private { if (_amt > credits[_user] || _amt == 0) _amt = credits[_user]; if (_amt == 0) return; vars.totalCredits -= uint88(_amt); credits[_user] -= _amt; require(_user.call.value(_amt)()); emit CreditsCashedout(now, _user, _amt); } // Creates a new game with the specified bet and current PayTable. // Does no validation of the _bet size. // // Gas Cost: 26k, 66k // Overhead: // - 20k: 1 writes: Game // - 5k: 1 update: vars // - 1k: SLOAD, execution // New User: // - 40k: 2 writes: userIds, userAddresses // Repeat User: // - 0k: nothing extra function _createNewGame(uint64 _bet) private returns (uint32 _curId) { // get or create user id uint32 _curUserId = vars.curUserId; uint32 _userId = userIds[msg.sender]; if (_userId == 0) { _curUserId++; userIds[msg.sender] = _curUserId; userAddresses[_curUserId] = msg.sender; _userId = _curUserId; } // increment vars _curId = vars.curId + 1; uint64 _totalWagered = vars.totalWageredGwei + _bet / 1e9; vars.curId = _curId; vars.totalWageredGwei = _totalWagered; vars.curUserId = _curUserId; // save game uint16 _payTableId = settings.curPayTableId; Game storage _game = games[_curId]; _game.userId = _userId; _game.bet = _bet; _game.payTableId = _payTableId; _game.iBlock = uint32(block.number); return _curId; } // Gets initialHand, and stores .draws and .dBlock. // Gas Cost: 13k // - 3k: getHand() // - 5k: 1 update: iHand, draws, dBlock // - 3k: event: DrawSuccess // - 2k: SLOADs, other function _draw(Game storage _game, uint32 _id, uint8 _draws, bytes32 _hashCheck) private { // assert hand is not already drawn assert(_game.dBlock == 0); // Deal the initial hand, or set draws to 5. uint32 _iHand; bytes32 _iBlockHash = blockhash(_game.iBlock); uint8 _warnCode; if (_iBlockHash != 0) { // Ensure they are drawing against expected hand if (_iBlockHash != _hashCheck) { return _drawFailure(_id, _draws, "HashCheck Failed. Try refreshing game."); } _iHand = getHand(uint(keccak256(_iBlockHash, _id))); } else { _warnCode = WARN_IHAND_TIMEOUT; _draws = 31; } // update game _game.iHand = _iHand; _game.draws = _draws; _game.dBlock = uint32(block.number); emit DrawSuccess(now, msg.sender, _id, _game.iHand, _draws, _warnCode); } // Resolves game based on .iHand and .draws, crediting user on a win. // This always sets game.dHand and game.handRank. // // There are four possible scenarios: // User draws N cads, and dBlock is fresh: // - draw N cards into iHand, this is dHand // User draws N cards, and dBlock is too old: // - set dHand to iHand (note: iHand may be empty) // User draws 0 cards, and iBlock is fresh: // - draw 5 cards into iHand, set dHand to iHand // User draws 0 cards, and iBlock is too old: // - fail: set draws to 5, return. (user should call finalize again) // // Gas Cost: 21k loss, 36k win, 49k new win // - 6k: if draws > 0: drawToHand() // - 7k: getHandRank() // - 5k: 1 update: Game // - 2k: FinalizeSuccess // - 1k: SLOADs, execution // On Win: +13k, or +28k // - 5k: 1 updates: totalCredits, totalWon // - 5k or 20k: 1 update/write to credits[user] // - 2k: event: AccountCredited // - 1k: SLOADs, execution function _finalize(Game storage _game, uint32 _id, bytes32 _hashCheck) private { // Require game is not already finalized assert(_game.handRank == HAND_UNDEFINED); // Compute _dHand address _user = userAddresses[_game.userId]; bytes32 _blockhash; uint32 _dHand; uint32 _iHand; // set if draws are 0, and iBlock is fresh uint8 _warnCode; if (_game.draws != 0) { _blockhash = blockhash(_game.dBlock); if (_blockhash != 0) { // draw cards to iHand, use as dHand _dHand = drawToHand(uint(keccak256(_blockhash, _id)), _game.iHand, _game.draws); } else { // cannot draw any cards. use iHand. if (_game.iHand != 0){ _dHand = _game.iHand; _warnCode = WARN_DHAND_TIMEOUT; } else { _dHand = 0; _warnCode = WARN_BOTH_TIMEOUT; } } } else { _blockhash = blockhash(_game.iBlock); if (_blockhash != 0) { // ensure they are drawing against expected hand if (_blockhash != _hashCheck) { _finalizeFailure(_id, "HashCheck Failed. Try refreshing game."); return; } // draw 5 cards into iHand, use as dHand _iHand = getHand(uint(keccak256(_blockhash, _id))); _dHand = _iHand; } else { // can't finalize with iHand. Draw 5 cards. _finalizeFailure(_id, "Initial hand not available. Drawing 5 new cards."); _game.draws = 31; _game.dBlock = uint32(block.number); emit DrawSuccess(now, _user, _id, 0, 31, WARN_IHAND_TIMEOUT); return; } } // Compute _handRank. be sure dHand is not empty uint8 _handRank = _dHand == 0 ? uint8(HAND_NOT_COMPUTABLE) : uint8(getHandRank(_dHand)); // This only happens if draws==0, and iHand was drawable. if (_iHand > 0) _game.iHand = _iHand; // Always set dHand and handRank _game.dHand = _dHand; _game.handRank = _handRank; // Compute _payout, credit user, emit event. uint _payout = payTables[_game.payTableId][_handRank] * uint(_game.bet); if (_payout > 0) _creditUser(_user, _payout, _id); emit FinalizeSuccess(now, _user, _id, _game.dHand, _game.handRank, _payout, _warnCode); } /************************************************************/ /******************** PUBLIC VIEWS **************************/ /************************************************************/ // IMPLEMENTS: Bankrollable.getProfits() // Ensures contract always has at least bankroll + totalCredits. function getCollateral() public view returns (uint _amount) { return vars.totalCredits; } // IMPLEMENTS: Bankrollable.getWhitelistOwner() // Ensures contract always has at least bankroll + totalCredits. function getWhitelistOwner() public view returns (address _wlOwner) { return getAdmin(); } // Returns the largest bet such that we could pay out two RoyalFlushes. // The likelihood that two RoyalFlushes (with max bet size) are // won within a 255 block period is extremely low. function curMaxBet() public view returns (uint) { // Return largest bet such that RF*2*bet = bankrollable uint _maxPayout = payTables[settings.curPayTableId][HAND_RF] * 2; return bankrollAvailable() / _maxPayout; } // Return the less of settings.maxBet and curMaxBet() function effectiveMaxBet() public view returns (uint _amount) { uint _curMax = curMaxBet(); return _curMax > settings.maxBet ? settings.maxBet : _curMax; } function getPayTable(uint16 _payTableId) public view returns (uint16[12]) { require(_payTableId < settings.numPayTables); return payTables[_payTableId]; } function getCurPayTable() public view returns (uint16[12]) { return getPayTable(settings.curPayTableId); } // Gets the initial hand of a game. function getIHand(uint32 _id) public view returns (uint32) { Game memory _game = games[_id]; if (_game.iHand != 0) return _game.iHand; if (_game.iBlock == 0) return; bytes32 _iBlockHash = blockhash(_game.iBlock); if (_iBlockHash == 0) return; return getHand(uint(keccak256(_iBlockHash, _id))); } // Get the final hand of a game. // This will return iHand if there are no draws yet. function getDHand(uint32 _id) public view returns (uint32) { Game memory _game = games[_id]; if (_game.dHand != 0) return _game.dHand; if (_game.draws == 0) return _game.iHand; if (_game.dBlock == 0) return; bytes32 _dBlockHash = blockhash(_game.dBlock); if (_dBlockHash == 0) return _game.iHand; return drawToHand(uint(keccak256(_dBlockHash, _id)), _game.iHand, _game.draws); } // Returns the hand rank and payout of a Game. function getDHandRank(uint32 _id) public view returns (uint8) { uint32 _dHand = getDHand(_id); return _dHand == 0 ? uint8(HAND_NOT_COMPUTABLE) : uint8(getHandRank(_dHand)); } // Expose Vars ////////////////////////////////////// function curId() public view returns (uint32) { return vars.curId; } function totalWagered() public view returns (uint) { return uint(vars.totalWageredGwei) * 1e9; } function curUserId() public view returns (uint) { return uint(vars.curUserId); } function totalWon() public view returns (uint) { return uint(vars.totalWonGwei) * 1e9; } function totalCredits() public view returns (uint) { return vars.totalCredits; } ///////////////////////////////////////////////////// // Expose Settings ////////////////////////////////// function minBet() public view returns (uint) { return settings.minBet; } function maxBet() public view returns (uint) { return settings.maxBet; } function curPayTableId() public view returns (uint) { return settings.curPayTableId; } function numPayTables() public view returns (uint) { return settings.numPayTables; } ///////////////////////////////////////////////////// }
0x60806040526004361061026e5763ffffffff60e060020a60003504166301a413b981146102705780630c657eb01461029757806311610c25146102ac57806313ca1464146102b4578063148105ab146102e857806319eb691a146102f05780632100a5d9146103055780632500ec4a1461033f5780632b36a657146103765780632e5b21681461038b5780633b19e84a146103a05780633f073031146103b55780633fea1c2b146103bd5780634081db51146103db57806342d1f17f146103fc57806345279c81146104aa5780634949d9fa146104bf57806354fd4d50146104e057806356397c35146104f55780635ab1bd531461050a5780635acfefee1461051f5780635b40a584146105345780635c1548fb146105495780635c7b79f51461055e578063609f9a8e146105765780636c85c727146105975780636e9960c3146105f55780637280850e1461060a5780638020fb7714610628578063854b1cdf14610676578063893d20e81461068b5780638a14f12c146106a05780638ab1d681146106b55780638bb7819f146106d657806393e59dc1146106eb5780639619367d1461070057806396fd550a146107155780639f0f78ca14610737578063a3293c0e1461074c578063acca92e01461077f578063b3ff277d146107b4578063b41a6ce2146107c9578063b5bd3eb914610549578063b94371ec146107f7578063c6699ba81461080c578063cc69176314610859578063d47f269e14610880578063d5420df414610898578063da5d2fac146108bc578063e43252d714610941578063ec50361114610962578063ed9980a614610977578063f3f318531461098c578063fe5ff468146109a8575b005b34801561027c57600080fd5b506102856109c9565b60408051918252519081900360200190f35b3480156102a357600080fd5b50610285610a14565b61026e610a1a565b3480156102c057600080fd5b506102d263ffffffff60043516610b9e565b6040805160ff9092168252519081900360200190f35b61026e610bd0565b3480156102fc57600080fd5b50610285610e5a565b34801561031157600080fd5b5061032363ffffffff60043516610e77565b60408051600160a060020a039092168252519081900360200190f35b34801561034b57600080fd5b5061035d63ffffffff60043516610e92565b6040805163ffffffff9092168252519081900360200190f35b34801561038257600080fd5b50610285610ffd565b34801561039757600080fd5b50610285611024565b3480156103ac57600080fd5b50610323611040565b61026e611070565b3480156103c957600080fd5b5061035d63ffffffff6004351661107e565b3480156103e757600080fd5b5061035d600160a060020a03600435166111af565b34801561040857600080fd5b506104116111c7565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561045557818101518382015260200161043d565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561049457818101518382015260200161047c565b5050505090500194505050505060405180910390f35b3480156104b657600080fd5b506102856112fc565b3480156104cb57600080fd5b50610285600160a060020a0360043516611350565b3480156104ec57600080fd5b506102d26113ed565b34801561050157600080fd5b506103236113f2565b34801561051657600080fd5b50610323611401565b34801561052b57600080fd5b50610285611410565b34801561054057600080fd5b5061035d6114b5565b34801561055557600080fd5b506102856114c1565b34801561056a57600080fd5b5061026e6004356114e0565b34801561058257600080fd5b5061026e63ffffffff600435166024356114ed565b3480156105a357600080fd5b5060408051602060046024803582810135601f810185900485028601850190965285855261028595833595369560449491939091019190819084018382808284375094975061158d9650505050505050565b34801561060157600080fd5b50610323611807565b34801561061657600080fd5b5061028563ffffffff60043516611832565b34801561063457600080fd5b5061063d611b19565b604051808261018080838360005b8381101561066357818101518382015260200161064b565b5050505090500191505060405180910390f35b34801561068257600080fd5b50610285611b38565b34801561069757600080fd5b50610323611b49565b3480156106ac57600080fd5b50610285611bce565b3480156106c157600080fd5b5061026e600160a060020a0360043516611bec565b3480156106e257600080fd5b50610285611d04565b3480156106f757600080fd5b50610323611d4b565b34801561070c57600080fd5b50610285611d5a565b34801561072157600080fd5b5061026e67ffffffffffffffff60043516611d6a565b34801561074357600080fd5b50610285612045565b34801561075857600080fd5b5061076a63ffffffff60043516612058565b60405181518152808260a0808383602061064b565b34801561078b57600080fd5b506107a063ffffffff600435166024356120ae565b604080519115158252519081900360200190f35b3480156107c057600080fd5b506102856122a7565b3480156107d557600080fd5b5061026e67ffffffffffffffff6004358116906024351660ff604435166122bd565b34801561080357600080fd5b506103236123cd565b34801561081857600080fd5b5061026e61ffff60043581169060243581169060443581169060643581169060843581169060a43581169060c43581169060e43581169061010435166123d7565b34801561086557600080fd5b5061026e63ffffffff6004351660ff602435166044356124f0565b34801561088c57600080fd5b5061035d6004356127a1565b3480156108a457600080fd5b5061035d60043563ffffffff602435166044356127b6565b3480156108c857600080fd5b506108da63ffffffff60043516612887565b6040805163ffffffff9a8b16815267ffffffffffffffff90991660208a015261ffff909716888801529488166060880152928716608087015260ff91821660a0870152861660c0860152941660e08401529092166101008201529051908190036101200190f35b34801561094d57600080fd5b5061026e600160a060020a0360043516612908565b34801561096e57600080fd5b50610285612a20565b34801561098357600080fd5b50610285612a26565b34801561099857600080fd5b5061063d61ffff60043516612a37565b3480156109b457600080fd5b50610285600160a060020a0360043516612ac9565b600354600090600160a060020a0330163190826109e46114c1565b90508083116109f65760009350610a0e565b818101831015610a0a578083039350610a0e565b8193505b50505090565b60035481565b600554349060009068010000000000000000900467ffffffffffffffff16821115610a8557610a806040805190810160405280600e81526020017f42657420746f6f206c617267652e000000000000000000000000000000000000815250836001612adb565b610b9a565b60055467ffffffffffffffff16821015610ada57610a806040805190810160405280600e81526020017f42657420746f6f20736d616c6c2e000000000000000000000000000000000000815250836001612adb565b610ae2611d04565b821115610b2a57610a806040805190810160405280601881526020017f5468652062616e6b726f6c6c20697320746f6f206c6f772e0000000000000000815250836001612adb565b610b3382612bc1565b600554604080514281526020810186905261ffff608060020a90930492909216828201525191925063ffffffff831691600160a060020a033316917f12b9199c6d155759e1d7f4f5c031e9ed900ea5b210b38475e7f1456d8ef03393919081900360600190a35b5050565b600080610baa83610e92565b905063ffffffff811615610bc657610bc181611832565b610bc9565b600b5b9392505050565b60048054604080517f949d225d0000000000000000000000000000000000000000000000000000000081529051600160a060020a039092169263949d225d9282820192602092908290030181600087803b158015610c2d57600080fd5b505af1158015610c41573d6000803e3d6000fd5b505050506040513d6020811015610c5757600080fd5b50511580610cf9575060048054604080517f21887c3d000000000000000000000000000000000000000000000000000000008152600160a060020a0333811694820194909452905192909116916321887c3d916024808201926020929091908290030181600087803b158015610ccc57600080fd5b505af1158015610ce0573d6000803e3d6000fd5b505050506040513d6020811015610cf657600080fd5b50515b1515610d0457600080fd5b600254604080517ff5d82b6b000000000000000000000000000000000000000000000000000000008152600160a060020a0333811660048301523460248301529151919092169163f5d82b6b91604480830192600092919082900301818387803b158015610d7157600080fd5b505af1158015610d85573d6000803e3d6000fd5b50505050600260009054906101000a9004600160a060020a0316600160a060020a0316632ddbd13a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610ddc57600080fd5b505af1158015610df0573d6000803e3d6000fd5b505050506040513d6020811015610e0657600080fd5b50516003819055604080514281523460208201528082019290925251600160a060020a033316917f160f75e2b6a3d77c89deda80a60c72ad72cd9f540d023e7fdf6317aecddb68db919081900360600190a2565b6006546c01000000000000000000000000900463ffffffff165b90565b600b60205260009081526040902054600160a060020a031681565b6000610e9c613a41565b5063ffffffff80831660009081526008602090815260408083208151610120810183529054808616825267ffffffffffffffff6401000000008204169382019390935261ffff6c0100000000000000000000000084041691810191909152607060020a820484166060820152609060020a82048416608082015260ff60b060020a8304811660a083015260b860020a8304851660c083015260d860020a830490941660e0820181905260f860020a90920490931661010084015215610f67578160e001519250610ff6565b60a082015160ff161515610f815781608001519250610ff6565b60c082015163ffffffff161515610f9757610ff6565b5060c081015163ffffffff1640801515610fb75781608001519250610ff6565b6040805182815260e060020a63ffffffff87160260208201529051908190036024019020608083015160a0840151610ff392919060ff166127b6565b92505b5050919050565b6000600160a060020a03301631816110136114c1565b60035401905080820392505b505090565b60055468010000000000000000900467ffffffffffffffff1690565b600061106b7f5452454153555259000000000000000000000000000000000000000000000000612d67565b905090565b61107c33346000612dce565b565b6000611088613a41565b5063ffffffff80831660009081526008602090815260408083208151610120810183529054808616825267ffffffffffffffff6401000000008204169382019390935261ffff6c0100000000000000000000000084041691810191909152607060020a820484166060820152609060020a820484166080820181905260ff60b060020a8404811660a084015260b860020a8404861660c084015260d860020a840490951660e083015260f860020a909204909316610100840152156111535781608001519250610ff6565b606082015163ffffffff16151561116957610ff6565b50606081015163ffffffff164080151561118257610ff6565b6040805182815260e060020a63ffffffff87160260208201529051908190036024019020610ff3906127a1565b600a6020526000908152604090205463ffffffff1681565b606080600260009054906101000a9004600160a060020a0316600160a060020a0316637bb98a686040518163ffffffff1660e060020a028152600401600060405180830381600087803b15801561121d57600080fd5b505af1158015611231573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561125a57600080fd5b81019080805164010000000081111561127257600080fd5b8201602081018481111561128557600080fd5b81518560208202830111640100000000821117156112a257600080fd5b505092919060200180516401000000008111156112be57600080fd5b820160208101848111156112d157600080fd5b81518560208202830111640100000000821117156112ee57600080fd5b509496509450505050509091565b600080611307611d04565b60055490915068010000000000000000900467ffffffffffffffff16811161132f5780611349565b60055468010000000000000000900467ffffffffffffffff165b91505b5090565b600254604080517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a038481166004830152915160009392909216916370a082319160248082019260209290919082900301818787803b1580156113bb57600080fd5b505af11580156113cf573d6000803e3d6000fd5b505050506040513d60208110156113e557600080fd5b505192915050565b600281565b600254600160a060020a031681565b600054600160a060020a031690565b600080600061141d610ffd565b91506000821361142c5761101f565b60018054830190559091508190611441611040565b905080600160a060020a03168360405160006040518083038185875af192505050151561146d57600080fd5b60408051428152602081018590528151600160a060020a038416927f6930d0e66bafb5f81d786f05b526422c3839d434d99a531eb4b2e4a535348165928290030190a2505090565b60065463ffffffff1690565b6007546801000000000000000090046affffffffffffffffffffff1690565b6114ea3382612ecd565b50565b6000806114fa84846120ae565b63ffffffff8516600090815260086020526040902054909250640100000000900467ffffffffffffffff16905081151561157e576115796040805190810160405280601e81526020017f4661696c656420746f2066696e616c697a65207072696f722067616d652e00008152508267ffffffffffffffff166000612adb565b611587565b61158781611d6a565b50505050565b6000338180808061159c6114c1565b935030600160a060020a03163192508383116115b95760006115bd565b8383035b9150818811156115cb578197505b600254604080517f68c6b11a000000000000000000000000000000000000000000000000000000008152600160a060020a038881166004830152602482018c9052915191909216916368c6b11a9160448083019260209291908290030181600087803b15801561163a57600080fd5b505af115801561164e573d6000803e3d6000fd5b505050506040513d602081101561166457600080fd5b5051600254604080517f2ddbd13a0000000000000000000000000000000000000000000000000000000081529051929a50600160a060020a0390911691632ddbd13a916004808201926020929091908290030181600087803b1580156116c957600080fd5b505af11580156116dd573d6000803e3d6000fd5b505050506040513d60208110156116f357600080fd5b5051600355871515611704576117fc565b866040518082805190602001908083835b602083106117345780518252601f199092019160209182019101611715565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020905084600160a060020a0316888260e060020a9004906040518263ffffffff1660e060020a02815260040160006040518083038185885af1935050505015156117a957600080fd5b60035460408051428152602081018b90528082019290925251600160a060020a038716917fe247ca1cc083b13e9e81a5d9f83c08e1be5369c7c6f12637cb0bf63d9d5b29f6919081900360600190a28795505b505050505092915050565b600061106b7f41444d494e000000000000000000000000000000000000000000000000000000612d67565b6000806060808280808080808080808063ffffffff8f16151561185857600b9d50611b07565b60408051600d8082526101c0820190925290602082016101a080388339505060408051600580825260c08201909252929e5090506020820160a080388339019050509a506064985060009750600092505b60058310156119fa576118c28f63ffffffff1684612fde565b9c5060338d11156118d657600b9d50611b07565b600d8d0691508b828151811015156118ea57fe5b602090810290910101805160010190528a600d8e0481518110151561190b57fe5b602090810290910101805160010190528a600d8e0481518110151561192c57fe5b906020019060200201516005141561194357600194505b811515611953576001935061196b565b8882101561195f578198505b8782111561196b578197505b8b8281518110151561197957fe5b90602001906020020151600214156119a157861515611996578199505b6001909601956119ef565b8b828151811015156119af57fe5b90602001906020020151600314156119ca57600395506119ef565b8b828151811015156119d857fe5b90602001906020020151600414156119ef57600495505b6001909201916118a9565b6000871115611a87578560041415611a155760039d50611b07565b856003148015611a255750866002145b15611a335760049d50611b07565b8560031415611a455760079d50611b07565b8660021415611a575760089d50611b07565b866001148015611a705750600a8a101580611a70575089155b15611a7e5760099d50611b07565b600a9d50611b07565b83611a9757888803600414611aa6565b8760041480611aa65750886009145b9050808015611ab25750845b8015611abe5750886009145b15611acc5760019d50611b07565b808015611ad65750845b15611ae45760029d50611b07565b8415611af35760059d50611b07565b8015611b025760069d50611b07565b600a9d505b50505050505050505050505050919050565b611b21613a8d565b60055461106b90608060020a900461ffff16612a37565b600554608060020a900461ffff1690565b60008060009054906101000a9004600160a060020a0316600160a060020a0316638da5cb5b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015611b9d57600080fd5b505af1158015611bb1573d6000803e3d6000fd5b505050506040513d6020811015611bc757600080fd5b5051905090565b600654640100000000900467ffffffffffffffff16633b9aca000290565b6000611bf66123cd565b600160a060020a031633600160a060020a0316141515611c1557600080fd5b60048054604080517f29092d0e000000000000000000000000000000000000000000000000000000008152600160a060020a0386811694820194909452905192909116916329092d0e916024808201926020929091908290030181600087803b158015611c8157600080fd5b505af1158015611c95573d6000803e3d6000fd5b505050506040513d6020811015611cab57600080fd5b505190508015610b9a5733600160a060020a031682600160a060020a03167fe64bfe936314bda02a76de6d787876f31f93470b24b68a9a2ceaa07fb609f392426040518082815260200191505060405180910390a35050565b60055461ffff608060020a90910481166000908152600c602052604081205490916201000090910481166002021680611d3b6109c9565b811515611d4457fe5b0491505090565b600454600160a060020a031681565b60055467ffffffffffffffff1690565b60055460009067ffffffffffffffff6801000000000000000090910481169083161115611ddc57610a806040805190810160405280600e81526020017f42657420746f6f206c617267652e0000000000000000000000000000000000008152508367ffffffffffffffff166000612adb565b60055467ffffffffffffffff9081169083161015611e3f57610a806040805190810160405280600e81526020017f42657420746f6f20736d616c6c2e0000000000000000000000000000000000008152508367ffffffffffffffff166000612adb565b611e47611d04565b8267ffffffffffffffff161115611ea357610a806040805190810160405280601881526020017f5468652062616e6b726f6c6c20697320746f6f206c6f772e00000000000000008152508367ffffffffffffffff166000612adb565b600160a060020a03331660009081526009602052604090205467ffffffffffffffff83161115611f1857610a806040805190810160405280601481526020017f496e73756666696369656e7420637265646974730000000000000000000000008152508367ffffffffffffffff166000612adb565b611f2182612bc1565b6007805472ffffffffffffffffffffff000000000000000019811667ffffffffffffffff861668010000000000000000928390046affffffffffffffffffffff908116829003169092021790915533600160a060020a031660008181526009602090815260409182902080548590039055815142815290810193909352805193945063ffffffff85169391927f319d155b1caa4fddb433c692c929ea27c83e6a83da54b51d8b8c9847238c5294929081900390910190a36005546040805142815267ffffffffffffffff85166020820152608060020a90920461ffff16828201525163ffffffff83169133600160a060020a0316917f12b9199c6d155759e1d7f4f5c031e9ed900ea5b210b38475e7f1456d8ef03393916060908290030190a35050565b600061204f610ffd565b60015401905090565b612060613aad565b6000805b6005811015610ff6576006810260020a603f8102925084831663ffffffff1681151561208c57fe5b0483826005811061209957fe5b60ff9092166020929092020152600101612064565b63ffffffff808316600090815260086020908152604080832080548086168552600b9093529083205492939092600160a060020a031691607060020a900416151561213957612132856040805190810160405280601081526020017f496e76616c69642067616d652049642e00000000000000000000000000000000815250613002565b925061229f565b33600160a060020a031681600160a060020a031614151561219357612132856040805190810160405280601681526020017f54686973206973206e6f7420796f75722067616d652e00000000000000000000815250613002565b815463ffffffff607060020a909104164314156121e957612132856040805190810160405280601a81526020017f496e697469616c2068616e64206e6f74206176616961626c652e000000000000815250613002565b815463ffffffff60b860020a9091041643141561223f57612132856040805190810160405280601a81526020017f447261776e206361726473206e6f7420617661696c61626c652e000000000000815250613002565b815460f860020a900460ff161561228f57612132856040805190810160405280601781526020017f47616d6520616c72656164792066696e616c697a65642e000000000000000000815250613002565b61229a8286866130bf565b600192505b505092915050565b60075467ffffffffffffffff16633b9aca000290565b6122c5611807565b600160a060020a031633600160a060020a03161415156122e457600080fd5b67053444835ec5800067ffffffffffffffff8316111561230357600080fd5b600554609060020a900461ffff1660ff82161061231f57600080fd5b6005805467ffffffffffffffff191667ffffffffffffffff858116919091176fffffffffffffffff0000000000000000191668010000000000000000918516919091021771ffff00000000000000000000000000000000191660ff8316608060020a021790556040805142815233600160a060020a0316602082015281517f1da3087dd1a739b3a686c91e6fadfbea4d3a88345fae920dcd4e65c920e29a88929181900390910190a1505050565b600061106b611807565b60006123e1611807565b600160a060020a031633600160a060020a031614151561240057600080fd5b506005546201518042049063ffffffff80831674010000000000000000000000000000000000000000909204161061243757600080fd5b6005805477ffffffff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000063ffffffff8416021790556124888a8a8a8a8a8a8a8a8a613563565b60055460408051428152600160a060020a033316602082015260001961ffff609060020a90940484160190921682820152517fc151d2fd11066f5c29b943a5f2bc7811d4d4162098b3009f54c2ca78e98f1c359181900360600190a150505050505050505050565b63ffffffff808416600090815260086020908152604080832080548086168552600b9093529220549192600160a060020a0390921691607060020a90910416151561257a5761257585856040805190810160405280601081526020017f496e76616c69642067616d652049642e000000000000000000000000000000008152506136d6565b61279a565b33600160a060020a031681600160a060020a03161415156125d55761257585856040805190810160405280601681526020017f54686973206973206e6f7420796f75722067616d652e000000000000000000008152506136d6565b815463ffffffff607060020a9091041643141561262c5761257585856040805190810160405280601c81526020017f496e697469616c206361726473206e6f7420617661696c61626c652e000000008152506136d6565b815460b860020a900463ffffffff16156126805761257585856040805190810160405280601481526020017f436172647320616c726561647920647261776e2e0000000000000000000000008152506136d6565b601f8460ff1611156126cc5761257585856040805190810160405280600e81526020017f496e76616c69642064726177732e0000000000000000000000000000000000008152506136d6565b60ff8416151561273d576125758585606060405190810160405280602a81526020017f43616e6e6f74206472617720302063617264732e205573652066696e616c697a81526020017f6520696e73746561642e000000000000000000000000000000000000000000008152506136d6565b815460f860020a900460ff161561278e5761257585856040805190810160405280601781526020017f47616d6520616c72656164792066696e616c697a65642e0000000000000000008152506136d6565b61279a8286868661379b565b5050505050565b60006127b0826005600061396c565b92915050565b600080808080601f8611156127c757fe5b63ffffffff87161515806127db575085601f145b15156127e357fe5b8515156127f25786945061287c565b85601f14156128165761280f88600561280a8a6139dd565b61396c565b945061287c565b600092505b6005831015612851578260020a86166000141561283757612846565b8260060260020a603f02841793505b60019092019161281b565b8319637fffffff16915061286a88600561280a8a6139dd565b841663ffffffff838916161794508490505b505050509392505050565b60086020526000908152604090205463ffffffff8082169167ffffffffffffffff6401000000008204169161ffff6c0100000000000000000000000083041691607060020a8104821691609060020a820481169160ff60b060020a820481169260b860020a830481169260d860020a81049091169160f860020a9091041689565b60006129126123cd565b600160a060020a031633600160a060020a031614151561293157600080fd5b60048054604080517f0a3b0a4f000000000000000000000000000000000000000000000000000000008152600160a060020a038681169482019490945290519290911691630a3b0a4f916024808201926020929091908290030181600087803b15801561299d57600080fd5b505af11580156129b1573d6000803e3d6000fd5b505050506040513d60208110156129c757600080fd5b505190508015610b9a5733600160a060020a031682600160a060020a03167f36794b07b1dabd3b5763df32ac01b7ab16f470ac57e87b63d0d4c1e40efdbf47426040518082815260200191505060405180910390a35050565b60015481565b600554609060020a900461ffff1690565b612a3f613a8d565b60055461ffff609060020a909104811690831610612a5c57600080fd5b61ffff82166000908152600c60208190526040808320815161018081019283905293909291908390855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411612a86575094979650505050505050565b60096020526000908152604090205481565b8015612b0957604051600160a060020a033316908390600081818185875af1925050501515612b0957600080fd5b33600160a060020a03167f38b6fed49e5857eec3c089ce663a4064b021b4ab48e164cddd63177c7685a2a14284866040518084815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612b80578181015183820152602001612b68565b50505050905090810190601f168015612bad5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a2505050565b600654600160a060020a0333166000908152600a6020526040812054909163ffffffff6c0100000000000000000000000090910481169116828080831515612c6657600160a060020a0333166000818152600a60209081526040808320805463ffffffff6001909b019a8b1663ffffffff1990911681179091558352600b9091529020805473ffffffffffffffffffffffffffffffffffffffff191690911790558493505b50506006805463ffffffff19808216600163ffffffff808516919091018082169283176bffffffffffffffff0000000019908116633b9aca0067ffffffffffffffff9d8e16908104640100000000988990048f1601909d168702176fffffffff00000000000000000000000019166c010000000000000000000000009a84168b021790965560055460009384526008602052604090932080549094169782169790971790941692909802919091176dffff0000000000000000000000001916608060020a90970461ffff169094029590951771ffffffff00000000000000000000000000001916607060020a43909616959095029490941790915592915050565b60008054604080517fbb34534c000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a039092169163bb34534c9160248082019260209290919082900301818787803b1580156113bb57600080fd5b60008080841515612dde57612ec5565b63ffffffff841615612df657633b9aca008504612df9565b60005b6007805467ffffffffffffffff808216840190811667ffffffffffffffff196affffffffffffffffffffff6801000000000000000080860482168d019182160272ffffffffffffffffffffff000000000000000019909516949094171617909255600160a060020a03891660008181526009602090815260409182902080548c01905581514281529081018b9052815195985092965092945063ffffffff88169390927f4e8cf3f0c5d8f7d35d109e7015348cbeb93094df121b4580598480d06066410b928290030190a35b505050505050565b600160a060020a038216600090815260096020526040902054811180612ef1575080155b15612f115750600160a060020a0381166000908152600960205260409020545b801515612f1d57610b9a565b600780546affffffffffffffffffffff6801000000000000000080830482168590039091160272ffffffffffffffffffffff000000000000000019909116179055600160a060020a0382166000818152600960205260408082208054859003905551839181818185875af1925050501515612f9757600080fd5b60408051428152602081018390528151600160a060020a038516927ff726a786741417cb817896860b979c3bddf4bda01575b4482efb4bb685c6baee928290030190a25050565b60006006820260020a603f818181028616811515612ff857fe5b0495945050505050565b60008263ffffffff1633600160a060020a03167f1c8fefb714208502f1a915e3a0fb01c204268cf90a0eed42cf081650c91e131742856040518083815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561307b578181015183820152602001613063565b50505050905090810190601f1680156130a85780820380516001836020036101000a031916815260200191505b50935050505060405180910390a350600092915050565b825460009081908190819081908190819060f860020a900460ff16156130e157fe5b895463ffffffff81166000908152600b6020526040902054600160a060020a0316975060b060020a900460ff16156131b457895460b860020a900463ffffffff164095508515613178576040805187815263ffffffff8b811660e060020a02602083015291516024918190039190910190208b5461317192609060020a8204169060b060020a900460ff166127b6565b94506131af565b8954609060020a900463ffffffff16156131a6578954609060020a900463ffffffff169450600292506131af565b60009450600392505b6133a7565b8954607060020a900463ffffffff1640955085156132765785881461323f5761323989606060405190810160405280602681526020017f48617368436865636b204661696c65642e205472792072656672657368696e6781526020017f2067616d652e0000000000000000000000000000000000000000000000000000815250613002565b50613557565b6040805187815260e060020a63ffffffff8c16026020820152905190819003602401902061326c906127a1565b93508394506133a7565b6132dc89606060405190810160405280603081526020017f496e697469616c2068616e64206e6f7420617661696c61626c652e204472617781526020017f696e672035206e65772063617264732e00000000000000000000000000000000815250613002565b50895476ff000000000000000000000000000000000000000000001916761f00000000000000000000000000000000000000000000177affffffff0000000000000000000000000000000000000000000000191660b860020a4363ffffffff90811691909102919091178b556040805142815260006020820152601f81830152600160608201529051918b1691600160a060020a038a16917f5de8219970cf1855f1b8ccfe2f57fb5579fd91696de0e60b6ef6e47475b59f43916080918190039190910190a3613557565b63ffffffff8516156133c1576133bc85611832565b6133c4565b600b5b915060008463ffffffff16111561340157895475ffffffff0000000000000000000000000000000000001916609060020a63ffffffff861602178a555b89547fff00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffff1660d860020a63ffffffff871602177effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660f860020a60ff841690810291909117808c556c01000000000000000000000000810461ffff166000908152600c6020819052604090912064010000000090920467ffffffffffffffff16929081106134a957fe5b601091828204019190066002029054906101000a900461ffff1661ffff1602905060008111156134de576134de87828b612dce565b89546040805142815260d860020a830463ffffffff908116602083015260ff60f860020a9094048416828401526060820185905292861660808201529051918b1691600160a060020a038a16917f018ef872420a53b47435588a5d67be6000b1c368eabc03049066ba29ad967c76919081900360a00190a35b50505050505050505050565b61356b613a8d565b6106408a61ffff1611158015613586575060648961ffff1611155b8015613597575060328861ffff1611155b80156135a8575060128761ffff1611155b80156135b95750600c8661ffff1611155b80156135ca575060088561ffff1611155b80156135db575060068461ffff1611155b80156135ec575060048361ffff1611155b80156135fd575060028261ffff1611155b151561360857600080fd5b600080825261ffff8b81166020808501919091528b82166040808601919091528b831660608601528a8316608086015289831660a086015288831660c086015287831660e086015286831661010086015285831661012086015261014085018490526101608501849052600554609060020a90049092168352600c908190529120613694918390613acc565b505060058054600161ffff609060020a808404821692909201160273ffff00000000000000000000000000000000000019909116179055505050505050505050565b8263ffffffff1633600160a060020a03167f4223ca7d6c37a824c716bcea67d6cd07f359bfe2173713e97e60a893baa7a0dc428585604051808481526020018360ff1660ff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561375a578181015183820152602001613742565b50505050905090810190601f1680156137875780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a3505050565b83546000908190819060b860020a900463ffffffff16156137b857fe5b8654607060020a900463ffffffff164091508115613877578184146138435761383e8686606060405190810160405280602681526020017f48617368436865636b204661696c65642e205472792072656672657368696e6781526020017f2067616d652e00000000000000000000000000000000000000000000000000008152506136d6565b613963565b6040805183815260e060020a63ffffffff89160260208201529051908190036024019020613870906127a1565b925061387f565b50601f935060015b865475ffffffff0000000000000000000000000000000000001916609060020a63ffffffff85811682029290921776ff00000000000000000000000000000000000000000000191660b060020a60ff898116918202929092177affffffff0000000000000000000000000000000000000000000000191660b860020a4386160217808c55604080514281529490910485166020850152838101919091529084166060830152519188169133600160a060020a0316917f5de8219970cf1855f1b8ccfe2f57fb5579fd91696de0e60b6ef6e47475b59f43916080918190039190910190a35b50505050505050565b600080808085151561397d576139d3565b600092505b505060348506600281900a84811615156139bb57938417936006830260020a82029390931792600190920191858314156139bb576139d3565b60408051978852519687900360200190962095613982565b5050509392505050565b600080808063ffffffff851615156139f85760009350613a39565b5060005b6005811015613a39576006810260020a603f8102935063ffffffff86851616811515613a2457fe5b04600281900a949094179391506001016139fc565b505050919050565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b61018060405190810160405280600c906020820280388339509192915050565b60a0604051908101604052806005906020820280388339509192915050565b600183019183908215613b525791602002820160005b83821115613b2257835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302613ae2565b8015613b505782816101000a81549061ffff0219169055600201602081600101049283019260010302613b22565b505b5061134c92610e749250905b8082111561134c57805461ffff19168155600101613b5e5600a165627a7a723058200f5cc22a5e24af0d745887ab53349d299b815c565830a0854ebe2c3c9483c09f0029
{"success": true, "error": null, "results": {"detectors": [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reused-constructor", "impact": "Medium", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reused-constructor', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2575, 2581, 2278, 17788, 2546, 2629, 2050, 2692, 3207, 2629, 19797, 2278, 2509, 2278, 2683, 2094, 2575, 2620, 2581, 8586, 14142, 21619, 2278, 2581, 2497, 16068, 17788, 2475, 2546, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 1013, 1013, 16770, 1024, 1013, 1013, 7479, 1012, 10647, 11031, 2121, 1012, 4012, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 2478, 15584, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 3957, 1996, 1999, 5886, 3436, 3206, 3229, 2000, 1024, 1012, 4769, 11253, 1006, 27507, 16703, 1007, 1024, 5651, 2783, 4769, 17715, 2000, 1996, 2171, 1012, 1031, 16913, 18095, 1033, 1012, 2013, 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,910
0x9796bcece6b6032deb6f097b6f1cc180ae974fec
/** * See you on the Moon * * Token name : Gangster Inu * Supply: 1,000,000,000 * Decimal place: 18 * Symbol : GANGSINU */ // File: @openzeppelin/contracts/utils/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { 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() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public pure 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 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 onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @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/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, Ownable, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; /** * @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() { _name = "Gangster Inu"; _symbol = "GANGSINU"; _decimals = 18; _totalSupply = 1000000000 * 10**18; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @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); _mint(spender, addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol pragma solidity ^0.8.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063a457c2d711610066578063a457c2d71461024f578063a9059cbb1461027f578063dd62ed3e146102af578063f2fde38b146102df576100ea565b8063715018a6146102095780638da5cb5b1461021357806395d89b4114610231576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f76102fb565b60405161010491906113a0565b60405180910390f35b6101276004803603810190610122919061115b565b61038d565b6040516101349190611385565b60405180910390f35b6101456103ab565b6040516101529190611502565b60405180910390f35b6101756004803603810190610170919061110c565b6103b5565b6040516101829190611385565b60405180910390f35b6101936104b6565b6040516101a0919061151d565b60405180910390f35b6101c360048036038101906101be919061115b565b6104bf565b6040516101d09190611385565b60405180910390f35b6101f360048036038101906101ee91906110a7565b610575565b6040516102009190611502565b60405180910390f35b6102116105be565b005b61021b6106d0565b604051610228919061136a565b60405180910390f35b6102396106d5565b60405161024691906113a0565b60405180910390f35b6102696004803603810190610264919061115b565b610767565b6040516102769190611385565b60405180910390f35b6102996004803603810190610294919061115b565b61085b565b6040516102a69190611385565b60405180910390f35b6102c960048036038101906102c491906110d0565b610879565b6040516102d69190611502565b60405180910390f35b6102f960048036038101906102f491906110a7565b610900565b005b60606006805461030a90611666565b80601f016020809104026020016040519081016040528092919081815260200182805461033690611666565b80156103835780601f1061035857610100808354040283529160200191610383565b820191906000526020600020905b81548152906001019060200180831161036657829003601f168201915b5050505050905090565b60006103a161039a6109a1565b84846109a9565b6001905092915050565b6000600354905090565b60006103c2848484610b74565b6000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061040d6109a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561048d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048490611442565b60405180910390fd5b6104aa856104996109a1565b85846104a591906115aa565b6109a9565b60019150509392505050565b60006012905090565b60006105616104cc6109a1565b8484600260006104da6109a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461055c9190611554565b6109a9565b61056b8383610df6565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105c66109a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610653576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064a90611462565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b600090565b6060600580546106e490611666565b80601f016020809104026020016040519081016040528092919081815260200182805461071090611666565b801561075d5780601f106107325761010080835404028352916020019161075d565b820191906000526020600020905b81548152906001019060200180831161074057829003601f168201915b5050505050905090565b600080600260006107766109a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610833576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a906114c2565b60405180910390fd5b61085061083e6109a1565b85858461084b91906115aa565b6109a9565b600191505092915050565b600061086f6108686109a1565b8484610b74565b6001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6109086109a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610995576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098c90611462565b60405180910390fd5b61099e81610f4b565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906114a2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8090611402565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610b679190611502565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610be4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdb90611482565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4b906113c2565b60405180910390fd5b610c5f838383611078565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610ce6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdd90611422565b60405180910390fd5b8181610cf291906115aa565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d849190611554565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610de89190611502565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e66576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5d906114e2565b60405180910390fd5b610e7260008383611078565b8060036000828254610e849190611554565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610eda9190611554565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610f3f9190611502565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610fbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb2906113e2565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b505050565b60008135905061108c816119d1565b92915050565b6000813590506110a1816119e8565b92915050565b6000602082840312156110b957600080fd5b60006110c78482850161107d565b91505092915050565b600080604083850312156110e357600080fd5b60006110f18582860161107d565b92505060206111028582860161107d565b9150509250929050565b60008060006060848603121561112157600080fd5b600061112f8682870161107d565b93505060206111408682870161107d565b925050604061115186828701611092565b9150509250925092565b6000806040838503121561116e57600080fd5b600061117c8582860161107d565b925050602061118d85828601611092565b9150509250929050565b6111a0816115de565b82525050565b6111af816115f0565b82525050565b60006111c082611538565b6111ca8185611543565b93506111da818560208601611633565b6111e3816116f6565b840191505092915050565b60006111fb602383611543565b915061120682611707565b604082019050919050565b600061121e602683611543565b915061122982611756565b604082019050919050565b6000611241602283611543565b915061124c826117a5565b604082019050919050565b6000611264602683611543565b915061126f826117f4565b604082019050919050565b6000611287602883611543565b915061129282611843565b604082019050919050565b60006112aa602083611543565b91506112b582611892565b602082019050919050565b60006112cd602583611543565b91506112d8826118bb565b604082019050919050565b60006112f0602483611543565b91506112fb8261190a565b604082019050919050565b6000611313602583611543565b915061131e82611959565b604082019050919050565b6000611336601f83611543565b9150611341826119a8565b602082019050919050565b6113558161161c565b82525050565b61136481611626565b82525050565b600060208201905061137f6000830184611197565b92915050565b600060208201905061139a60008301846111a6565b92915050565b600060208201905081810360008301526113ba81846111b5565b905092915050565b600060208201905081810360008301526113db816111ee565b9050919050565b600060208201905081810360008301526113fb81611211565b9050919050565b6000602082019050818103600083015261141b81611234565b9050919050565b6000602082019050818103600083015261143b81611257565b9050919050565b6000602082019050818103600083015261145b8161127a565b9050919050565b6000602082019050818103600083015261147b8161129d565b9050919050565b6000602082019050818103600083015261149b816112c0565b9050919050565b600060208201905081810360008301526114bb816112e3565b9050919050565b600060208201905081810360008301526114db81611306565b9050919050565b600060208201905081810360008301526114fb81611329565b9050919050565b6000602082019050611517600083018461134c565b92915050565b6000602082019050611532600083018461135b565b92915050565b600081519050919050565b600082825260208201905092915050565b600061155f8261161c565b915061156a8361161c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561159f5761159e611698565b5b828201905092915050565b60006115b58261161c565b91506115c08361161c565b9250828210156115d3576115d2611698565b5b828203905092915050565b60006115e9826115fc565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611651578082015181840152602081019050611636565b83811115611660576000848401525b50505050565b6000600282049050600182168061167e57607f821691505b60208210811415611692576116916116c7565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6119da816115de565b81146119e557600080fd5b50565b6119f18161161c565b81146119fc57600080fd5b5056fea26469706673582212207a9845e1f15c72bf5e6842af84b6751f6937d1951c3954e2977dfe282b772a1d64736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2575, 9818, 26005, 2575, 2497, 16086, 16703, 3207, 2497, 2575, 2546, 2692, 2683, 2581, 2497, 2575, 2546, 2487, 9468, 15136, 2692, 6679, 2683, 2581, 2549, 7959, 2278, 1013, 1008, 1008, 1008, 2156, 2017, 2006, 1996, 4231, 1008, 1008, 19204, 2171, 1024, 20067, 1999, 2226, 1008, 4425, 1024, 1015, 1010, 2199, 1010, 2199, 1010, 2199, 1008, 26066, 2173, 1024, 2324, 1008, 6454, 1024, 18542, 2378, 2226, 1008, 1013, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 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,911
0x9796cd91e3bad850a9897ea3f6fcb7a6dfbd05ab
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Rain Water Series By Brooke Dahl /// @author: manifold.xyz import "./ERC721Creator.sol"; ///////////////////////////////////////////////// // // // // // ^ ^ ^ ^ // // /^\ /^\ |》》》》 /^\ /^\ // // // \v/ \\ |》》》》 // \v/ \\ // // |[]|||[]| | |[]|||[]| // // | ^ | ^ | ^ | // // | / \ |________/^\________| / \ | // // | /___\ ~•~~•~~•~~•~~•~~•~~•~ /___\ | // // | | | | () *☆D☆* () | | | | // // | | | | ()_______________() | | | | // // |/ ^ \ ()_¡_¡_¡_¡_¡_¡_¡_() / ^ \| // // | / \ \ / / \ | // // | / * \ \ vvvvvvvvvvvvvvv / / * \ | // // |/_____\ | _____________ | /_____\| // // ||_|_|_|\| [ | ] |/|_|_|_|| // // ||_|_|_|| | [][] | [][] | | |_|_|_|| // // ||_|_|_|| | | | | |_|_|_|| // // | _____ | [______|______] | _____ | // // ||_|_|_|| 《 》| |_|_|_|| // // ||_|_|_|| 《______________》| |_|_|_|| // // ||_|_|_|| _《____________》_| |_|_|_|| // // | | 《__________》 | | // // | | 《________》 | | // // ############ 《______》 ############# // // ¥¥¥¥¥¥¥¥¥¥¥¥ | | ¥¥¥¥¥¥¥¥¥¥¥¥¥ // // ############ | | ############# // // *| |* // // *| |* // // *| |* // // ::::::::::::::::::::::::::::::::::::: // // ::::::::::::::::::::::::::::::::::;:: // // // // // ///////////////////////////////////////////////// contract RWS is ERC721Creator { constructor() ERC721Creator("Rain Water Series By Brooke Dahl", "RWS") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209927cf8f32b0bf1aec2f61d845414c55f8cc80fab89cefb28d494a06a13d7bb664736f6c63430008070033
{"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, 2581, 2683, 2575, 19797, 2683, 2487, 2063, 2509, 9024, 27531, 2692, 2050, 2683, 2620, 2683, 2581, 5243, 2509, 2546, 2575, 11329, 2497, 2581, 2050, 2575, 20952, 2497, 2094, 2692, 2629, 7875, 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, 4542, 2300, 2186, 2011, 11535, 27934, 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, 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,912
0x9796e167b9f1eb99c6c254d04a5ce4680befdeab
/* ____ _ ____ _ _____ _ / ___|___ ___ | | _ \(_)_ __ ___ | ___(_)_ __ __ _ _ __ ___ ___ | | / _ \ / _ \| | | | | | '_ \ / _ \ | |_ | | '_ \ / _` | '_ \ / __/ _ \ | |__| (_) | (_) | | |_| | | | | | (_) | | _| | | | | | (_| | | | | (_| __/ \____\___/ \___/|_|____/|_|_| |_|\___/ |_| |_|_| |_|\__,_|_| |_|\___\___| (CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN)-(CDN) CoolDino is a new and unique DeFi project featuring an experimental CDN token. The principle of operation of our token is very simple - earn with us more than 200% per annum by receiving a CDN token staking your pool's token. Website: https://cooldino.finance/ Twitter: https://twitter.com/CoolDino_Finance Telegram: https://t.me/CoolDino_Finance Discord: https://discord.gg/RNpuXb Medium: https://medium.com/@cooldino.finance GitHub: https://github.com/CoolDinoFinance/Contract CoolDino token sale price is 0.001 ETH/CDN (15% discount from Uniswap listing) Token Sale Dates: Aug 30 - Sep 04 CDN Allocation: Token Sale - 115.200 CDN (72%) Initial Liquidity - 30.400 CDN (19%) Team - 11.200 CDN (7%) Marketing - 3.200 CDN (2%) */ pragma solidity ^0.5.16; interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns (uint); function transfer(address recipient, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint amount) external returns (bool); function transferFrom(address sender, address recipient, uint amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Context { constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping (address => uint) private _balances; mapping (address => mapping (address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns (uint) { return _totalSupply; } function balanceOf(address account) public view returns (uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns (bool) { //require(!_tokenSaleMode || msg.sender == governance, "token sale is ongoing"); _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) { //require(!_tokenSaleMode || msg.sender == governance, "token sale is ongoing"); _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(!_tokenSaleMode || msg.sender == governance, "token sale is ongoing"); 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 { //require(!_tokenSaleMode || msg.sender == governance, "token sale is ongoing"); callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { //require(!_tokenSaleMode || msg.sender == governance, "token sale is ongoing"); 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 COOLDINO is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; uint256 public tokenSalePrice = 0.001 ether; bool public _tokenSaleMode = true; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("CoolDino.Finance", "CDN", 18) { governance = msg.sender; minters[msg.sender] = true; } function mint(address account, uint256 amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function burn(uint256 amount) public { _burn(msg.sender, 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; } function buyToken() public payable { require(_tokenSaleMode, "token sale is over"); uint256 newTokens = SafeMath.mul(SafeMath.div(msg.value, tokenSalePrice),1e18); _mint(msg.sender, newTokens); } function() external payable { buyToken(); } function endTokenSale() public { require(msg.sender == governance, "!governance"); _tokenSaleMode = false; } function withdraw() external { require(msg.sender == governance, "!governance"); msg.sender.transfer(address(this).balance); } }
0x6080604052600436106101405760003560e01c80635aa6e675116100b6578063a9059cbb1161006f578063a9059cbb14610494578063ab033ea9146104cd578063dd62ed3e14610500578063e55bfd161461053b578063e86790eb14610550578063f46eccc41461056557610140565b80635aa6e675146103af57806370a08231146103e057806395d89b4114610413578063983b2d5614610428578063a457c2d71461045b578063a48217191461014057610140565b80633092afd5116101085780633092afd5146102a0578063313ce567146102d357806339509351146102fe5780633ccfd60b1461033757806340c10f191461034c57806342966c681461038557610140565b806306fdde031461014a578063095ea7b3146101d457806318160ddd1461022157806323b872dd14610248578063307edff81461028b575b610148610598565b005b34801561015657600080fd5b5061015f610612565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610199578181015183820152602001610181565b50505050905090810190601f1680156101c65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101e057600080fd5b5061020d600480360360408110156101f757600080fd5b506001600160a01b0381351690602001356106a8565b604080519115158252519081900360200190f35b34801561022d57600080fd5b506102366106c6565b60408051918252519081900360200190f35b34801561025457600080fd5b5061020d6004803603606081101561026b57600080fd5b506001600160a01b038135811691602081013590911690604001356106cc565b34801561029757600080fd5b50610148610759565b3480156102ac57600080fd5b50610148600480360360208110156102c357600080fd5b50356001600160a01b03166107b7565b3480156102df57600080fd5b506102e861082a565b6040805160ff9092168252519081900360200190f35b34801561030a57600080fd5b5061020d6004803603604081101561032157600080fd5b506001600160a01b038135169060200135610833565b34801561034357600080fd5b50610148610887565b34801561035857600080fd5b506101486004803603604081101561036f57600080fd5b506001600160a01b038135169060200135610905565b34801561039157600080fd5b50610148600480360360208110156103a857600080fd5b5035610961565b3480156103bb57600080fd5b506103c461096b565b604080516001600160a01b039092168252519081900360200190f35b3480156103ec57600080fd5b506102366004803603602081101561040357600080fd5b50356001600160a01b031661097f565b34801561041f57600080fd5b5061015f61099a565b34801561043457600080fd5b506101486004803603602081101561044b57600080fd5b50356001600160a01b03166109fb565b34801561046757600080fd5b5061020d6004803603604081101561047e57600080fd5b506001600160a01b038135169060200135610a71565b3480156104a057600080fd5b5061020d600480360360408110156104b757600080fd5b506001600160a01b038135169060200135610adf565b3480156104d957600080fd5b50610148600480360360208110156104f057600080fd5b50356001600160a01b0316610af3565b34801561050c57600080fd5b506102366004803603604081101561052357600080fd5b506001600160a01b0381358116916020013516610b6d565b34801561054757600080fd5b5061020d610b98565b34801561055c57600080fd5b50610236610ba1565b34801561057157600080fd5b5061020d6004803603602081101561058857600080fd5b50356001600160a01b0316610ba7565b60075460ff166105e4576040805162461bcd60e51b81526020600482015260126024820152713a37b5b2b71039b0b6329034b99037bb32b960711b604482015290519081900360640190fd5b60006106036105f534600654610bbc565b670de0b6b3a7640000610c05565b905061060f3382610c5e565b50565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561069e5780601f106106735761010080835404028352916020019161069e565b820191906000526020600020905b81548152906001019060200180831161068157829003601f168201915b5050505050905090565b60006106bc6106b5610d4e565b8484610d52565b5060015b92915050565b60025490565b60006106d9848484610e3e565b61074f846106e5610d4e565b61074a856040518060600160405280602881526020016112dd602891396001600160a01b038a16600090815260016020526040812090610723610d4e565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610f9a16565b610d52565b5060019392505050565b60075461010090046001600160a01b031633146107ab576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6007805460ff19169055565b60075461010090046001600160a01b03163314610809576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b03166000908152600860205260409020805460ff19169055565b60055460ff1690565b60006106bc610840610d4e565b8461074a8560016000610851610d4e565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61103116565b60075461010090046001600160a01b031633146108d9576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b60405133904780156108fc02916000818181858888f1935050505015801561060f573d6000803e3d6000fd5b3360009081526008602052604090205460ff16610953576040805162461bcd60e51b815260206004820152600760248201526610b6b4b73a32b960c91b604482015290519081900360640190fd5b61095d8282610c5e565b5050565b61060f338261108b565b60075461010090046001600160a01b031681565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561069e5780601f106106735761010080835404028352916020019161069e565b60075461010090046001600160a01b03163314610a4d576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b03166000908152600860205260409020805460ff19166001179055565b60006106bc610a7e610d4e565b8461074a8560405180606001604052806025815260200161136f6025913960016000610aa8610d4e565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610f9a16565b60006106bc610aec610d4e565b8484610e3e565b60075461010090046001600160a01b03163314610b45576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600780546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60075460ff1681565b60065481565b60086020526000908152604090205460ff1681565b6000610bfe83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611187565b9392505050565b600082610c14575060006106c0565b82820282848281610c2157fe5b0414610bfe5760405162461bcd60e51b81526004018080602001828103825260218152602001806112bc6021913960400191505060405180910390fd5b6001600160a01b038216610cb9576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600254610ccc908263ffffffff61103116565b6002556001600160a01b038216600090815260208190526040902054610cf8908263ffffffff61103116565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b3390565b6001600160a01b038316610d975760405162461bcd60e51b815260040180806020018281038252602481526020018061134b6024913960400191505060405180910390fd5b6001600160a01b038216610ddc5760405162461bcd60e51b81526004018080602001828103825260228152602001806112746022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610e835760405162461bcd60e51b81526004018080602001828103825260258152602001806113266025913960400191505060405180910390fd5b6001600160a01b038216610ec85760405162461bcd60e51b815260040180806020018281038252602381526020018061122f6023913960400191505060405180910390fd5b610f0b81604051806060016040528060268152602001611296602691396001600160a01b038616600090815260208190526040902054919063ffffffff610f9a16565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610f40908263ffffffff61103116565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156110295760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610fee578181015183820152602001610fd6565b50505050905090810190601f16801561101b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610bfe576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0382166110d05760405162461bcd60e51b81526004018080602001828103825260218152602001806113056021913960400191505060405180910390fd5b61111381604051806060016040528060228152602001611252602291396001600160a01b038516600090815260208190526040902054919063ffffffff610f9a16565b6001600160a01b03831660009081526020819052604090205560025461113f908263ffffffff6111ec16565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600081836111d65760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610fee578181015183820152602001610fd6565b5060008385816111e257fe5b0495945050505050565b6000610bfe83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610f9a56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582050f1f4d2319553ae127ff974e9c92efac9d3d341c220a016a596499d4e58703c64736f6c63430005100032
{"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, 2581, 2683, 2575, 2063, 16048, 2581, 2497, 2683, 2546, 2487, 15878, 2683, 2683, 2278, 2575, 2278, 17788, 2549, 2094, 2692, 2549, 2050, 2629, 3401, 21472, 17914, 4783, 2546, 3207, 7875, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1035, 1035, 1035, 1064, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1035, 1032, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1035, 1035, 1035, 1006, 1035, 1007, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 1013, 1035, 1032, 1013, 1035, 1032, 1064, 1064, 1064, 1064, 1064, 1064, 1005, 1035, 1032, 1013, 1035, 1032, 1064, 1064, 1035, 1064, 1064, 1005, 1035, 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,913
0x9796ec7eef46398a74c377b4f527b5a3d8a389a9
pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20TOKEN 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 = "Bonsover"; // CHANGEME, token name ex: Bitcoin symbol = "BNE"; // CHANGEME, token symbol ex: BTC decimals = 8; // token decimals (ETH=18,USDT=6,BTC=8) _totalSupply = 1000000000; // total supply including decimals 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; } }
0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a293d1e814610067578063b5931f7c146100c0578063d05c78da14610119578063e6cb901314610172575b600080fd5b34801561007357600080fd5b506100aa6004803603604081101561008a57600080fd5b8101908080359060200190929190803590602001909291905050506101cb565b6040518082815260200191505060405180910390f35b3480156100cc57600080fd5b50610103600480360360408110156100e357600080fd5b8101908080359060200190929190803590602001909291905050506101e7565b6040518082815260200191505060405180910390f35b34801561012557600080fd5b5061015c6004803603604081101561013c57600080fd5b81019080803590602001909291908035906020019092919050505061020b565b6040518082815260200191505060405180910390f35b34801561017e57600080fd5b506101b56004803603604081101561019557600080fd5b81019080803590602001909291908035906020019092919050505061023c565b6040518082815260200191505060405180910390f35b60008282111515156101dc57600080fd5b818303905092915050565b600080821115156101f757600080fd5b818381151561020257fe5b04905092915050565b60008183029050600083148061022b575081838281151561022857fe5b04145b151561023657600080fd5b92915050565b6000818301905082811015151561025257600080fd5b9291505056fea165627a7a7230582067ffe629fc8f1fbff30526192374ed5038088d379b271b3ed4e166b050a276c30029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2575, 8586, 2581, 4402, 2546, 21472, 23499, 2620, 2050, 2581, 2549, 2278, 24434, 2581, 2497, 2549, 2546, 25746, 2581, 2497, 2629, 2050, 29097, 2620, 2050, 22025, 2683, 2050, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 19204, 2015, 1007, 2270, 5651, 1006, 22017, 2140, 3112, 1007, 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,914
0x979714467D4ce3Af07FdEaB1B5008e9a540B9c7E
// SPDX-License-Identifier: MIT /* ███████╗██╗ ██╗███████╗██╗ ██████╗ ███╗ ██╗ ███████╗██████╗ █████╗ ██████╗████████╗ █████╗ ██╗ ███████╗ ██╔════╝██║ ██║██╔════╝██║██╔═══██╗████╗ ██║ ██╔════╝██╔══██╗██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██║ ██╔════╝ █████╗ ██║ ██║███████╗██║██║ ██║██╔██╗ ██║ █████╗ ██████╔╝███████║██║ ██║ ███████║██║ ███████╗ ██╔══╝ ██║ ██║╚════██║██║██║ ██║██║╚██╗██║ ██╔══╝ ██╔══██╗██╔══██║██║ ██║ ██╔══██║██║ ╚════██║ ██║ ╚██████╔╝███████║██║╚██████╔╝██║ ╚████║ ██║ ██║ ██║██║ ██║╚██████╗ ██║ ██║ ██║███████╗███████║ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ v2.1.1 */ pragma solidity ^0.8.11; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @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 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 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 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 * ==== * * [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); } } } } /** * @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); } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert('ERC721A: unable to get token of owner by index'); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: approve to caller'); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); require(quantity != 0, 'ERC721A: quantity must be greater than 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } updatedIndex++; } currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } /** * @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); } } // 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; } } } contract FabledFractals is ERC721A, Ownable { using Address for address; using SafeMath for uint256; using Strings for uint256; string private constant baseURI = "https://storage.googleapis.com/flames/metadata/"; uint256 private constant mintPrice = 0.055 ether; uint256 private constant maxSupply = 5000; uint256 private constant maxGiveaway = 50; uint256 private nftsGivenAway = 0; uint256 private constant maxPerTxn = 10; bool private saleIsActive = false; constructor() ERC721A("Flames by Fabled Fractals | Official Collection", "FLAMES") { } function setSale(bool value) external onlyOwner { saleIsActive = value; } // Function to withdraw collected amount during minting by the owners function withdraw() public onlyOwner { uint balance = address(this).balance; require(balance > 0, "Balance should be more then zero"); address DEV3_ADDRESS = 0x03D5a39CD7517bc568aA8B23C4302fA4c67DC204; // payout for deployer (80%) (bool success1, ) = (msg.sender).call{value: balance * 4 / 5}(""); require(success1, "Failed to send ether"); // payout for dev3 (20%) (bool success2, ) = (DEV3_ADDRESS).call{value: balance * 1 / 5}(""); require(success2, "Failed to send ether"); } function mint(uint256 amount) external payable { require(saleIsActive == true, "Sale is not active"); require(amount <= maxPerTxn, "Amount should be less than 10 per txn"); require(amount > 0, "Amount to mint was 0"); require(totalSupply().add(amount) <= maxSupply, "Exceeds maximum supply"); require(msg.value == mintPrice.mul(amount), "Must provide exact required ETH"); _safeMint(msg.sender, amount); } function freeMintToAddr(address addr, uint256 amount) external payable onlyOwner { require(saleIsActive == true, "Sale is not active"); require(amount > 0, "Amount to mint was 0"); require(totalSupply().add(amount) <= maxSupply, "Exceeds maximum supply"); require(msg.value == 0, "Please send 0 eth"); require(nftsGivenAway + amount <= maxGiveaway); _safeMint(addr, amount); nftsGivenAway += amount; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); return string(abi.encodePacked(baseURI, tokenId.toString(), ".json")); } } contract FusionFractals is ERC721A, Ownable { using Address for address; using SafeMath for uint256; using Strings for uint256; string private constant baseURI = "https://storage.googleapis.com/flames/fusion/metadata/"; bool public saleIsActive = false; FabledFractals ff; address public flames_contract_address = 0x5deDEDb58E08e20D36Ff1918aF90aDCF4048e08E; //rinkeby contract mapping(uint256 => mapping(uint256 => bool)) public mintedFusions; // boolean matrix mapping(uint256 => uint256) public tokenId1Lookup; // fusion token id => flame 1 mapping(uint256 => uint256) public tokenId2Lookup; // fusion token id => flame 2 constructor() ERC721A("Fusion by Fabled Fractals | Official Collection", "FUSION") { ff = FabledFractals(flames_contract_address); } function setSale(bool value) external onlyOwner { saleIsActive = value; } // Function to withdraw collected amount during minting by the owners function withdraw() public onlyOwner { uint balance = address(this).balance; require(balance > 0, "Balance should be more then zero"); (bool success, ) = (msg.sender).call{value: balance}(""); require(success, "Failed to send ether"); } function flamesHolderProxy(uint256 tokenid) public view returns (address holder_address) { return ff.ownerOf(tokenid); } function getFlamesByAddressProxy(address a) public view returns (uint256[] memory) { uint256 count = 0; for (uint256 i = 0; i < ff.totalSupply(); i++) { if (ff.ownerOf(i) == a) { count += 1; } } uint256[] memory list = new uint256[](count); uint256 used_count = 0; for (uint256 i = 0; i < ff.totalSupply(); i++) { if (ff.ownerOf(i) == a) { list[used_count] = i; used_count++; } } return list; } // mint fusion nft function mint(uint256 tokenid_1, uint256 tokenid_2) external payable { require(saleIsActive == true, "Sale is not active"); require(tokenid_1 != tokenid_2, "Cant make a fusion of the same token!"); require(flamesHolderProxy(tokenid_1) == msg.sender, "You do not own token1"); require(flamesHolderProxy(tokenid_2) == msg.sender, "You do not own token2"); require(mintedFusions[tokenid_1][tokenid_2] == false, "Fusion already minted!"); _safeMint(msg.sender, 1); // mark this fusion as taken mintedFusions[tokenid_1][tokenid_2] = true; mintedFusions[tokenid_2][tokenid_1] = true; // point the fusion tokenid to both flame tokenids for lookup later tokenId1Lookup[totalSupply() - 1] = tokenid_1; tokenId2Lookup[totalSupply() - 1] = tokenid_2; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); return string(abi.encodePacked(baseURI, tokenId.toString(), ".json")); } }
0x6080604052600436106101c25760003560e01c80636352211e116100f7578063a22cb46511610095578063d94ab50f11610064578063d94ab50f14610512578063e985e9c51461054d578063eb8d244414610596578063f2fde38b146105b757600080fd5b8063a22cb46514610492578063a5499a6c146104b2578063b88d4fde146104d2578063c87b56dd146104f257600080fd5b80637de291da116100d15780637de291da146104125780638da5cb5b1461043257806395d89b4114610450578063a0b1b2731461046557600080fd5b80636352211e146103bd57806370a08231146103dd578063715018a6146103fd57600080fd5b80631b2ef1ca116101645780632f745c591161013e5780632f745c59146103485780633ccfd60b1461036857806342842e0e1461037d5780634f6ccce71461039d57600080fd5b80631b2ef1ca146102f55780631d2e5a3a1461030857806323b872dd1461032857600080fd5b8063095ea7b3116101a0578063095ea7b3146102565780630cd5277a1461027857806318160ddd146102b3578063188ad34e146102c857600080fd5b806301ffc9a7146101c757806306fdde03146101fc578063081812fc1461021e575b600080fd5b3480156101d357600080fd5b506101e76101e2366004611cdc565b6105d7565b60405190151581526020015b60405180910390f35b34801561020857600080fd5b50610211610644565b6040516101f39190611d58565b34801561022a57600080fd5b5061023e610239366004611d6b565b6106d6565b6040516001600160a01b0390911681526020016101f3565b34801561026257600080fd5b50610276610271366004611d99565b610766565b005b34801561028457600080fd5b506102a5610293366004611d6b565b600b6020526000908152604090205481565b6040519081526020016101f3565b3480156102bf57600080fd5b506000546102a5565b3480156102d457600080fd5b506102e86102e3366004611dc5565b61087e565b6040516101f39190611de2565b610276610303366004611e26565b610b30565b34801561031457600080fd5b50610276610323366004611e5d565b610d99565b34801561033457600080fd5b50610276610343366004611e78565b610de1565b34801561035457600080fd5b506102a5610363366004611d99565b610dec565b34801561037457600080fd5b50610276610f49565b34801561038957600080fd5b50610276610398366004611e78565b611054565b3480156103a957600080fd5b506102a56103b8366004611d6b565b61106f565b3480156103c957600080fd5b5061023e6103d8366004611d6b565b6110d1565b3480156103e957600080fd5b506102a56103f8366004611dc5565b6110e3565b34801561040957600080fd5b50610276611174565b34801561041e57600080fd5b5060095461023e906001600160a01b031681565b34801561043e57600080fd5b506007546001600160a01b031661023e565b34801561045c57600080fd5b506102116111aa565b34801561047157600080fd5b506102a5610480366004611d6b565b600c6020526000908152604090205481565b34801561049e57600080fd5b506102766104ad366004611eb9565b6111b9565b3480156104be57600080fd5b5061023e6104cd366004611d6b565b61127e565b3480156104de57600080fd5b506102766104ed366004611f04565b6112ec565b3480156104fe57600080fd5b5061021161050d366004611d6b565b611325565b34801561051e57600080fd5b506101e761052d366004611e26565b600a60209081526000928352604080842090915290825290205460ff1681565b34801561055957600080fd5b506101e7610568366004611fe4565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156105a257600080fd5b506007546101e790600160a01b900460ff1681565b3480156105c357600080fd5b506102766105d2366004611dc5565b6113df565b60006001600160e01b031982166380ac58cd60e01b148061060857506001600160e01b03198216635b5e139f60e01b145b8061062357506001600160e01b0319821663780e9d6360e01b145b8061063e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600180546106539061201d565b80601f016020809104026020016040519081016040528092919081815260200182805461067f9061201d565b80156106cc5780601f106106a1576101008083540402835291602001916106cc565b820191906000526020600020905b8154815290600101906020018083116106af57829003601f168201915b5050505050905090565b60006106e3826000541190565b61074a5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b6000610771826110d1565b9050806001600160a01b0316836001600160a01b031614156107e05760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610741565b336001600160a01b03821614806107fc57506107fc8133610568565b61086e5760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610741565b61087983838361147a565b505050565b60606000805b600860009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fb9190612058565b8110156109a0576008546040516331a9108f60e11b8152600481018390526001600160a01b03868116921690636352211e90602401602060405180830381865afa15801561094d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109719190612071565b6001600160a01b0316141561098e5761098b6001836120a4565b91505b80610998816120bc565b915050610884565b5060008167ffffffffffffffff8111156109bc576109bc611eee565b6040519080825280602002602001820160405280156109e5578160200160208202803683370190505b5090506000805b600860009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a639190612058565b811015610b26576008546040516331a9108f60e11b8152600481018390526001600160a01b03888116921690636352211e90602401602060405180830381865afa158015610ab5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad99190612071565b6001600160a01b03161415610b145780838381518110610afb57610afb6120d7565b602090810291909101015281610b10816120bc565b9250505b80610b1e816120bc565b9150506109ec565b5090949350505050565b600754600160a01b900460ff161515600114610b835760405162461bcd60e51b815260206004820152601260248201527153616c65206973206e6f742061637469766560701b6044820152606401610741565b80821415610be15760405162461bcd60e51b815260206004820152602560248201527f43616e74206d616b65206120667573696f6e206f66207468652073616d6520746044820152646f6b656e2160d81b6064820152608401610741565b33610beb8361127e565b6001600160a01b031614610c395760405162461bcd60e51b8152602060048201526015602482015274596f7520646f206e6f74206f776e20746f6b656e3160581b6044820152606401610741565b33610c438261127e565b6001600160a01b031614610c915760405162461bcd60e51b81526020600482015260156024820152742cb7ba903237903737ba1037bbb7103a37b5b2b71960591b6044820152606401610741565b6000828152600a6020908152604080832084845290915290205460ff1615610cf45760405162461bcd60e51b8152602060048201526016602482015275467573696f6e20616c7265616479206d696e7465642160501b6044820152606401610741565b610cff3360016114d6565b6000828152600a602081815260408084208585528252808420805460ff1990811660019081179092559383528185208786529092528320805490921681179091558391600b91610d4e60005490565b610d5891906120ed565b81526020019081526020016000208190555080600c60006001610d7a60005490565b610d8491906120ed565b81526020810191909152604001600020555050565b6007546001600160a01b03163314610dc35760405162461bcd60e51b815260040161074190612104565b60078054911515600160a01b0260ff60a01b19909216919091179055565b6108798383836114f0565b6000610df7836110e3565b8210610e505760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610741565b600080549080805b83811015610ee9576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610eab57805192505b876001600160a01b0316836001600160a01b03161415610ee05786841415610ed95750935061063e92505050565b6001909301925b50600101610e58565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610741565b6007546001600160a01b03163314610f735760405162461bcd60e51b815260040161074190612104565b4780610fc15760405162461bcd60e51b815260206004820181905260248201527f42616c616e63652073686f756c64206265206d6f7265207468656e207a65726f6044820152606401610741565b604051600090339083908381818185875af1925050503d8060008114611003576040519150601f19603f3d011682016040523d82523d6000602084013e611008565b606091505b50509050806110505760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321032ba3432b960611b6044820152606401610741565b5050565b610879838383604051806020016040528060008152506112ec565b6000805482106110cd5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610741565b5090565b60006110dc826117d5565b5192915050565b60006001600160a01b03821661114f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610741565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6007546001600160a01b0316331461119e5760405162461bcd60e51b815260040161074190612104565b6111a860006118ac565b565b6060600280546106539061201d565b6001600160a01b0382163314156112125760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610741565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6008546040516331a9108f60e11b8152600481018390526000916001600160a01b031690636352211e90602401602060405180830381865afa1580156112c8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e9190612071565b6112f78484846114f0565b611303848484846118fe565b61131f5760405162461bcd60e51b815260040161074190612139565b50505050565b6060611332826000541190565b6113965760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610741565b604051806060016040528060368152602001612264603691396113b8836119fd565b6040516020016113c992919061218c565b6040516020818303038152906040529050919050565b6007546001600160a01b031633146114095760405162461bcd60e51b815260040161074190612104565b6001600160a01b03811661146e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610741565b611477816118ac565b50565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b611050828260405180602001604052806000815250611afb565b60006114fb826117d5565b80519091506000906001600160a01b0316336001600160a01b03161480611532575033611527846106d6565b6001600160a01b0316145b80611544575081516115449033610568565b9050806115ae5760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610741565b846001600160a01b031682600001516001600160a01b0316146116225760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610741565b6001600160a01b0384166116865760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610741565b611696600084846000015161147a565b6001600160a01b03858116600090815260046020908152604080832080546001600160801b03198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600390935281842080546001600160e01b031916909117600160a01b4267ffffffffffffffff160217905590860180835291205490911661178b5761173e816000541190565b1561178b578251600082815260036020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b60408051808201909152600080825260208201526117f4826000541190565b6118535760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610741565b815b6000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156118a2579392505050565b5060001901611855565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b156119f157604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906119429033908990889088906004016121cb565b6020604051808303816000875af192505050801561197d575060408051601f3d908101601f1916820190925261197a91810190612208565b60015b6119d7573d8080156119ab576040519150601f19603f3d011682016040523d82523d6000602084013e6119b0565b606091505b5080516119cf5760405162461bcd60e51b815260040161074190612139565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506119f5565b5060015b949350505050565b606081611a215750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611a4b5780611a35816120bc565b9150611a449050600a8361223b565b9150611a25565b60008167ffffffffffffffff811115611a6657611a66611eee565b6040519080825280601f01601f191660200182016040528015611a90576020820181803683370190505b5090505b84156119f557611aa56001836120ed565b9150611ab2600a8661224f565b611abd9060306120a4565b60f81b818381518110611ad257611ad26120d7565b60200101906001600160f81b031916908160001a905350611af4600a8661223b565b9450611a94565b61087983838360016000546001600160a01b038516611b665760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610741565b83611bc45760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d75737420626520677265617465604482015267072207468616e20360c41b6064820152608401610741565b6001600160a01b03851660008181526004602090815260408083208054600160801b6001600160801b031982166001600160801b039283168c01831690811782900483168c01909216021790558483526003909152812080546001600160e01b031916909217600160a01b4267ffffffffffffffff16021790915581905b85811015611cbd5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48315611cb157611c9560008884886118fe565b611cb15760405162461bcd60e51b815260040161074190612139565b60019182019101611c42565b506000556117ce565b6001600160e01b03198116811461147757600080fd5b600060208284031215611cee57600080fd5b8135611cf981611cc6565b9392505050565b60005b83811015611d1b578181015183820152602001611d03565b8381111561131f5750506000910152565b60008151808452611d44816020860160208601611d00565b601f01601f19169290920160200192915050565b602081526000611cf96020830184611d2c565b600060208284031215611d7d57600080fd5b5035919050565b6001600160a01b038116811461147757600080fd5b60008060408385031215611dac57600080fd5b8235611db781611d84565b946020939093013593505050565b600060208284031215611dd757600080fd5b8135611cf981611d84565b6020808252825182820181905260009190848201906040850190845b81811015611e1a57835183529284019291840191600101611dfe565b50909695505050505050565b60008060408385031215611e3957600080fd5b50508035926020909101359150565b80358015158114611e5857600080fd5b919050565b600060208284031215611e6f57600080fd5b611cf982611e48565b600080600060608486031215611e8d57600080fd5b8335611e9881611d84565b92506020840135611ea881611d84565b929592945050506040919091013590565b60008060408385031215611ecc57600080fd5b8235611ed781611d84565b9150611ee560208401611e48565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215611f1a57600080fd5b8435611f2581611d84565b93506020850135611f3581611d84565b925060408501359150606085013567ffffffffffffffff80821115611f5957600080fd5b818701915087601f830112611f6d57600080fd5b813581811115611f7f57611f7f611eee565b604051601f8201601f19908116603f01168101908382118183101715611fa757611fa7611eee565b816040528281528a6020848701011115611fc057600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611ff757600080fd5b823561200281611d84565b9150602083013561201281611d84565b809150509250929050565b600181811c9082168061203157607f821691505b6020821081141561205257634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561206a57600080fd5b5051919050565b60006020828403121561208357600080fd5b8151611cf981611d84565b634e487b7160e01b600052601160045260246000fd5b600082198211156120b7576120b761208e565b500190565b60006000198214156120d0576120d061208e565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6000828210156120ff576120ff61208e565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6000835161219e818460208801611d00565b8351908301906121b2818360208801611d00565b64173539b7b760d91b9101908152600501949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906121fe90830184611d2c565b9695505050505050565b60006020828403121561221a57600080fd5b8151611cf981611cc6565b634e487b7160e01b600052601260045260246000fd5b60008261224a5761224a612225565b500490565b60008261225e5761225e612225565b50069056fe68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f666c616d65732f667573696f6e2f6d657461646174612fa2646970667358221220595f8fe146cece3f9f8f29aa0820ea4ca652f218765d739f893f4a7707364f8a64736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2581, 16932, 21472, 2581, 2094, 2549, 3401, 2509, 10354, 2692, 2581, 2546, 3207, 7875, 2487, 2497, 29345, 2620, 2063, 2683, 2050, 27009, 2692, 2497, 2683, 2278, 2581, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1058, 2475, 1012, 1015, 1012, 1015, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2340, 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,915
0x97971ce2d824e740B2cA8D4A16a4DF2d6481AaEA
/** MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWWWWWWWWWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMWWNXXKKKKKKKXXXXKKKKKKXXNWWMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMWNXKKKKXXNWWWWMMWWWWMWWWWNXXXKKKXNWMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMWNXKKKXNWMMMMMMMMMNOdxKWMMMMMMMMWNXKKKXNWMMMMMMMMMMMMMM MMMMMMMMMMMMMWXKKKNWMMMMMMMMMMMMNx:;;l0WMMMMMMMMMMMWNK0KXWMMMMMMMMMMMM MMMMMMMMMMMWXKKXWMMMMMMMMMMMMMMXd:;;;;cOWMMMMMMMMMMMMMWXKKXWMMMMMMMMMM MMMMMMMMMWNKKXWMMMMMMMMMMMMMMWKo;;col:;:kNMMMMMMMMMMMMMMWX0KNWMMMMMMMM MMMMMMMMWX0XWMMMMMMMMMMMMMMMWOl;;oKWXkc;:dXMMMMMMMMMMMMMMMWX0XWMMMMMMM MMMMMMMNKKNWMMMMMMMMMMMMMMMNkc;:dXMMMWOc;;oKWMMMMMMMMMMMMMMWNKKNMMMMMM MMMMMMNKKNMMMMMMMMMMMMMMMMNx:;:xNMMMMMW0l;;l0WMMMMMMMWMMMMMMMNKKNMMMMM MMMMMNKKNMMMMMMMMMMMMMMMMXd:;ckNMMMMMMMMKo:;cOWMMMMXkxkXWMMMMMNKKNMMMM MMMMWK0NMMMMMMMMMMMMMMMWKo;;l0WMMMMMMMMMMXx:;:xNMMW0lccxXMMMMMMN0KWMMM MMMMX0XWMMMMMMWWMMMMMMWOl;;oKWMMMMMMMMMMMMNkc;:dXMMNklcoKMMMMMMMX0XMMM MMMWKKNMMWK0OkkkkkkKWNkc;:dXMMMMMMMMMMMMMMMWOl;;oKWMXdcxNMMMMMMMNKKWMM MMMN0XWMMWNXX0OdlccdKOc;:xNMMMWXKKXNWNNNNWWMW0o;;l0WNkdKWMMMMMMMWX0NMM MMMX0XMMMMMMMMMN0dlcdOxoONMMMMW0xdddddodxk0KNWXd:;l0Kx0WMMMMMMMMMX0XMM MMMX0NMMMMMMMMMMWXxlcoOXWMMMMWKkolclodkKNNNNWWMNxcxOkKWMMMMMMMMMMX0XMM MMMX0XMMMMMMMMMMMMNklclkNMMWXklccodxdodKWMMMMMMMNKOkKWMMMMMMMMMMMX0XMM MMMN0XWMMMMMMMMMMMMNOoclxXN0occcdKX0xlco0WMMMMMMNOOXMMMMMMMMMMMMMX0NMM MMMWKKWMMMMMMMMMMMMMW0dccoxocccdKWMWNklclONMMMMXOONMMMMMMMMMMMMMWKKWMM MMMMX0XMMMMMMMMMMMMMMWKdcccccco0WMMMMNOoclkNWWKk0NMMMMMMMMMMMMMMX0XWMM MMMMWKKNMMMMMMMMMMMMMMMXxlcccckNMMMMMMW0oclxK0kKWMMMMMMMMMMMMMMNKKWMMM MMMMMN0KWMMMMMMMMMMMMMMMNklccoKWMMMMMMMWKdlcoxKWMMMMMMMMMMMMMMWK0NMMMM MMMMMMN0KWMMMMMMMMMMMMMMMNOod0KXWMMMMMMNK0xoxXWMMMMMMMMMMMMMMWK0NMMMMM MMMMMMMN0KNMMMMMMMMMMMMMMMWXKkll0WMMMMXdcoOKNMMMMMMMMMMMMMMMNK0NMMMMMM MMMMMMMMNK0XWMMMMMMMMMMMMMMMNd:;cOWMWKo:;c0WMMMMMMMMMMMMMMWX0KNMMMMMMM MMMMMMMMMWXKKNWMMMMMMMMMMMMMMXd:;cx0kl;;l0WMMMMMMMMMMMMMWNKKXWMMMMMMMM MMMMMMMMMMMWX0KNWMMMMMMMMMMMMMNkc;;::;:oKWMMMMMMMMMMMMWNK0XWMMMMMMMMMM MMMMMMMMMMMMMNXKKXNWMMMMMMMMMMMWOc;;;:dXMMMMMMMMMMMWNXKKXWMMMMMMMMMMMM MMMMMMMMMMMMMMMWNKKKXNWMMMMMMMMMW0l:ckNMMMMMMMMMWNXKKKNWMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMWNXKKKXXNWWWMMMMX0KWMMMWWWNXXKKKXNWMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMWWNXXKKKKKXXXXXXXXXXKKKKXXNWWMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMWWNNNNNNNNNNNNWWWMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ---------------------- [ WPSmartContracts.com ] ---------------------- [ Blockchain Made Easy ] | | ERC-721 NFT Marketplace | |---------------------------- | | Flavors | | > Matcha: Fully featured ERC-721 Token, with Buy, | Sell and Auction NFT Marketplace | */ pragma solidity ^0.5.7; /** * @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. */ contract IERC721 is IERC165 { event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApproveForAll}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApproveForAll}. */ function transferFrom( address from, address to, uint256 tokenId ) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public; } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract IERC721Receiver { /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransfer}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 contract address is always the message sender. * @param operator The address which called `safeTransferFrom` function * @param from The address which previously owned the token * @param tokenId The NFT identifier which is being transferred * @param data Additional data with no specified format * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address operator, address from, uint256 tokenId, bytes memory data ) public returns (bytes4); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } } /** * @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 { counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ 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) external view 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 { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is ERC165, IERC721 { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; // 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 token ID to owner mapping(uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping(address => Counters.Counter) private _ownedTokensCount; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /* * 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 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); } /** * @dev Gets the balance of the specified address. * @param owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _ownedTokensCount[owner].current(); } /** * @dev Gets the owner of the specified token ID. * @param tokenId uint256 ID of the token to query the owner of * @return address currently marked as the owner of the given token ID */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; require( owner != address(0), "ERC721: owner query for nonexistent token" ); return owner; } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param to address to be approved for the given token ID * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { require( _exists(tokenId), "ERC721: approved query for nonexistent token" ); return _tokenApprovals[tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf. * @param to operator address to set the approval * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { require(to != msg.sender, "ERC721: approve to caller"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } /** * @dev Tells whether an operator is approved by a given owner. * @param owner owner address which you want to query the approval of * @param operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Transfers the ownership of a given token ID to another address. * Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * Requires the msg.sender to be the owner, approved, or operator. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function transferFrom( address from, address to, uint256 tokenId ) public { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved" ); _transferFrom(from, to, tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address from, address to, uint256 tokenId ) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public { transferFrom(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether the specified token exists. * @param tokenId uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists(uint256 tokenId) internal view returns (bool) { address owner = _tokenOwner[tokenId]; return owner != address(0); } /** * @dev Returns whether the given spender can transfer a given token ID. * @param spender address of the spender to query * @param tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to mint a new token. * Reverts if the given token ID already exists. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); emit Transfer(address(0), to, tokenId); } /** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom( address from, address to, uint256 tokenId ) internal { require( ownerOf(tokenId) == from, "ERC721: transfer of token that is not own" ); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); _ownedTokensCount[from].decrement(); _ownedTokensCount[to].increment(); _tokenOwner[tokenId] = to; emit Transfer(from, 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. * * This function is deprecated. * @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 ) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received( msg.sender, from, tokenId, _data ); return (retval == _ERC721_RECEIVED); } /** * @dev Private function to clear current approval of a given token ID. * @param tokenId uint256 ID of the token to be transferred */ function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } } /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor() internal { _addMinter(msg.sender); } modifier onlyMinter() { require( isMinter(msg.sender), "MinterRole: caller does not have the Minter role" ); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } /** * @title ERC721Mintable * @dev ERC721 minting logic. */ contract ERC721Mintable is ERC721, MinterRole { bool public anyoneCanMint; /** * @dev Options to activate or deactivate mint ability */ function _setMintableOption(bool _anyoneCanMint) internal { anyoneCanMint = _anyoneCanMint; } /** * @dev Function to mint tokens. * @param to The address that will receive the minted tokens. * @param tokenId The token id to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { _mint(to, tokenId); return true; } function canIMint() public view returns (bool) { return anyoneCanMint || isMinter(msg.sender); } /** * Open modifier to anyone can mint possibility */ modifier onlyMinter() { string memory mensaje; require( canIMint(), "MinterRole: caller does not have the Minter role" ); _; } } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract IERC721Enumerable is IERC721 { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256 tokenId); function tokenByIndex(uint256 index) public view returns (uint256); } /** * @title ERC-721 Non-Fungible Token with optional enumeration extension logic * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => 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; /* * 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 Constructor function. */ constructor () public { // register the supported interface to conform to ERC721Enumerable via ERC165 _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev Gets the token ID at a given index of the tokens list of the requested owner. * @param owner address owning the tokens list to be accessed * @param index uint256 representing the index to be accessed of the requested tokens list * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev Gets the total amount of tokens stored by the contract. * @return uint256 representing the total amount of tokens */ function totalSupply() public view returns (uint256) { return _allTokens.length; } /** * @dev Gets the token ID at a given index of all the tokens in this contract * Reverts if the index is greater or equal to the total number of tokens. * @param index uint256 representing the index to be accessed of the tokens list * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to transferFrom, this imposes no restrictions on msg.sender. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { super._transferFrom(from, to, tokenId); _removeTokenFromOwnerEnumeration(from, tokenId); _addTokenToOwnerEnumeration(to, tokenId); } /** * @dev Internal function to mint a new token. * Reverts if the given token ID already exists. * @param to address the beneficiary that will own the minted token * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { super._mint(to, tokenId); _addTokenToOwnerEnumeration(to, tokenId); _addTokenToAllTokensEnumeration(tokenId); } /** * @dev Gets the list of token IDs of the requested owner. * @param owner address owning the tokens * @return uint256[] List of token IDs owned by the requested address */ function _tokensOfOwner(address owner) internal view returns (uint256[] storage) { return _ownedTokens[owner]; } /** * @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 { _ownedTokensIndex[tokenId] = _ownedTokens[to].length; _ownedTokens[to].push(tokenId); } /** * @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 = _ownedTokens[from].length.sub(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 _ownedTokens[from].length--; // Note that _ownedTokensIndex[tokenId] hasn't been cleared: it still points to the old slot (now occupied by // lastTokenId, or just over the end of the array if the token was the last one). } } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * 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; /** * @dev Constructor function */ 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_METADATA); } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return _tokenURIs[tokenId]; } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } } /** * @title ERC721MetadataMintable * @dev ERC721 minting logic with metadata. */ contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole { /** * @dev Function to mint tokens. * @param to The address that will receive the minted tokens. * @param tokenId The token id to mint. * @param tokenURI The token URI of the minted token. * @return A boolean that indicates if the operation was successful. */ function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) { _mint(to, tokenId); _setTokenURI(tokenId, tokenURI); return true; } } /** * @title ERC721 * Full ERC-721 Token with automint function */ contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata, ERC721Mintable, ERC721MetadataMintable { uint256 autoTokenId; constructor (string memory name, string memory symbol, bool _anyoneCanMint) public ERC721Mintable() ERC721Metadata(name, symbol) { // solhint-disable-previous-line no-empty-blocks _setMintableOption(_anyoneCanMint); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function tokensOfOwner(address owner) public view returns (uint256[] memory) { return _tokensOfOwner(owner); } function setTokenURI(uint256 tokenId, string memory uri) public { _setTokenURI(tokenId, uri); } /** * @dev Function to mint tokens with automatic ID * @param to The address that will receive the minted tokens. * @return A boolean that indicates if the operation was successful. */ function autoMint(string memory tokenURI, address to) public onlyMinter returns (bool) { do { autoTokenId++; } while(_exists(autoTokenId)); _mint(to, autoTokenId); _setTokenURI(autoTokenId, tokenURI); return true; } /** * @dev Function to transfer tokens * @param to The address that will receive the minted tokens. * @param tokenId the token ID */ function transfer( address to, uint256 tokenId ) public { _transferFrom(msg.sender, to, tokenId); } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { // counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } /** * @title ERC721Matcha * ERC-721 Marketplace */ contract ERC721Matcha is ERC721Full, ReentrancyGuard { using SafeMath for uint256; using Address for address payable; // admin address, the owner of the marketplace address payable admin; address public contract_owner; // commission rate is a value from 0 to 100 uint256 commissionRate; // last price sold or auctioned mapping(uint256 => uint256) public soldFor; // Mapping from token ID to sell price in Ether or to bid price, depending if it is an auction or not mapping(uint256 => uint256) public sellBidPrice; // Mapping payment address for tokenId mapping(uint256 => address payable) private _wallets; event Sale(uint256 indexed tokenId, address indexed from, address indexed to, uint256 value); event Commission(uint256 indexed tokenId, address indexed to, uint256 value, uint256 rate, uint256 total); /* index _isAuction _sellBidPrice Meaning 0 true 0 Item 0 is on auction and no bids so far 1 true 10 Item 1 is on auction and the last bid is for 10 Ethers 2 false 0 Item 2 is not on auction nor for sell 3 false 10 Item 3 is on sale for 10 Ethers */ // Auction data struct Auction { // Parameters of the auction. Times are either // absolute unix timestamps (seconds since 1970-01-01) // or time periods in seconds. address payable beneficiary; uint auctionEnd; // Current state of the auction. address payable highestBidder; uint highestBid; // Set to true at the end, disallows any change bool open; // minimum reserve price in wei uint256 reserve; } // mapping auctions for each tokenId mapping(uint256 => Auction) public auctions; // Events that will be fired on changes. event Refund(address bidder, uint amount); event HighestBidIncreased(address indexed bidder, uint amount, uint256 tokenId); event AuctionEnded(address winner, uint amount); event LimitSell(address indexed from, address indexed to, uint256 amount); event LimitBuy(address indexed from, address indexed to, uint256 amount); event MarketSell(address indexed from, address indexed to, uint256 amount); event MarketBuy(address indexed from, address indexed to, uint256 amount); constructor(address _owner, address payable _admin, uint256 _commissionRate, string memory name, string memory symbol, bool _anyoneCanMint) public ERC721Full(name, symbol, _anyoneCanMint) { admin = _admin; contract_owner = _owner; require(_commissionRate<=100, "ERC721Matcha: Commission rate has to be between 0 and 100"); commissionRate = _commissionRate; } function canSell(uint256 tokenId) public view returns (bool) { return (ownerOf(tokenId)==msg.sender && !auctions[tokenId].open); } // Sell option for a fixed price function sell(uint256 tokenId, uint256 price, address payable wallet) public { // onlyOwner require(ownerOf(tokenId)==msg.sender, "ERC721Matcha: Only owner can sell this item"); // cannot set a price if auction is activated require(!auctions[tokenId].open, "ERC721Matcha: Cannot sell an item which has an active auction"); // set sell price for index sellBidPrice[tokenId] = price; // If price is zero, means not for sale if (price>0) { // approve the Index to the current contract approve(address(this), tokenId); // set wallet payment _wallets[tokenId] = wallet; } } // simple function to return the price of a tokenId // returns: sell price, bid price, sold price, only one can be non zero function getPrice(uint256 tokenId) public view returns (uint256, uint256, uint256) { if (sellBidPrice[tokenId]>0) return (sellBidPrice[tokenId], 0, 0); if (auctions[tokenId].highestBid>0) return (0, auctions[tokenId].highestBid, 0); return (0, 0, soldFor[tokenId]); } function canBuy(uint256 tokenId) public view returns (uint256) { if (!auctions[tokenId].open && sellBidPrice[tokenId]>0 && sellBidPrice[tokenId]>0 && getApproved(tokenId) == address(this)) { return sellBidPrice[tokenId]; } else { return 0; } } // Buy option function buy(uint256 tokenId) public payable nonReentrant { // is on sale require(!auctions[tokenId].open && sellBidPrice[tokenId]>0, "ERC721Matcha: The collectible is not for sale"); // transfer funds require(msg.value >= sellBidPrice[tokenId], "ERC721Matcha: Not enough funds"); // transfer ownership address owner = ownerOf(tokenId); require(msg.sender!=owner, "ERC721Matcha: The seller cannot buy his own collectible"); // we need to call a transferFrom from this contract, which is the one with permission to sell the NFT callOptionalReturn(this, abi.encodeWithSelector(this.transferFrom.selector, owner, msg.sender, tokenId)); // calculate amounts uint256 amount4admin = msg.value.mul(commissionRate).div(100); uint256 amount4owner = msg.value.sub(amount4admin); // to owner (bool success, ) = _wallets[tokenId].call.value(amount4owner)(""); require(success, "Transfer failed."); // to admin (bool success2, ) = admin.call.value(amount4admin)(""); require(success2, "Transfer failed."); // close the sell sellBidPrice[tokenId] = 0; _wallets[tokenId] = address(0); soldFor[tokenId] = msg.value; emit Sale(tokenId, owner, msg.sender, msg.value); emit Commission(tokenId, owner, msg.value, commissionRate, amount4admin); } function canAuction(uint256 tokenId) public view returns (bool) { return (ownerOf(tokenId)==msg.sender && !auctions[tokenId].open && sellBidPrice[tokenId]==0); } // Instantiate an auction contract for a tokenId function createAuction(uint256 tokenId, uint _closingTime, address payable _beneficiary, uint256 _reservePrice) public { require(sellBidPrice[tokenId]==0, "ERC721Matcha: The selected NFT is open for sale, cannot be auctioned"); require(!auctions[tokenId].open, "ERC721Matcha: The selected NFT already has an auction"); require(ownerOf(tokenId)==msg.sender, "ERC721Matcha: Only owner can auction this item"); auctions[tokenId].beneficiary = _beneficiary; auctions[tokenId].auctionEnd = _closingTime; auctions[tokenId].reserve = _reservePrice; auctions[tokenId].open = true; // approve the Index to the current contract approve(address(this), tokenId); } function canBid(uint256 tokenId) public view returns (bool) { if (!msg.sender.isContract() && auctions[tokenId].open && now <= auctions[tokenId].auctionEnd && msg.sender != ownerOf(tokenId) && getApproved(tokenId) == address(this) ) { return true; } else { return false; } } /// Bid on the auction with the value sent /// together with this transaction. /// The value will only be refunded if the /// auction is not won. function bid(uint256 tokenId) public payable nonReentrant { // No arguments are necessary, all // information is already part of // the transaction. The keyword payable // is required for the function to // be able to receive Ether. // Contracts cannot bid, because they can block the auction with a reentrant attack require(!msg.sender.isContract(), "No script kiddies"); // auction has to be opened require(auctions[tokenId].open, "No opened auction found"); // approve was lost require(getApproved(tokenId) == address(this), "Cannot complete the auction"); // Revert the call if the bidding // period is over. require( now <= auctions[tokenId].auctionEnd, "Auction already ended." ); // If the bid is not higher, send the // money back. require( msg.value > auctions[tokenId].highestBid, "There already is a higher bid." ); address owner = ownerOf(tokenId); require(msg.sender!=owner, "ERC721Matcha: The owner cannot bid his own collectible"); // return the funds to the previous bidder, if there is one if (auctions[tokenId].highestBid>0) { (bool success, ) = auctions[tokenId].highestBidder.call.value(auctions[tokenId].highestBid)(""); require(success, "Transfer failed."); emit Refund(auctions[tokenId].highestBidder, auctions[tokenId].highestBid); } // now store the bid data auctions[tokenId].highestBidder = msg.sender; auctions[tokenId].highestBid = msg.value; emit HighestBidIncreased(msg.sender, msg.value, tokenId); } // anyone can execute withdraw if auction is opened and // the bid time expired and the reserve was not met // or // the auction is openen but the contract is unable to transfer function canWithdraw(uint256 tokenId) public view returns (bool) { if (auctions[tokenId].open && ( ( now >= auctions[tokenId].auctionEnd && auctions[tokenId].highestBid > 0 && auctions[tokenId].highestBid<auctions[tokenId].reserve ) || getApproved(tokenId) != address(this) ) ) { return true; } else { return false; } } /// Withdraw a bid when the auction is not finalized function withdraw(uint256 tokenId) public nonReentrant returns (bool) { require(canWithdraw(tokenId), "Conditions to withdraw are not met"); // transfer funds to highest bidder always if (auctions[tokenId].highestBid > 0) { (bool success, ) = auctions[tokenId].highestBidder.call.value(auctions[tokenId].highestBid)(""); require(success, "Transfer failed."); } // finalize the auction delete auctions[tokenId]; } function canFinalize(uint256 tokenId) public view returns (bool) { if (auctions[tokenId].open && now >= auctions[tokenId].auctionEnd && ( auctions[tokenId].highestBid>=auctions[tokenId].reserve || auctions[tokenId].highestBid==0 ) ) { return true; } else { return false; } } // implement the auctionFinalize including the NFT transfer logic function auctionFinalize(uint256 tokenId) public nonReentrant { require(canFinalize(tokenId), "Cannot finalize"); if (auctions[tokenId].highestBid>0) { // transfer the ownership of token to the highest bidder address payable highestBidder = auctions[tokenId].highestBidder; // calculate payment amounts uint256 amount4admin = auctions[tokenId].highestBid.mul(commissionRate).div(100); uint256 amount4owner = auctions[tokenId].highestBid.sub(amount4admin); // to owner (bool success, ) = auctions[tokenId].beneficiary.call.value(amount4owner)(""); require(success, "Transfer failed."); // to admin (bool success2, ) = admin.call.value(amount4admin)(""); require(success2, "Transfer failed."); emit Sale(tokenId, auctions[tokenId].beneficiary, highestBidder, auctions[tokenId].highestBid); emit Commission(tokenId, auctions[tokenId].beneficiary, auctions[tokenId].highestBid, commissionRate, amount4admin); // transfer ownership address owner = ownerOf(tokenId); // we need to call a transferFrom from this contract, which is the one with permission to sell the NFT // transfer the NFT to the auction's highest bidder callOptionalReturn(this, abi.encodeWithSelector(this.transferFrom.selector, owner, highestBidder, tokenId)); soldFor[tokenId] = auctions[tokenId].highestBid; } emit AuctionEnded(auctions[tokenId].highestBidder, auctions[tokenId].highestBid); // finalize the auction delete auctions[tokenId]; } // Bid query functions function highestBidder(uint256 tokenId) public view returns (address payable) { return auctions[tokenId].highestBidder; } function highestBid(uint256 tokenId) public view returns (uint256) { return auctions[tokenId].highestBid; } /** * @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(IERC721 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(), "SafeERC721: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC721: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC721: ERC20 operation did not succeed"); } } // update contract fields function updateAdmin(address payable _admin, uint256 _commissionRate, bool _anyoneCanMint) public { require(msg.sender==contract_owner, "Only contract owner can do this"); admin=_admin; commissionRate=_commissionRate; anyoneCanMint=_anyoneCanMint; } }
0x6080604052600436106102935760003560e01c806370a082311161015a578063b1cb48ef116100c1578063dc16bd431161007a578063dc16bd4314610d88578063e4e2bfe414610db2578063e757223014610ddc578063e985e9c514610e24578063ee1b59e414610e5f578063fbe85f0614610e7457610293565b8063b1cb48ef14610bc2578063b2ecfad414610c07578063b88d4fde14610c31578063c87b56dd14610d02578063d04c698314610d2c578063d96a094a14610d6b57610293565b8063a22cb46511610113578063a22cb46514610ab2578063a36b146214610aed578063a9059cbb14610b17578063aa271e1a14610b50578063b13fbe9614610b83578063b14c63c514610b9857610293565b806370a08231146109755780638462151c146109a857806389f4c0b114610a2b57806395d89b4114610a55578063983b2d5614610a6a5780639865027514610a9d57610293565b8063384f58eb116101fe5780634f558e79116101b75780634f558e79146107075780634f6ccce71461073157806350bb4e7f1461075b578063571a26a01461082157806361a09c971461088f5780636352211e1461094b57610293565b8063384f58eb146106055780633ca88a2f1461061a57806340c10f191461064457806342842e0e1461067d578063451df52e146106c0578063454a2ab3146106ea57610293565b806318160ddd1161025057806318160ddd146104df5780631ac70f6f146104f457806323b872dd1461051e578063263f5877146105615780632e1a7d4d146105a25780632f745c59146105cc57610293565b806301ffc9a71461029857806306fdde03146102e0578063081812fc1461036a578063095ea7b3146103b0578063162094c4146103eb578063172b099d146104a3575b600080fd5b3480156102a457600080fd5b506102cc600480360360208110156102bb57600080fd5b50356001600160e01b031916610e9e565b604080519115158252519081900360200190f35b3480156102ec57600080fd5b506102f5610ec1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561032f578181015183820152602001610317565b50505050905090810190601f16801561035c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561037657600080fd5b506103946004803603602081101561038d57600080fd5b5035610f58565b604080516001600160a01b039092168252519081900360200190f35b3480156103bc57600080fd5b506103e9600480360360408110156103d357600080fd5b506001600160a01b038135169060200135610fbd565b005b3480156103f757600080fd5b506103e96004803603604081101561040e57600080fd5b81359190810190604081016020820135600160201b81111561042f57600080fd5b82018360208201111561044157600080fd5b803590602001918460018302840111600160201b8311171561046257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506110d4945050505050565b3480156104af57600080fd5b506104cd600480360360208110156104c657600080fd5b50356110e2565b60408051918252519081900360200190f35b3480156104eb57600080fd5b506104cd6110f4565b34801561050057600080fd5b506102cc6004803603602081101561051757600080fd5b50356110fa565b34801561052a57600080fd5b506103e96004803603606081101561054157600080fd5b506001600160a01b0381358116916020810135909116906040013561114c565b34801561056d57600080fd5b506103e96004803603606081101561058457600080fd5b506001600160a01b03813516906020810135906040013515156111a4565b3480156105ae57600080fd5b506102cc600480360360208110156105c557600080fd5b503561123d565b3480156105d857600080fd5b506104cd600480360360408110156105ef57600080fd5b506001600160a01b0381351690602001356113f4565b34801561061157600080fd5b50610394611476565b34801561062657600080fd5b506104cd6004803603602081101561063d57600080fd5b5035611485565b34801561065057600080fd5b506102cc6004803603604081101561066757600080fd5b506001600160a01b03813516906020013561150b565b34801561068957600080fd5b506103e9600480360360608110156106a057600080fd5b506001600160a01b03813581169160208101359091169060400135611569565b3480156106cc57600080fd5b50610394600480360360208110156106e357600080fd5b5035611584565b6103e96004803603602081101561070057600080fd5b50356115a2565b34801561071357600080fd5b506102cc6004803603602081101561072a57600080fd5b50356119e5565b34801561073d57600080fd5b506104cd6004803603602081101561075457600080fd5b50356119f0565b34801561076757600080fd5b506102cc6004803603606081101561077e57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b8111156107ad57600080fd5b8201836020820111156107bf57600080fd5b803590602001918460018302840111600160201b831117156107e057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611a59945050505050565b34801561082d57600080fd5b5061084b6004803603602081101561084457600080fd5b5035611ac2565b604080516001600160a01b0397881681526020810196909652939095168484015260608401919091521515608083015260a082019290925290519081900360c00190f35b34801561089b57600080fd5b506102cc600480360360408110156108b257600080fd5b810190602081018135600160201b8111156108cc57600080fd5b8201836020820111156108de57600080fd5b803590602001918460018302840111600160201b831117156108ff57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550505090356001600160a01b03169150611b099050565b34801561095757600080fd5b506103946004803603602081101561096e57600080fd5b5035611b83565b34801561098157600080fd5b506104cd6004803603602081101561099857600080fd5b50356001600160a01b0316611bda565b3480156109b457600080fd5b506109db600480360360208110156109cb57600080fd5b50356001600160a01b0316611c45565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610a175781810151838201526020016109ff565b505050509050019250505060405180910390f35b348015610a3757600080fd5b506102cc60048036036020811015610a4e57600080fd5b5035611ca6565b348015610a6157600080fd5b506102f5611d3b565b348015610a7657600080fd5b506103e960048036036020811015610a8d57600080fd5b50356001600160a01b0316611d9c565b348015610aa957600080fd5b506103e9611ded565b348015610abe57600080fd5b506103e960048036036040811015610ad557600080fd5b506001600160a01b0381351690602001351515611df8565b348015610af957600080fd5b506104cd60048036036020811015610b1057600080fd5b5035611ec7565b348015610b2357600080fd5b506103e960048036036040811015610b3a57600080fd5b506001600160a01b038135169060200135611ed9565b348015610b5c57600080fd5b506102cc60048036036020811015610b7357600080fd5b50356001600160a01b0316611ee4565b348015610b8f57600080fd5b506102cc611ef7565b348015610ba457600080fd5b506104cd60048036036020811015610bbb57600080fd5b5035611f00565b348015610bce57600080fd5b506103e960048036036080811015610be557600080fd5b508035906020810135906001600160a01b036040820135169060600135611f15565b348015610c1357600080fd5b506102cc60048036036020811015610c2a57600080fd5b503561205f565b348015610c3d57600080fd5b506103e960048036036080811015610c5457600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610c8e57600080fd5b820183602082011115610ca057600080fd5b803590602001918460018302840111600160201b83111715610cc157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612096945050505050565b348015610d0e57600080fd5b506102f560048036036020811015610d2557600080fd5b50356120eb565b348015610d3857600080fd5b506103e960048036036060811015610d4f57600080fd5b50803590602081013590604001356001600160a01b03166121c9565b6103e960048036036020811015610d8157600080fd5b50356122be565b348015610d9457600080fd5b506103e960048036036020811015610dab57600080fd5b50356126ef565b348015610dbe57600080fd5b506102cc60048036036020811015610dd557600080fd5b5035612b6b565b348015610de857600080fd5b50610e0660048036036020811015610dff57600080fd5b5035612be3565b60408051938452602084019290925282820152519081900360600190f35b348015610e3057600080fd5b506102cc60048036036040811015610e4757600080fd5b506001600160a01b0381358116916020013516612c62565b348015610e6b57600080fd5b506102cc612c90565b348015610e8057600080fd5b506102cc60048036036020811015610e9757600080fd5b5035612cad565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60098054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f4d5780601f10610f2257610100808354040283529160200191610f4d565b820191906000526020600020905b815481529060010190602001808311610f3057829003601f168201915b505050505090505b90565b6000610f6382612d42565b610fa157604051600160e51b62461bcd02815260040180806020018281038252602c815260200180613cb7602c913960400191505060405180910390fd5b506000908152600260205260409020546001600160a01b031690565b6000610fc882611b83565b9050806001600160a01b0316836001600160a01b0316141561101e57604051600160e51b62461bcd028152600401808060200182810382526021815260200180613dcd6021913960400191505060405180910390fd5b336001600160a01b038216148061103a575061103a8133612c62565b61107857604051600160e51b62461bcd028152600401808060200182810382526038815260200180613b996038913960400191505060405180910390fd5b60008281526002602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6110de8282612d5f565b5050565b60146020526000908152604090205481565b60075490565b60003361110683611b83565b6001600160a01b031614801561112e575060008281526016602052604090206004015460ff16155b80156111465750600082815260146020526040902054155b92915050565b6111563382612dc5565b61119457604051600160e51b62461bcd028152600401808060200182810382526031815260200180613e1b6031913960400191505060405180910390fd5b61119f838383612e6c565b505050565b6011546001600160a01b031633146112065760408051600160e51b62461bcd02815260206004820152601f60248201527f4f6e6c7920636f6e7472616374206f776e65722063616e20646f207468697300604482015290519081900360640190fd5b601080546001600160a01b0319166001600160a01b039490941693909317909255601255600d805460ff1916911515919091179055565b600f80546001019081905560009061125483612cad565b61129257604051600160e51b62461bcd028152600401808060200182810382526022815260200180613ee06022913960400191505060405180910390fd5b6000838152601660205260409020600301541561136057600083815260166020526040808220600281015460039091015491516001600160a01b0390911691908381818185875af1925050503d806000811461130a576040519150601f19603f3d011682016040523d82523d6000602084013e61130f565b606091505b505090508061135e5760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b505b600083815260166020526040812080546001600160a01b031990811682556001820183905560028201805490911690556003810182905560048101805460ff1916905560050155600f5481146113ee5760408051600160e51b62461bcd02815260206004820152601f6024820152600080516020613a3c833981519152604482015290519081900360640190fd5b50919050565b60006113ff83611bda565b821061143f57604051600160e51b62461bcd02815260040180806020018281038252602b815260200180613a8a602b913960400191505060405180910390fd5b6001600160a01b038316600090815260056020526040902080548390811061146357fe5b9060005260206000200154905092915050565b6011546001600160a01b031681565b60008181526016602052604081206004015460ff161580156114b4575060008281526014602052604090205415155b80156114cd575060008281526014602052604090205415155b80156114e95750306114de83610f58565b6001600160a01b0316145b156115035750600081815260146020526040902054610ebc565b506000610ebc565b60006060611517612c90565b61155557604051600160e51b62461bcd028152600401808060200182810382526030815260200180613c456030913960400191505060405180910390fd5b61155f8484612e8b565b5060019392505050565b61119f83838360405180602001604052806000815250612096565b6000908152601660205260409020600201546001600160a01b031690565b600f8054600101908190556115b633612ea8565b1561160b5760408051600160e51b62461bcd02815260206004820152601160248201527f4e6f20736372697074206b696464696573000000000000000000000000000000604482015290519081900360640190fd5b60008281526016602052604090206004015460ff166116745760408051600160e51b62461bcd02815260206004820152601760248201527f4e6f206f70656e65642061756374696f6e20666f756e64000000000000000000604482015290519081900360640190fd5b3061167e83610f58565b6001600160a01b0316146116dc5760408051600160e51b62461bcd02815260206004820152601b60248201527f43616e6e6f7420636f6d706c657465207468652061756374696f6e0000000000604482015290519081900360640190fd5b6000828152601660205260409020600101544211156117455760408051600160e51b62461bcd02815260206004820152601660248201527f41756374696f6e20616c726561647920656e6465642e00000000000000000000604482015290519081900360640190fd5b60008281526016602052604090206003015434116117ad5760408051600160e51b62461bcd02815260206004820152601e60248201527f546865726520616c7265616479206973206120686967686572206269642e0000604482015290519081900360640190fd5b60006117b883611b83565b9050336001600160a01b038216141561180557604051600160e51b62461bcd028152600401808060200182810382526036815260200180613f026036913960400191505060405180910390fd5b6000838152601660205260409020600301541561193357600083815260166020526040808220600281015460039091015491516001600160a01b0390911691908381818185875af1925050503d806000811461187d576040519150601f19603f3d011682016040523d82523d6000602084013e611882565b606091505b50509050806118d15760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b600084815260166020908152604091829020600281015460039091015483516001600160a01b0390921682529181019190915281517fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d929181900390910190a1505b6000838152601660209081526040918290206002810180546001600160a01b031916339081179091553460039092018290558351918252918101869052825191927fdafc4a123c6bb3b49dd38a0cba299808581a0126a37248a5f1102d5e5fa0633792918290030190a250600f5481146110de5760408051600160e51b62461bcd02815260206004820152601f6024820152600080516020613a3c833981519152604482015290519081900360640190fd5b600061114682612d42565b60006119fa6110f4565b8210611a3a57604051600160e51b62461bcd02815260040180806020018281038252602c815260200180613e4c602c913960400191505060405180910390fd5b60078281548110611a4757fe5b90600052602060002001549050919050565b60006060611a65612c90565b611aa357604051600160e51b62461bcd028152600401808060200182810382526030815260200180613c456030913960400191505060405180910390fd5b611aad8585612e8b565b611ab78484612d5f565b506001949350505050565b6016602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b0394851695939490921692909160ff9091169086565b60006060611b15612c90565b611b5357604051600160e51b62461bcd028152600401808060200182810382526030815260200180613c456030913960400191505060405180910390fd5b600e805460010190819055611b6790612d42565b611b5357611b7783600e54612e8b565b61155f600e5485612d5f565b6000818152600160205260408120546001600160a01b03168061114657604051600160e51b62461bcd028152600401808060200182810382526029815260200180613bfb6029913960400191505060405180910390fd5b60006001600160a01b038216611c2457604051600160e51b62461bcd02815260040180806020018281038252602a815260200180613bd1602a913960400191505060405180910390fd5b6001600160a01b038216600090815260036020526040902061114690612edf565b6060611c5082612ee3565b805480602002602001604051908101604052809291908181526020018280548015611c9a57602002820191906000526020600020905b815481526020019060010190808311611c86575b50505050509050919050565b6000611cb133612ea8565b158015611ccf575060008281526016602052604090206004015460ff165b8015611cec57506000828152601660205260409020600101544211155b8015611d125750611cfc82611b83565b6001600160a01b0316336001600160a01b031614155b8015611d2e575030611d2383610f58565b6001600160a01b0316145b1561150357506001610ebc565b600a8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f4d5780601f10610f2257610100808354040283529160200191610f4d565b6060611da6612c90565b611de457604051600160e51b62461bcd028152600401808060200182810382526030815260200180613c456030913960400191505060405180910390fd5b6110de82612efd565b611df633612f45565b565b6001600160a01b038216331415611e595760408051600160e51b62461bcd02815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b60136020526000908152604090205481565b6110de338383612e6c565b6000611146600c8363ffffffff612f8d16565b600d5460ff1681565b60009081526016602052604090206003015490565b60008481526014602052604090205415611f6357604051600160e51b62461bcd028152600401808060200182810382526044815260200180613d896044913960600191505060405180910390fd5b60008481526016602052604090206004015460ff1615611fb757604051600160e51b62461bcd028152600401808060200182810382526035815260200180613a076035913960400191505060405180910390fd5b33611fc185611b83565b6001600160a01b03161461200957604051600160e51b62461bcd02815260040180806020018281038252602e815260200180613a5c602e913960400191505060405180910390fd5b600084815260166020526040902080546001600160a01b0319166001600160a01b0384161781556001808201859055600582018390556004909101805460ff191690911790556120593085610fbd565b50505050565b60003361206b83611b83565b6001600160a01b031614801561114657505060009081526016602052604090206004015460ff161590565b6120a184848461114c565b6120ad84848484612ff7565b61205957604051600160e51b62461bcd028152600401808060200182810382526032815260200180613ab56032913960400191505060405180910390fd5b60606120f682612d42565b61213457604051600160e51b62461bcd02815260040180806020018281038252602f815260200180613d5a602f913960400191505060405180910390fd5b6000828152600b602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015611c9a5780601f1061219c57610100808354040283529160200191611c9a565b820191906000526020600020905b8154815290600101906020018083116121aa5750939695505050505050565b336121d384611b83565b6001600160a01b03161461221b57604051600160e51b62461bcd02815260040180806020018281038252602b815260200180613ae7602b913960400191505060405180910390fd5b60008381526016602052604090206004015460ff161561226f57604051600160e51b62461bcd02815260040180806020018281038252603d815260200180613ea3603d913960400191505060405180910390fd5b6000838152601460205260409020829055811561119f576122903084610fbd565b600083815260156020526040902080546001600160a01b0383166001600160a01b0319909116179055505050565b600f80546001019081905560008281526016602052604090206004015460ff161580156122f8575060008281526014602052604090205415155b61233657604051600160e51b62461bcd02815260040180806020018281038252602d815260200180613dee602d913960400191505060405180910390fd5b60008281526014602052604090205434101561239c5760408051600160e51b62461bcd02815260206004820152601e60248201527f4552433732314d61746368613a204e6f7420656e6f7567682066756e64730000604482015290519081900360640190fd5b60006123a783611b83565b9050336001600160a01b03821614156123f457604051600160e51b62461bcd028152600401808060200182810382526037815260200180613b366037913960400191505060405180910390fd5b604080516001600160a01b038316602482015233604482015260648082018690528251808303909101815260849091019091526020810180516001600160e01b0316600160e01b6323b872dd0217905261244f903090613130565b6000612477606461246b601254346132db90919063ffffffff16565b9063ffffffff61333e16565b9050600061248b348363ffffffff6133ab16565b60008681526015602052604080822054905192935090916001600160a01b039091169083908381818185875af1925050503d80600081146124e8576040519150601f19603f3d011682016040523d82523d6000602084013e6124ed565b606091505b505090508061253c5760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b6010546040516000916001600160a01b03169085908381818185875af1925050503d8060008114612589576040519150601f19603f3d011682016040523d82523d6000602084013e61258e565b606091505b50509050806125dd5760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b60008781526014602090815260408083208390556015825280832080546001600160a01b0319169055601382529182902034908190558251908152915133926001600160a01b038916928b927f88863d5e20f64464b554931394e2e4b6f09c10015147215bf26b3ba5070acebe9281900390910190a4601254604080513481526020810192909252818101869052516001600160a01b0387169189917fef7a63d352d8b0f42e35d7f8bd277ba75ba2ff721a50eaad4c62f1ee6561d5eb9181900360600190a35050505050600f5481146110de5760408051600160e51b62461bcd02815260206004820152601f6024820152600080516020613a3c833981519152604482015290519081900360640190fd5b600f80546001019081905561270382612b6b565b6127575760408051600160e51b62461bcd02815260206004820152600f60248201527f43616e6e6f742066696e616c697a650000000000000000000000000000000000604482015290519081900360640190fd5b60008281526016602052604090206003015415612a7d57600082815260166020526040812060028101546012546003909201546001600160a01b0390911692916127ae9160649161246b919063ffffffff6132db16565b600085815260166020526040812060030154919250906127d4908363ffffffff6133ab16565b60008681526016602052604080822054905192935090916001600160a01b039091169083908381818185875af1925050503d8060008114612831576040519150601f19603f3d011682016040523d82523d6000602084013e612836565b606091505b50509050806128855760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b6010546040516000916001600160a01b03169085908381818185875af1925050503d80600081146128d2576040519150601f19603f3d011682016040523d82523d6000602084013e6128d7565b606091505b50509050806129265760408051600160e51b62461bcd0281526020600482015260106024820152600160811b6f2a3930b739b332b9103330b4b632b21702604482015290519081900360640190fd5b6000878152601660209081526040918290208054600390910154835190815292516001600160a01b03808a16949216928b927f88863d5e20f64464b554931394e2e4b6f09c10015147215bf26b3ba5070acebe929081900390910190a4600087815260166020908152604091829020805460039091015460125484519182529281019290925281830187905291516001600160a01b039092169189917fef7a63d352d8b0f42e35d7f8bd277ba75ba2ff721a50eaad4c62f1ee6561d5eb919081900360600190a360006129f888611b83565b604080516001600160a01b0380841660248301528916604482015260648082018c90528251808303909101815260849091019091526020810180516001600160e01b0316600160e01b6323b872dd02179052909150612a58903090613130565b5050506000858152601660209081526040808320600301546013909252909120555050505b600082815260166020908152604091829020600281015460039091015483516001600160a01b0390921682529181019190915281517fdaec4582d5d9595688c8c98545fdd1c696d41c6aeaeb636737e84ed2f5c00eda929181900390910190a1600082815260166020526040812080546001600160a01b031990811682556001820183905560028201805490911690556003810182905560048101805460ff1916905560050155600f5481146110de5760408051600160e51b62461bcd02815260206004820152601f6024820152600080516020613a3c833981519152604482015290519081900360640190fd5b60008181526016602052604081206004015460ff168015612b9d57506000828152601660205260409020600101544210155b8015611d2e575060008281526016602052604090206005810154600390910154101580611d2e575060008281526016602052604090206003015461150357506001610ebc565b6000818152601460205260408120548190819015612c14575050506000818152601460205260408120549080612c5b565b60008481526016602052604090206003015415612c465750505060008181526016602052604081206003015481612c5b565b50505060008181526013602052604081205481905b9193909250565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b600d5460009060ff1680612ca85750612ca833611ee4565b905090565b60008181526016602052604081206004015460ff168015611d2e57506000828152601660205260409020600101544210801590612cfa575060008281526016602052604090206003015415155b8015612d1c575060008281526016602052604090206005810154600390910154105b80611d2e575030612d2c83610f58565b6001600160a01b03161461150357506001610ebc565b6000908152600160205260409020546001600160a01b0316151590565b612d6882612d42565b612da657604051600160e51b62461bcd02815260040180806020018281038252602c815260200180613ce3602c913960400191505060405180910390fd5b6000828152600b60209081526040909120825161119f9284019061394e565b6000612dd082612d42565b612e0e57604051600160e51b62461bcd02815260040180806020018281038252602c815260200180613b6d602c913960400191505060405180910390fd5b6000612e1983611b83565b9050806001600160a01b0316846001600160a01b03161480612e545750836001600160a01b0316612e4984610f58565b6001600160a01b0316145b80612e645750612e648185612c62565b949350505050565b612e7783838361340b565b612e818382613555565b61119f828261364a565b612e958282613688565b612e9f828261364a565b6110de816137bf565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708115801590612e645750141592915050565b5490565b6001600160a01b0316600090815260056020526040902090565b612f0e600c8263ffffffff61380316565b6040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b612f56600c8263ffffffff61388716565b6040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b60006001600160a01b038216612fd757604051600160e51b62461bcd028152600401808060200182810382526022815260200180613d0f6022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b600061300b846001600160a01b0316612ea8565b61301757506001612e64565b604051600160e11b630a85bd0102815233600482018181526001600160a01b03888116602485015260448401879052608060648501908152865160848601528651600095928a169463150b7a029490938c938b938b939260a4019060208501908083838e5b8381101561309457818101518382015260200161307c565b50505050905090810190601f1680156130c15780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156130e357600080fd5b505af11580156130f7573d6000803e3d6000fd5b505050506040513d602081101561310d57600080fd5b50516001600160e01b031916600160e11b630a85bd010214915050949350505050565b613142826001600160a01b0316612ea8565b6131965760408051600160e51b62461bcd02815260206004820181905260248201527f536166654552433732313a2063616c6c20746f206e6f6e2d636f6e7472616374604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106131d45780518252601f1990920191602091820191016131b5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613236576040519150601f19603f3d011682016040523d82523d6000602084013e61323b565b606091505b50915091508161327f57604051600160e51b62461bcd028152600401808060200182810382526021815260200180613c246021913960400191505060405180910390fd5b8051156120595780806020019051602081101561329b57600080fd5b505161205957604051600160e51b62461bcd02815260040180806020018281038252602b815260200180613e78602b913960400191505060405180910390fd5b6000826132ea57506000611146565b828202828482816132f757fe5b041461333757604051600160e51b62461bcd028152600401808060200182810382526021815260200180613c966021913960400191505060405180910390fd5b9392505050565b60008082116133975760408051600160e51b62461bcd02815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b60008284816133a257fe5b04949350505050565b6000828211156134055760408051600160e51b62461bcd02815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b826001600160a01b031661341e82611b83565b6001600160a01b03161461346657604051600160e51b62461bcd028152600401808060200182810382526029815260200180613d316029913960400191505060405180910390fd5b6001600160a01b0382166134ae57604051600160e51b62461bcd028152600401808060200182810382526024815260200180613b126024913960400191505060405180910390fd5b6134b7816138f1565b6001600160a01b03831660009081526003602052604090206134d89061392e565b6001600160a01b03821660009081526003602052604090206134f990613945565b60008181526001602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b03821660009081526005602052604081205461357f90600163ffffffff6133ab16565b60008381526006602052604090205490915080821461361a576001600160a01b03841660009081526005602052604081208054849081106135bc57fe5b906000526020600020015490508060056000876001600160a01b03166001600160a01b0316815260200190815260200160002083815481106135fa57fe5b600091825260208083209091019290925591825260069052604090208190555b6001600160a01b03841660009081526005602052604090208054906136439060001983016139cc565b5050505050565b6001600160a01b0390911660009081526005602081815260408084208054868652600684529185208290559282526001810183559183529091200155565b6001600160a01b0382166136e65760408051600160e51b62461bcd02815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6136ef81612d42565b156137445760408051600160e51b62461bcd02815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b600081815260016020908152604080832080546001600160a01b0319166001600160a01b03871690811790915583526003909152902061378390613945565b60405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600780546000838152600860205260408120829055600182018355919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880155565b61380d8282612f8d565b156138625760408051600160e51b62461bcd02815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b6138918282612f8d565b6138cf57604051600160e51b62461bcd028152600401808060200182810382526021815260200180613c756021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b6000818152600260205260409020546001600160a01b03161561392b57600081815260026020526040902080546001600160a01b03191690555b50565b805461394190600163ffffffff6133ab16565b9055565b80546001019055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061398f57805160ff19168380011785556139bc565b828001600101855582156139bc579182015b828111156139bc5782518255916020019190600101906139a1565b506139c89291506139ec565b5090565b81548183558181111561119f5760008381526020902061119f9181019083015b610f5591905b808211156139c857600081556001016139f256fe4552433732314d61746368613a205468652073656c6563746564204e465420616c72656164792068617320616e2061756374696f6e5265656e7472616e637947756172643a207265656e7472616e742063616c6c004552433732314d61746368613a204f6e6c79206f776e65722063616e2061756374696f6e2074686973206974656d455243373231456e756d657261626c653a206f776e657220696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732314d61746368613a204f6e6c79206f776e65722063616e2073656c6c2074686973206974656d4552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732314d61746368613a205468652073656c6c65722063616e6e6f742062757920686973206f776e20636f6c6c65637469626c654552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e536166654552433732313a206c6f772d6c6576656c2063616c6c206661696c65644d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e526f6c65733a206163636f756e7420697320746865207a65726f20616464726573734552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d61746368613a205468652073656c6563746564204e4654206973206f70656e20666f722073616c652c2063616e6e6f742062652061756374696f6e65644552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732314d61746368613a2054686520636f6c6c65637469626c65206973206e6f7420666f722073616c654552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243373231456e756d657261626c653a20676c6f62616c20696e646578206f7574206f6620626f756e6473536166654552433732313a204552433230206f7065726174696f6e20646964206e6f7420737563636565644552433732314d61746368613a2043616e6e6f742073656c6c20616e206974656d2077686963682068617320616e206163746976652061756374696f6e436f6e646974696f6e7320746f20776974686472617720617265206e6f74206d65744552433732314d61746368613a20546865206f776e65722063616e6e6f742062696420686973206f776e20636f6c6c65637469626c65a165627a7a72305820d3217b6ed168ce6b7ca5300deebd80a96402daffd563ff2fd72587dbe10a80670029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2581, 2487, 3401, 2475, 2094, 2620, 18827, 2063, 2581, 12740, 2497, 2475, 3540, 2620, 2094, 2549, 27717, 2575, 2050, 2549, 20952, 2475, 2094, 21084, 2620, 2487, 11057, 5243, 1013, 1008, 1008, 25391, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 2213, 25391, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 2213, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 2213, 25391, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 2213, 2860, 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,916
0x97982830c57e409FC11cD8D89526f5ECb144e8D0
//IGNITE-A unprecedented prediction market of based decentralization network. //Website:IGToken.net pragma solidity ^0.4.18; /** * @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; } } contract ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } 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); } contract Ignite is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Ignite"; string public constant symbol = "IGT"; uint public constant decimals = 8; uint256 public totalSupply = 800000000e8; uint256 public totalDistributed = 400000000e8; uint256 public constant MIN_CONTRIBUTION = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 75000e8; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function Ignite () public { owner = msg.sender; distr(owner, totalDistributed); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function doAirdrop(address _participant, uint _amount) internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function adminClaimAirdrop(address _participant, uint _amount) public onlyOwner { doAirdrop(_participant, _amount); } function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner { for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; // minimum contribution require( msg.value >= MIN_CONTRIBUTION ); require( msg.value > 0 ); // get baseline number of tokens tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner 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); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461013d578063095ea7b3146101cd57806318160ddd1461023257806323b872dd1461025d578063313ce567146102e25780633ccfd60b1461030d57806340650c911461032457806342966c681461034f5780634a63464d1461037c57806367220fd7146103c957806370a082311461043957806395d89b41146104905780639b1cbccc146105205780639ea407be1461054f578063a9059cbb1461057c578063aa6ca808146105e1578063c108d542146105eb578063c489744b1461061a578063cbdd69b514610691578063dd62ed3e146106bc578063e58fc54c14610733578063efca2eed1461078e578063f2fde38b146107b9575b61013b6107fc565b005b34801561014957600080fd5b506101526108b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610192578082015181840152602081019050610177565b50505050905090810190601f1680156101bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101d957600080fd5b50610218600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ec565b604051808215151515815260200191505060405180910390f35b34801561023e57600080fd5b50610247610a7a565b6040518082815260200191505060405180910390f35b34801561026957600080fd5b506102c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a80565b604051808215151515815260200191505060405180910390f35b3480156102ee57600080fd5b506102f7610e56565b6040518082815260200191505060405180910390f35b34801561031957600080fd5b50610322610e5b565b005b34801561033057600080fd5b50610339610f44565b6040518082815260200191505060405180910390f35b34801561035b57600080fd5b5061037a60048036038101908080359060200190929190505050610f4f565b005b34801561038857600080fd5b506103c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061111b565b005b3480156103d557600080fd5b506104376004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050611185565b005b34801561044557600080fd5b5061047a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611224565b6040518082815260200191505060405180910390f35b34801561049c57600080fd5b506104a561126d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104e55780820151818401526020810190506104ca565b50505050905090810190601f1680156105125780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561052c57600080fd5b506105356112a6565b604051808215151515815260200191505060405180910390f35b34801561055b57600080fd5b5061057a6004803603810190808035906020019092919050505061136e565b005b34801561058857600080fd5b506105c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061140b565b604051808215151515815260200191505060405180910390f35b6105e96107fc565b005b3480156105f757600080fd5b50610600611646565b604051808215151515815260200191505060405180910390f35b34801561062657600080fd5b5061067b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611659565b6040518082815260200191505060405180910390f35b34801561069d57600080fd5b506106a6611744565b6040518082815260200191505060405180910390f35b3480156106c857600080fd5b5061071d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061174a565b6040518082815260200191505060405180910390f35b34801561073f57600080fd5b50610774600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117d1565b604051808215151515815260200191505060405180910390f35b34801561079a57600080fd5b506107a3611a16565b6040518082815260200191505060405180910390f35b3480156107c557600080fd5b506107fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a1c565b005b600080600760009054906101000a900460ff1615151561081b57600080fd5b60009150662386f26fc10000341015151561083557600080fd5b60003411151561084457600080fd5b670de0b6b3a764000061086234600654611af390919063ffffffff16565b81151561086b57fe5b0491503390506000821115610886576108848183611b2b565b505b6004546005541015156108af576001600760006101000a81548160ff0219169083151502179055505b5050565b6040805190810160405280600681526020017f49676e697465000000000000000000000000000000000000000000000000000081525081565b600080821415801561097b57506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b156109895760009050610a74565b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60045481565b6000606060048101600036905010151515610a9757fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610ad357600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610b2157600080fd5b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610bac57600080fd5b610bfe83600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd083600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610da283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600881565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610eba57600080fd5b3091508173ffffffffffffffffffffffffffffffffffffffff16319050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610f3f573d6000803e3d6000fd5b505050565b662386f26fc1000081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fad57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ffb57600080fd5b33905061105082600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110a882600454611cb790919063ffffffff16565b6004819055506110c382600554611cb790919063ffffffff16565b6005819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561117757600080fd5b6111818282611cec565b5050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111e357600080fd5b600090505b825181101561121f57611212838281518110151561120257fe5b9060200190602002015183611cec565b80806001019150506111e8565b505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f494754000000000000000000000000000000000000000000000000000000000081525081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561130457600080fd5b600760009054906101000a900460ff1615151561132057600080fd5b6001600760006101000a81548160ff0219169083151502179055507f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a16001905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ca57600080fd5b806006819055507ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c003816040518082815260200191505060405180910390a150565b600060406004810160003690501015151561142257fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561145e57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483111515156114ac57600080fd5b6114fe83600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061159383600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600760009054906101000a900460ff1681565b60008060008491508173ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156116fc57600080fd5b505af1158015611710573d6000803e3d6000fd5b505050506040513d602081101561172657600080fd5b81019080805190602001909291905050509050809250505092915050565b60065481565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561183257600080fd5b8391508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156118d057600080fd5b505af11580156118e4573d6000803e3d6000fd5b505050506040513d60208110156118fa57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156119d257600080fd5b505af11580156119e6573d6000803e3d6000fd5b505050506040513d60208110156119fc57600080fd5b810190808051906020019092919050505092505050919050565b60055481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a7857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515611af05780600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b600080831415611b065760009050611b25565b8183029050818382811515611b1757fe5b04141515611b2157fe5b8090505b92915050565b6000600760009054906101000a900460ff16151515611b4957600080fd5b611b5e82600554611cd090919063ffffffff16565b600581905550611bb682600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a77836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000828211151515611cc557fe5b818303905092915050565b60008183019050828110151515611ce357fe5b80905092915050565b600081111515611cfb57600080fd5b600454600554101515611d0d57600080fd5b611d5f81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611db781600554611cd090919063ffffffff16565b600581905550600454600554101515611de6576001600760006101000a81548160ff0219169083151502179055505b8173ffffffffffffffffffffffffffffffffffffffff167fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d27282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808381526020018281526020019250505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505600a165627a7a72305820d2688eb9d4f17f4463bd10673dec0db526022ad48cae335d8935a4eb6aa5199e0029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2620, 22407, 14142, 2278, 28311, 2063, 12740, 2683, 11329, 14526, 19797, 2620, 2094, 2620, 2683, 25746, 2575, 2546, 2629, 8586, 2497, 16932, 2549, 2063, 2620, 2094, 2692, 1013, 1013, 16270, 4221, 1011, 1037, 15741, 17547, 3006, 1997, 2241, 11519, 7941, 3989, 2897, 1012, 1013, 1013, 4037, 1024, 1045, 13512, 11045, 2078, 1012, 5658, 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, 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, 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,917
0x979838c9c16fd365c9fe028b0bea49b1750d86e9
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; 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)); } } abstract contract ReentrancyGuard { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); _status = _ENTERED; _; _status = _NOT_ENTERED; } } // File: openzeppelin-solidity\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); } interface ERC20 { function totalSupply() external returns (uint); function balanceOf(address who) external returns (uint); function transferFrom(address from, address to, uint value) external; function transfer(address to, uint value) external; event Transfer(address indexed from, address indexed to, uint value); } /** * @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); } } } } 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; } function ceil(uint a, uint m) internal pure returns (uint r) { return (a + m - 1) / m * m; } } 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"); } } } contract fUSDT is IERC20, ReentrancyGuard { using Address for address; using SafeMath for uint256; using SafeERC20 for IERC20; enum TxType { FromExcluded, ToExcluded, BothExcluded, Standard } mapping (address => uint256) private rUsdtBalance; mapping (address => uint256) private tUsdtBalance; mapping (address => mapping (address => uint256)) private _allowances; EnumerableSet.AddressSet excluded; uint256 private tUsdtSupply; uint256 private rUsdtSupply; uint256 private feesAccrued; string private _name = 'FEG Wrapped USDT'; string private _symbol = 'fUSDT'; uint8 private _decimals = 6; address private op; address private op2; IERC20 public lpToken; event Deposit(address indexed dst, uint amount); event Withdrawal(address indexed src, uint amount); constructor (address _lpToken) { op = address(0x4c9BC793716e8dC05d1F48D8cA8f84318Ec3043C); op2 = op; lpToken = IERC20(_lpToken); EnumerableSet.add(excluded, address(0)); // stablity - zen. emit Transfer(address(0), msg.sender, 0); } 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 tUsdtSupply; } function balanceOf(address account) public view override returns (uint256) { if (EnumerableSet.contains(excluded, account)) return tUsdtBalance[account]; (uint256 r, uint256 t) = currentSupply(); return (rUsdtBalance[account] * t) / r; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender] - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] - subtractedValue); return true; } function isExcluded(address account) public view returns (bool) { return EnumerableSet.contains(excluded, account); } function totalFees() public view returns (uint256) { return feesAccrued; } function deposit(uint256 _amount) public { require(_amount > 0, "can't deposit nothing"); lpToken.safeTransferFrom(msg.sender, address(this), _amount); (uint256 r, uint256 t) = currentSupply(); uint256 fee = _amount / 100; uint256 df = fee / 10; uint256 net = fee != 0 ? (_amount - (fee)) : _amount; tUsdtSupply += _amount; if(isExcluded(msg.sender)){ tUsdtBalance[msg.sender] += (_amount- fee); } feesAccrued += df; rUsdtBalance[op] += ((df * r) / t); rUsdtSupply += (((net + df) * r) / t); rUsdtBalance[msg.sender] += ((net * r) / t); emit Deposit(msg.sender, _amount); } function withdraw(uint256 _amount) public { require(balanceOf(msg.sender) >= _amount && _amount <= totalSupply(), "invalid _amount"); (uint256 r, uint256 t) = currentSupply(); uint256 fee = _amount / 100; uint256 wf = fee / 10; uint256 net = _amount - fee; if(isExcluded(msg.sender)) { tUsdtBalance[msg.sender] -= _amount; rUsdtBalance[msg.sender] -= ((_amount * r) / t); } else { rUsdtBalance[msg.sender] -= ((_amount * r) / t); } tUsdtSupply -= (net + wf); rUsdtSupply -= (((net + wf) * r ) / t); rUsdtBalance[op] += ((wf * r) / t); feesAccrued += wf; lpToken.safeTransfer(msg.sender, net); emit Withdrawal(msg.sender, net); } function rUsdtToEveryone(uint256 amt) public { require(!isExcluded(msg.sender), "not allowed"); (uint256 r, uint256 t) = currentSupply(); rUsdtBalance[msg.sender] -= ((amt * r) / t); rUsdtSupply -= ((amt * r) / t); feesAccrued += amt; } function excludeFromFees(address account) external { require(msg.sender == op2, "op only"); require(!EnumerableSet.contains(excluded, account), "address excluded"); if(rUsdtBalance[account] > 0) { (uint256 r, uint256 t) = currentSupply(); tUsdtBalance[account] = (rUsdtBalance[account] * (t)) / (r); } EnumerableSet.add(excluded, account); } function includeInFees(address account) external { require(msg.sender == op2, "op only"); require(EnumerableSet.contains(excluded, account), "address excluded"); tUsdtBalance[account] = 0; EnumerableSet.remove(excluded, account); } function tUsdtFromrUsdt(uint256 rUsdtAmount) external view returns (uint256) { (uint256 r, uint256 t) = currentSupply(); return (rUsdtAmount * t) / r; } 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 getTtype(address sender, address recipient) internal view returns (TxType t) { bool isSenderExcluded = EnumerableSet.contains(excluded, sender); bool isRecipientExcluded = EnumerableSet.contains(excluded, recipient); if (isSenderExcluded && !isRecipientExcluded) { t = TxType.FromExcluded; } else if (!isSenderExcluded && isRecipientExcluded) { t = TxType.ToExcluded; } else if (!isSenderExcluded && !isRecipientExcluded) { t = TxType.Standard; } else if (isSenderExcluded && isRecipientExcluded) { t = TxType.BothExcluded; } else { t = TxType.Standard; } return t; } function _transfer(address sender, address recipient, uint256 amt) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amt > 0, "Transfer amt must be greater than zero"); (uint256 r, uint256 t) = currentSupply(); uint256 fee = amt / 100; TxType tt = getTtype(sender, recipient); if (tt == TxType.ToExcluded) { rUsdtBalance[sender] -= ((amt * r) / t); tUsdtBalance[recipient] += (amt - fee); rUsdtBalance[recipient] += (((amt - fee) * r) / t); } else if (tt == TxType.FromExcluded) { tUsdtBalance[sender] -= (amt); rUsdtBalance[sender] -= ((amt * r) / t); rUsdtBalance[recipient] += (((amt - fee) * r) / t); } else if (tt == TxType.BothExcluded) { tUsdtBalance[sender] -= (amt); rUsdtBalance[sender] -= ((amt * r) / t); tUsdtBalance[recipient] += (amt - fee); rUsdtBalance[recipient] += (((amt - fee) * r) / t); } else { rUsdtBalance[sender] -= ((amt * r) / t); rUsdtBalance[recipient] += (((amt - fee) * r) / t); } rUsdtSupply -= ((fee * r) / t); feesAccrued += fee; emit Transfer(sender, recipient, amt - fee); } function currentSupply() public view returns(uint256, uint256) { if(rUsdtSupply == 0 || tUsdtSupply == 0) return (1000000000, 1); uint256 rSupply = rUsdtSupply; uint256 tSupply = tUsdtSupply; for (uint256 i = 0; i < EnumerableSet.length(excluded); i++) { if (rUsdtBalance[EnumerableSet.at(excluded, i)] > rSupply || tUsdtBalance[EnumerableSet.at(excluded, i)] > tSupply) return (rUsdtSupply, tUsdtSupply); rSupply -= (rUsdtBalance[EnumerableSet.at(excluded, i)]); tSupply -= (tUsdtBalance[EnumerableSet.at(excluded, i)]); } if (rSupply < rUsdtSupply / tUsdtSupply) return (rUsdtSupply, tUsdtSupply); return (rSupply, tSupply); } function setOp(address opper, address opper2) external { require(msg.sender == op, "only op can call"); op = opper; op2 = opper2; } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80635fcbd285116100b8578063a9059cbb1161007c578063a9059cbb1461038e578063b6b55f25146103be578063cba0e996146103da578063d2ac95a01461040a578063dd62ed3e14610426578063e57f14e11461045657610142565b80635fcbd285146102d357806370a08231146102f1578063771282f61461032157806395d89b4114610340578063a457c2d71461035e57610142565b806318160ddd1161010a57806318160ddd146101ff57806323b872dd1461021d5780632b4142641461024d5780632e1a7d4d14610269578063313ce5671461028557806339509351146102a357610142565b8063034f5d1b1461014757806306fdde0314610177578063095ea7b31461019557806313114a9d146101c557806316a2f82a146101e3575b600080fd5b610161600480360381019061015c9190612a73565b610472565b60405161016e9190612fca565b60405180910390f35b61017f6104a3565b60405161018c9190612de8565b60405180910390f35b6101af60048036038101906101aa9190612a0e565b610535565b6040516101bc9190612db2565b60405180910390f35b6101cd61054c565b6040516101da9190612fca565b60405180910390f35b6101fd60048036038101906101f8919061295a565b610556565b005b610207610684565b6040516102149190612fca565b60405180910390f35b610237600480360381019061023291906129bf565b61068e565b6040516102449190612db2565b60405180910390f35b61026760048036038101906102629190612983565b610738565b005b610283600480360381019061027e9190612a73565b61084e565b005b61028d610bd7565b60405161029a919061300e565b60405180910390f35b6102bd60048036038101906102b89190612a0e565b610bee565b6040516102ca9190612db2565b60405180910390f35b6102db610c8c565b6040516102e89190612dcd565b60405180910390f35b61030b6004803603810190610306919061295a565b610cb2565b6040516103189190612fca565b60405180910390f35b610329610d7a565b604051610337929190612fe5565b60405180910390f35b610348610f74565b6040516103559190612de8565b60405180910390f35b61037860048036038101906103739190612a0e565b611006565b6040516103859190612db2565b60405180910390f35b6103a860048036038101906103a39190612a0e565b6110a4565b6040516103b59190612db2565b60405180910390f35b6103d860048036038101906103d39190612a73565b6110bb565b005b6103f460048036038101906103ef919061295a565b6113c9565b6040516104019190612db2565b60405180910390f35b610424600480360381019061041f9190612a73565b6113dd565b005b610440600480360381019061043b9190612983565b6114ee565b60405161044d9190612fca565b60405180910390f35b610470600480360381019061046b919061295a565b611575565b005b600080600061047f610d7a565b9150915081818561049091906130e2565b61049a91906130b1565b92505050919050565b6060600980546104b29061321c565b80601f01602080910402602001604051908101604052809291908181526020018280546104de9061321c565b801561052b5780601f106105005761010080835404028352916020019161052b565b820191906000526020600020905b81548152906001019060200180831161050e57829003601f168201915b5050505050905090565b6000610542338484611782565b6001905092915050565b6000600854905090565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105dd90612eca565b60405180910390fd5b6105f160048261194d565b610630576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062790612e8a565b60405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061068060048261197d565b5050565b6000600654905090565b600061069b8484846119ad565b61072d843384600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610728919061313c565b611782565b600190509392505050565b600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107bf90612f2a565b60405180910390fd5b81600b60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b8061085833610cb2565b1015801561086d5750610869610684565b8111155b6108ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a390612eea565b60405180910390fd5b6000806108b7610d7a565b9150915060006064846108ca91906130b1565b90506000600a826108db91906130b1565b9050600082866108eb919061313c565b90506108f6336113c9565b156109c25785600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461094a919061313c565b9250508190555083858761095e91906130e2565b61096891906130b1565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109b6919061313c565b92505081905550610a2f565b8385876109cf91906130e2565b6109d991906130b1565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a27919061313c565b925050819055505b8181610a3b919061305b565b60066000828254610a4c919061313c565b9250508190555083858383610a61919061305b565b610a6b91906130e2565b610a7591906130b1565b60076000828254610a86919061313c565b92505081905550838583610a9a91906130e2565b610aa491906130b1565b60016000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b14919061305b565b925050819055508160086000828254610b2d919061305b565b92505081905550610b813382600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166122369092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b6582604051610bc79190612fca565b60405180910390a2505050505050565b6000600b60009054906101000a900460ff16905090565b6000610c82338484600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7d919061305b565b611782565b6001905092915050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610cbf60048361194d565b15610d0b57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610d75565b600080610d16610d7a565b915091508181600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d6691906130e2565b610d7091906130b1565b925050505b919050565b60008060006007541480610d9057506000600654145b15610da557633b9aca00600191509150610f70565b600060075490506000600654905060005b610dc060046122bc565b811015610f3e578260016000610dd76004856122d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180610e6657508160026000610e296004856122d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15610e7d5760075460065494509450505050610f70565b60016000610e8c6004846122d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610ed2919061313c565b925060026000610ee36004846122d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610f29919061313c565b91508080610f369061324e565b915050610db6565b50600654600754610f4f91906130b1565b821015610f6757600754600654935093505050610f70565b81819350935050505b9091565b6060600a8054610f839061321c565b80601f0160208091040260200160405190810160405280929190818152602001828054610faf9061321c565b8015610ffc5780601f10610fd157610100808354040283529160200191610ffc565b820191906000526020600020905b815481529060010190602001808311610fdf57829003601f168201915b5050505050905090565b600061109a338484600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611095919061313c565b611782565b6001905092915050565b60006110b13384846119ad565b6001905092915050565b600081116110fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f590612e4a565b60405180910390fd5b61114d333083600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166122eb909392919063ffffffff16565b600080611158610d7a565b91509150600060648461116b91906130b1565b90506000600a8261117c91906130b1565b905060008083141561118e578561119b565b828661119a919061313c565b5b905085600660008282546111af919061305b565b925050819055506111bf336113c9565b156112265782866111d0919061313c565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461121e919061305b565b925050819055505b8160086000828254611238919061305b565b9250508190555083858361124c91906130e2565b61125691906130b1565b60016000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112c6919061305b565b92505081905550838583836112db919061305b565b6112e591906130e2565b6112ef91906130b1565b60076000828254611300919061305b565b9250508190555083858261131491906130e2565b61131e91906130b1565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461136c919061305b565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c876040516113b99190612fca565b60405180910390a2505050505050565b60006113d660048361194d565b9050919050565b6113e6336113c9565b15611426576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141d90612eaa565b60405180910390fd5b600080611431610d7a565b9150915080828461144291906130e2565b61144c91906130b1565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461149a919061313c565b925050819055508082846114ae91906130e2565b6114b891906130b1565b600760008282546114c9919061313c565b9250508190555082600860008282546114e2919061305b565b92505081905550505050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611605576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115fc90612eca565b60405180910390fd5b61161060048261194d565b15611650576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164790612e8a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611743576000806116a3610d7a565b915091508181600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116f391906130e2565b6116fd91906130b1565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505b61174e600482611752565b5050565b600061177a836000018373ffffffffffffffffffffffffffffffffffffffff1660001b612374565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156117f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e990612f4a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611862576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185990612e6a565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516119409190612fca565b60405180910390a3505050565b6000611975836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6123e4565b905092915050565b60006119a5836000018373ffffffffffffffffffffffffffffffffffffffff1660001b612407565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611a1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a1490612f0a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8490612e2a565b60405180910390fd5b60008111611ad0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac790612faa565b60405180910390fd5b600080611adb610d7a565b915091506000606484611aee91906130b1565b90506000611afc8787612591565b905060016003811115611b38577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b816003811115611b71577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b1415611cc057828486611b8491906130e2565b611b8e91906130b1565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611bdc919061313c565b925050819055508185611bef919061313c565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c3d919061305b565b9250508190555082848387611c52919061313c565b611c5c91906130e2565b611c6691906130b1565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611cb4919061305b565b92505081905550612175565b60006003811115611cfa577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b816003811115611d33577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b1415611e775784600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d88919061313c565b92505081905550828486611d9c91906130e2565b611da691906130b1565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611df4919061313c565b9250508190555082848387611e09919061313c565b611e1391906130e2565b611e1d91906130b1565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e6b919061305b565b92505081905550612174565b60026003811115611eb1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b816003811115611eea577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b141561208f5784600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f3f919061313c565b92505081905550828486611f5391906130e2565b611f5d91906130b1565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fab919061313c565b925050819055508185611fbe919061313c565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461200c919061305b565b9250508190555082848387612021919061313c565b61202b91906130e2565b61203591906130b1565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612083919061305b565b92505081905550612173565b82848661209c91906130e2565b6120a691906130b1565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120f4919061313c565b9250508190555082848387612109919061313c565b61211391906130e2565b61211d91906130b1565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461216b919061305b565b925050819055505b5b5b82848361218291906130e2565b61218c91906130b1565b6007600082825461219d919061313c565b9250508190555081600860008282546121b6919061305b565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8488612218919061313c565b6040516122259190612fca565b60405180910390a350505050505050565b6122b78363a9059cbb60e01b8484604051602401612255929190612d89565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612624565b505050565b60006122ca826000016126eb565b9050919050565b60006122e083600001836126fc565b60001c905092915050565b61236e846323b872dd60e01b85858560405160240161230c93929190612d52565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612624565b50505050565b600061238083836123e4565b6123d95782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506123de565b600090505b92915050565b600080836001016000848152602001908152602001600020541415905092915050565b60008083600101600084815260200190815260200160002054905060008114612585576000600182612439919061313c565b9050600060018660000180549050612451919061313c565b90506000866000018281548110612491577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050808760000184815481106124db577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506001836124f6919061305b565b8760010160008381526020019081526020016000208190555086600001805480612549577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061258b565b60009150505b92915050565b60008061259f60048561194d565b905060006125ae60048561194d565b90508180156125bb575080155b156125c9576000925061261c565b811580156125d45750805b156125e2576001925061261b565b811580156125ee575080155b156125fc576003925061261a565b8180156126065750805b156126145760029250612619565b600392505b5b5b5b505092915050565b6000612686826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166127969092919063ffffffff16565b90506000815111156126e657808060200190518101906126a69190612a4a565b6126e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126dc90612f8a565b60405180910390fd5b5b505050565b600081600001805490509050919050565b600081836000018054905011612747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161273e90612e0a565b60405180910390fd5b826000018281548110612783577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905092915050565b60606127a584846000856127ae565b90509392505050565b60606127b9856128d0565b6127f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127ef90612f6a565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516128219190612d3b565b60006040518083038185875af1925050503d806000811461285e576040519150601f19603f3d011682016040523d82523d6000602084013e612863565b606091505b509150915081156128785780925050506128c8565b60008151111561288b5780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128bf9190612de8565b60405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561291257506000801b8214155b92505050919050565b60008135905061292a8161367d565b92915050565b60008151905061293f81613694565b92915050565b600081359050612954816136ab565b92915050565b60006020828403121561296c57600080fd5b600061297a8482850161291b565b91505092915050565b6000806040838503121561299657600080fd5b60006129a48582860161291b565b92505060206129b58582860161291b565b9150509250929050565b6000806000606084860312156129d457600080fd5b60006129e28682870161291b565b93505060206129f38682870161291b565b9250506040612a0486828701612945565b9150509250925092565b60008060408385031215612a2157600080fd5b6000612a2f8582860161291b565b9250506020612a4085828601612945565b9150509250929050565b600060208284031215612a5c57600080fd5b6000612a6a84828501612930565b91505092915050565b600060208284031215612a8557600080fd5b6000612a9384828501612945565b91505092915050565b612aa581613170565b82525050565b612ab481613182565b82525050565b6000612ac582613029565b612acf818561303f565b9350612adf8185602086016131e9565b80840191505092915050565b612af4816131c5565b82525050565b6000612b0582613034565b612b0f818561304a565b9350612b1f8185602086016131e9565b612b2881613324565b840191505092915050565b6000612b4060228361304a565b9150612b4b82613335565b604082019050919050565b6000612b6360238361304a565b9150612b6e82613384565b604082019050919050565b6000612b8660158361304a565b9150612b91826133d3565b602082019050919050565b6000612ba960228361304a565b9150612bb4826133fc565b604082019050919050565b6000612bcc60108361304a565b9150612bd78261344b565b602082019050919050565b6000612bef600b8361304a565b9150612bfa82613474565b602082019050919050565b6000612c1260078361304a565b9150612c1d8261349d565b602082019050919050565b6000612c35600f8361304a565b9150612c40826134c6565b602082019050919050565b6000612c5860258361304a565b9150612c63826134ef565b604082019050919050565b6000612c7b60108361304a565b9150612c868261353e565b602082019050919050565b6000612c9e60248361304a565b9150612ca982613567565b604082019050919050565b6000612cc1601d8361304a565b9150612ccc826135b6565b602082019050919050565b6000612ce4602a8361304a565b9150612cef826135df565b604082019050919050565b6000612d0760268361304a565b9150612d128261362e565b604082019050919050565b612d26816131ae565b82525050565b612d35816131b8565b82525050565b6000612d478284612aba565b915081905092915050565b6000606082019050612d676000830186612a9c565b612d746020830185612a9c565b612d816040830184612d1d565b949350505050565b6000604082019050612d9e6000830185612a9c565b612dab6020830184612d1d565b9392505050565b6000602082019050612dc76000830184612aab565b92915050565b6000602082019050612de26000830184612aeb565b92915050565b60006020820190508181036000830152612e028184612afa565b905092915050565b60006020820190508181036000830152612e2381612b33565b9050919050565b60006020820190508181036000830152612e4381612b56565b9050919050565b60006020820190508181036000830152612e6381612b79565b9050919050565b60006020820190508181036000830152612e8381612b9c565b9050919050565b60006020820190508181036000830152612ea381612bbf565b9050919050565b60006020820190508181036000830152612ec381612be2565b9050919050565b60006020820190508181036000830152612ee381612c05565b9050919050565b60006020820190508181036000830152612f0381612c28565b9050919050565b60006020820190508181036000830152612f2381612c4b565b9050919050565b60006020820190508181036000830152612f4381612c6e565b9050919050565b60006020820190508181036000830152612f6381612c91565b9050919050565b60006020820190508181036000830152612f8381612cb4565b9050919050565b60006020820190508181036000830152612fa381612cd7565b9050919050565b60006020820190508181036000830152612fc381612cfa565b9050919050565b6000602082019050612fdf6000830184612d1d565b92915050565b6000604082019050612ffa6000830185612d1d565b6130076020830184612d1d565b9392505050565b60006020820190506130236000830184612d2c565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000613066826131ae565b9150613071836131ae565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156130a6576130a5613297565b5b828201905092915050565b60006130bc826131ae565b91506130c7836131ae565b9250826130d7576130d66132c6565b5b828204905092915050565b60006130ed826131ae565b91506130f8836131ae565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561313157613130613297565b5b828202905092915050565b6000613147826131ae565b9150613152836131ae565b92508282101561316557613164613297565b5b828203905092915050565b600061317b8261318e565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006131d0826131d7565b9050919050565b60006131e28261318e565b9050919050565b60005b838110156132075780820151818401526020810190506131ec565b83811115613216576000848401525b50505050565b6000600282049050600182168061323457607f821691505b60208210811415613248576132476132f5565b5b50919050565b6000613259826131ae565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561328c5761328b613297565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f63616e2774206465706f736974206e6f7468696e670000000000000000000000600082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f61646472657373206578636c7564656400000000000000000000000000000000600082015250565b7f6e6f7420616c6c6f776564000000000000000000000000000000000000000000600082015250565b7f6f70206f6e6c7900000000000000000000000000000000000000000000000000600082015250565b7f696e76616c6964205f616d6f756e740000000000000000000000000000000000600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f6f6e6c79206f702063616e2063616c6c00000000000000000000000000000000600082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220616d74206d75737420626520677265617465722074686160008201527f6e207a65726f0000000000000000000000000000000000000000000000000000602082015250565b61368681613170565b811461369157600080fd5b50565b61369d81613182565b81146136a857600080fd5b50565b6136b4816131ae565b81146136bf57600080fd5b5056fea26469706673582212206ae4bd9c94778c0c88194747201c993cd8ce97d9ef48c311bd7a2fbf2bd8246364736f6c63430008040033
{"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, 2581, 2683, 2620, 22025, 2278, 2683, 2278, 16048, 2546, 2094, 21619, 2629, 2278, 2683, 7959, 2692, 22407, 2497, 2692, 4783, 2050, 26224, 2497, 16576, 12376, 2094, 20842, 2063, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 3075, 4372, 17897, 16670, 13462, 1063, 1013, 1013, 2000, 10408, 2023, 3075, 2005, 3674, 4127, 2007, 2004, 2210, 3642, 1013, 1013, 23318, 2004, 2825, 1010, 2057, 4339, 2009, 1999, 3408, 1997, 1037, 12391, 2275, 2828, 2007, 1013, 1013, 27507, 16703, 5300, 1012, 1013, 1013, 1996, 2275, 7375, 3594, 2797, 4972, 1010, 1998, 5310, 1011, 5307, 1013, 1013, 24977, 1006, 2107, 2004, 4769, 13462, 1007, 2024, 2074, 10236, 7347, 2105, 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,918
0x97983e0014064dc7a43baf6f913feb31f2519b23
pragma solidity ^0.5.0; 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } /** * @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 internal _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 () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @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()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() internal view returns (bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract NeuroToken is Ownable { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping(address => uint256)) private allowed; string public constant name = "NeuroToken"; string public constant symbol = "NRT"; uint8 public constant decimal = 18; uint256 public totalSupply; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _from, address indexed _to, uint256 _value); // _value = n * 10**18 (1000000000000000000) function mint(address _to, uint256 _value) onlyOwner public { require(_to != address(0), "ERC20: mint to the zero address"); balances[_to] = balances[_to].add(_value); totalSupply = totalSupply.add(_value); emit Transfer(address(0), _to, _value); } function balanceOf(address _owner) public view returns(uint256) { return balances[_owner]; } function transfer(address _to, uint256 _value) public { require(_to != address(0), "ERC20: transfer to the zero address"); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public { require(_from != address(0), "ERC20: transfer from the zero address"); require(_to != address(0), "ERC20: transfer to the zero address"); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); 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); emit Approval(_from, _to, _value); } function allowance(address _owner, address _spender) public view returns(uint256) { return allowed[_owner][_spender]; } function approve(address _spender, uint256 _value) public { require(msg.sender != address(0), "ERC20: approve from the zero address"); require(_spender != address(0), "ERC20: approve from the zero address"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063715018a61161008c57806395d89b411161006657806395d89b411461026b578063a9059cbb14610273578063dd62ed3e1461029f578063f2fde38b146102cd576100cf565b8063715018a61461022157806376809ce3146102295780638da5cb5b14610247576100cf565b806306fdde03146100d4578063095ea7b31461015157806318160ddd1461017f57806323b872dd1461019957806340c10f19146101cf57806370a08231146101fb575b600080fd5b6100dc6102f3565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101165781810151838201526020016100fe565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561016757600080fd5b506001600160a01b038135169060200135610319565b005b6101876103fc565b60408051918252519081900360200190f35b61017d600480360360608110156101af57600080fd5b506001600160a01b03813581169160208101359091169060400135610402565b61017d600480360360408110156101e557600080fd5b506001600160a01b038135169060200135610633565b6101876004803603602081101561021157600080fd5b50356001600160a01b031661073c565b61017d610757565b6102316107b2565b6040805160ff9092168252519081900360200190f35b61024f6107b7565b604080516001600160a01b039092168252519081900360200190f35b6100dc6107c6565b61017d6004803603604081101561028957600080fd5b506001600160a01b0381351690602001356107e5565b610187600480360360408110156102b557600080fd5b506001600160a01b03813581169160200135166108f1565b61017d600480360360208110156102e357600080fd5b50356001600160a01b031661091c565b6040518060400160405280600a8152602001692732bab937aa37b5b2b760b11b81525081565b336103555760405162461bcd60e51b8152600401808060200182810382526024815260200180610a2f6024913960400191505060405180910390fd5b6001600160a01b03821661039a5760405162461bcd60e51b8152600401808060200182810382526024815260200180610a2f6024913960400191505060405180910390fd5b3360008181526002602090815260408083206001600160a01b03871680855290835292819020859055805185815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35050565b60035481565b6001600160a01b0383166104475760405162461bcd60e51b8152600401808060200182810382526025815260200180610a0a6025913960400191505060405180910390fd5b6001600160a01b03821661048c5760405162461bcd60e51b81526004018080602001828103825260238152602001806109e76023913960400191505060405180910390fd5b6001600160a01b03831660009081526001602052604090205481118015906104d757506001600160a01b03831660009081526002602090815260408083203384529091529020548111155b6104e057600080fd5b6001600160a01b038316600090815260016020526040902054610509908263ffffffff61093916565b6001600160a01b03808516600090815260016020526040808220939093559084168152205461053e908263ffffffff61094e16565b6001600160a01b038084166000908152600160209081526040808320949094559186168152600282528281203382529091522054610582908263ffffffff61093916565b6001600160a01b03808516600081815260026020908152604080832033845282529182902094909455805185815290519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3816001600160a01b0316836001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b61063b610967565b61064457600080fd5b6001600160a01b03821661069f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6001600160a01b0382166000908152600160205260409020546106c8908263ffffffff61094e16565b6001600160a01b0383166000908152600160205260409020556003546106f4908263ffffffff61094e16565b6003556040805182815290516001600160a01b038416916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b031660009081526001602052604090205490565b61075f610967565b61076857600080fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b601281565b6000546001600160a01b031690565b6040518060400160405280600381526020016213949560ea1b81525081565b6001600160a01b03821661082a5760405162461bcd60e51b81526004018080602001828103825260238152602001806109e76023913960400191505060405180910390fd5b3360009081526001602052604090205481111561084657600080fd5b33600090815260016020526040902054610866908263ffffffff61093916565b33600090815260016020526040808220929092556001600160a01b03841681522054610898908263ffffffff61094e16565b6001600160a01b0383166000818152600160209081526040918290209390935580518481529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b610924610967565b61092d57600080fd5b61093681610978565b50565b60008282111561094857600080fd5b50900390565b60008282018381101561096057600080fd5b9392505050565b6000546001600160a01b0316331490565b6001600160a01b03811661098b57600080fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b039290921691909117905556fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a265627a7a7231582006789180c898f1442e2d04e418074683354cdef7ad3983999be6bc5a2e255cbd64736f6c63430005110032
{"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, 2581, 2683, 2620, 2509, 2063, 8889, 16932, 2692, 21084, 16409, 2581, 2050, 23777, 3676, 2546, 2575, 2546, 2683, 17134, 7959, 2497, 21486, 2546, 17788, 16147, 2497, 21926, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 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,919
0x979843B8eEa56E0bEA971445200e0eC3398cdB87
// SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // Global Enums and Structs struct StrategyParams { uint256 performanceFee; uint256 activation; uint256 debtRatio; uint256 rateLimit; uint256 lastReport; uint256 totalDebt; uint256 totalGain; uint256 totalLoss; } // Part: Gauge interface Gauge { function deposit(uint256) external; function balanceOf(address) external view returns (uint256); function claim_rewards() external; function claimable_reward(address, address) external view returns (uint256); function withdraw(uint256) external; } // Part: ICurveFi interface ICurveFi { function get_virtual_price() external view returns (uint256); function add_liquidity( // sBTC pool uint256[3] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // bUSD pool uint256[4] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // stETH pool uint256[2] calldata amounts, uint256 min_mint_amount ) external payable; function remove_liquidity_imbalance(uint256[4] calldata amounts, uint256 max_burn_amount) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount ) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external payable; function balances(int128) external view returns (uint256); function get_dy( int128 from, int128 to, uint256 _from_amount ) external view returns (uint256); function calc_token_amount( uint256[2] calldata amounts, bool is_deposit) external view returns (uint256); } // Part: IMooniswap interface IMooniswap { function swap(address src, address dst, uint256 amount, uint256 minReturn, address referral) external payable returns(uint256 result); } // Part: IStrategyProxy interface IStrategyProxy { function withdraw( address _gauge, address _token, uint256 _amount ) external returns (uint256); function balanceOf(address _gauge) external view returns (uint256); function withdrawAll(address _gauge, address _token) external returns (uint256); function deposit(address _gauge, address _token) external; function harvest(address _gauge) external; function lock() external; function claimRewards(address _gauge, address _token) external; function approveStrategy(address _gauge, address _strategy) external; } // Part: IUniswapV2Router01 interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Address /** * @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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/IERC20 /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Math /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeMath /** * @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; } } // Part: ICrvV3 interface ICrvV3 is IERC20 { function minter() external view returns (address); } // Part: ISteth interface ISteth is IERC20 { function submit(address) external payable returns (uint256); } // Part: IUniswapV2Router02 interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeERC20 /** * @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"); } } } // Part: iearn-finance/yearn-vaults@0.3.0/VaultAPI interface VaultAPI is IERC20 { function apiVersion() external view returns (string memory); function withdraw(uint256 shares, address recipient) external; function token() external view returns (address); function strategies(address _strategy) external view returns (StrategyParams memory); /** * View how much the Vault would increase this Strategy's borrow limit, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function creditAvailable() external view returns (uint256); /** * View how much the Vault would like to pull back from the Strategy, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function debtOutstanding() external view returns (uint256); /** * View how much the Vault expect this Strategy to return at the current * block, based on its present performance (since its last report). Can be * used to determine expectedReturn in your Strategy. */ function expectedReturn() external view returns (uint256); /** * This is the main contact point where the Strategy interacts with the * Vault. It is critical that this call is handled as intended by the * Strategy. Therefore, this function will be called by BaseStrategy to * make sure the integration is correct. */ function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256); /** * This function should only be used in the scenario where the Strategy is * being retired but no migration of the positions are possible, or in the * extreme scenario that the Strategy needs to be put into "Emergency Exit" * mode in order for it to exit as quickly as possible. The latter scenario * could be for any reason that is considered "critical" that the Strategy * exits its position as fast as possible, such as a sudden change in * market conditions leading to losses, or an imminent failure in an * external dependency. */ function revokeStrategy() external; /** * View the governance address of the Vault to assert privileged functions * can only be called by governance. The Strategy serves the Vault, so it * is subject to governance defined by the Vault. */ function governance() external view returns (address); } // Part: iearn-finance/yearn-vaults@0.3.0/BaseStrategy /** * @title Yearn Base Strategy * @author yearn.finance * @notice * BaseStrategy implements all of the required functionality to interoperate * closely with the Vault contract. This contract should be inherited and the * abstract methods implemented to adapt the Strategy to the particular needs * it has to create a return. * * Of special interest is the relationship between `harvest()` and * `vault.report()'. `harvest()` may be called simply because enough time has * elapsed since the last report, and not because any funds need to be moved * or positions adjusted. This is critical so that the Vault may maintain an * accurate picture of the Strategy's performance. See `vault.report()`, * `harvest()`, and `harvestTrigger()` for further details. */ abstract contract BaseStrategy { using SafeMath for uint256; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this contract. */ function apiVersion() public pure returns (string memory) { return "0.3.0"; } /** * @notice This Strategy's name. * @dev * You can use this field to manage the "version" of this Strategy, e.g. * `StrategySomethingOrOtherV1`. However, "API Version" is managed by * `apiVersion()` function above. * @return This Strategy's name. */ function name() external virtual view returns (string memory); /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external virtual view returns (uint256) { return 0; } VaultAPI public vault; address public strategist; address public rewards; address public keeper; IERC20 public want; // So indexers can keep track of this event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding); event UpdatedStrategist(address newStrategist); event UpdatedKeeper(address newKeeper); event UpdatedRewards(address rewards); event UpdatedReportDelay(uint256 delay); event UpdatedProfitFactor(uint256 profitFactor); event UpdatedDebtThreshold(uint256 debtThreshold); event EmergencyExitEnabled(); // The maximum number of seconds between harvest calls. See // `setMaxReportDelay()` for more details. uint256 public maxReportDelay = 86400; // ~ once a day // The minimum multiple that `callCost` must be above the credit/profit to // be "justifiable". See `setProfitFactor()` for more details. uint256 public profitFactor = 100; // Use this to adjust the threshold at which running a debt causes a // harvest trigger. See `setDebtThreshold()` for more details. uint256 public debtThreshold = 0; // See note on `setEmergencyExit()`. bool public emergencyExit; // modifiers modifier onlyAuthorized() { require(msg.sender == strategist || msg.sender == governance(), "!authorized"); _; } modifier onlyStrategist() { require(msg.sender == strategist, "!strategist"); _; } modifier onlyGovernance() { require(msg.sender == governance(), "!authorized"); _; } modifier onlyKeepers() { require(msg.sender == keeper || msg.sender == strategist || msg.sender == governance(), "!authorized"); _; } /** * @notice * Initializes the Strategy, this is called only once, when the * contract is deployed. * @dev `_vault` should implement `VaultAPI`. * @param _vault The address of the Vault responsible for this Strategy. */ constructor(address _vault) public { vault = VaultAPI(_vault); want = IERC20(vault.token()); want.approve(_vault, uint256(-1)); // Give Vault unlimited access (might save gas) strategist = msg.sender; rewards = msg.sender; keeper = msg.sender; } /** * @notice * Used to change `strategist`. * * This may only be called by governance or the existing strategist. * @param _strategist The new address to assign as `strategist`. */ function setStrategist(address _strategist) external onlyAuthorized { require(_strategist != address(0)); strategist = _strategist; emit UpdatedStrategist(_strategist); } /** * @notice * Used to change `keeper`. * * `keeper` is the only address that may call `tend()` or `harvest()`, * other than `governance()` or `strategist`. However, unlike * `governance()` or `strategist`, `keeper` may *only* call `tend()` * and `harvest()`, and no other authorized functions, following the * principle of least privilege. * * This may only be called by governance or the strategist. * @param _keeper The new address to assign as `keeper`. */ function setKeeper(address _keeper) external onlyAuthorized { require(_keeper != address(0)); keeper = _keeper; emit UpdatedKeeper(_keeper); } /** * @notice * Used to change `rewards`. Any distributed rewards will cease flowing * to the old address and begin flowing to this address once the change * is in effect. * * This may only be called by the strategist. * @param _rewards The address to use for collecting rewards. */ function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); rewards = _rewards; emit UpdatedRewards(_rewards); } /** * @notice * Used to change `maxReportDelay`. `maxReportDelay` is the maximum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the maximum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The maximum number of seconds to wait between harvests. */ function setMaxReportDelay(uint256 _delay) external onlyAuthorized { maxReportDelay = _delay; emit UpdatedReportDelay(_delay); } /** * @notice * Used to change `profitFactor`. `profitFactor` is used to determine * if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _profitFactor A ratio to multiply anticipated * `harvest()` gas cost against. */ function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); } /** * @notice * Sets how far the Strategy can go into loss without a harvest and report * being required. * * By default this is 0, meaning any losses would cause a harvest which * will subsequently report the loss to the Vault for tracking. (See * `harvestTrigger()` for more details.) * * This may only be called by governance or the strategist. * @param _debtThreshold How big of a loss this Strategy may carry without * being required to report to the Vault. */ function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized { debtThreshold = _debtThreshold; emit UpdatedDebtThreshold(_debtThreshold); } /** * Resolve governance address from Vault contract, used to make assertions * on protected functions in the Strategy. */ function governance() internal view returns (address) { return vault.governance(); } /** * @notice * Provide an accurate estimate for the total amount of assets * (principle + return) that this Strategy is currently managing, * denominated in terms of `want` tokens. * * This total should be "realizable" e.g. the total value that could * *actually* be obtained from this Strategy if it were to divest its * entire position based on current on-chain conditions. * @dev * Care must be taken in using this function, since it relies on external * systems, which could be manipulated by the attacker to give an inflated * (or reduced) value produced by this function, based on current on-chain * conditions (e.g. this function is possible to influence through * flashloan attacks, oracle manipulations, or other DeFi attack * mechanisms). * * It is up to governance to use this function to correctly order this * Strategy relative to its peers in the withdrawal queue to minimize * losses for the Vault based on sudden withdrawals. This value should be * higher than the total debt of the Strategy and higher than its expected * value to be "safe". * @return The estimated total assets in this Strategy. */ function estimatedTotalAssets() public virtual view returns (uint256); /* * @notice * Provide an indication of whether this strategy is currently "active" * in that it is managing an active position, or will manage a position in * the future. This should correlate to `harvest()` activity, so that Harvest * events can be tracked externally by indexing agents. * @return True if the strategy is actively managing a position. */ function isActive() public view returns (bool) { return vault.strategies(address(this)).debtRatio > 0 || estimatedTotalAssets() > 0; } /** * Perform any Strategy unwinding or other calls necessary to capture the * "free return" this Strategy has generated since the last time its core * position(s) were adjusted. Examples include unwrapping extra rewards. * This call is only used during "normal operation" of a Strategy, and * should be optimized to minimize losses as much as possible. * * This method returns any realized profits and/or realized losses * incurred, and should return the total amounts of profits/losses/debt * payments (in `want` tokens) for the Vault's accounting (e.g. * `want.balanceOf(this) >= _debtPayment + _profit - _loss`). * * `_debtOutstanding` will be 0 if the Strategy is not past the configured * debt limit, otherwise its value will be how far past the debt limit * the Strategy is. The Strategy's debt limit is configured in the Vault. * * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`. * It is okay for it to be less than `_debtOutstanding`, as that * should only used as a guide for how much is left to pay back. * Payments should be made to minimize loss from slippage, debt, * withdrawal fees, etc. * * See `vault.debtOutstanding()`. */ function prepareReturn(uint256 _debtOutstanding) internal virtual returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ); /** * Perform any adjustments to the core position(s) of this Strategy given * what change the Vault made in the "investable capital" available to the * Strategy. Note that all "free capital" in the Strategy after the report * was made is available for reinvestment. Also note that this number * could be 0, and you should handle that scenario accordingly. * * See comments regarding `_debtOutstanding` on `prepareReturn()`. */ function adjustPosition(uint256 _debtOutstanding) internal virtual; /** * Liquidate up to `_amountNeeded` of `want` of this strategy's positions, * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`. * This function should return the amount of `want` tokens made available by the * liquidation. If there is a difference between them, `_loss` indicates whether the * difference is due to a realized loss, or if there is some other sitution at play * (e.g. locked funds). This function is used during emergency exit instead of * `prepareReturn()` to liquidate all of the Strategy's positions back to the Vault. * * NOTE: The invariant `_amountFreed + _loss <= _amountNeeded` should always be maintained */ function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss); /** * `Harvest()` calls this function after shares are created during * `vault.report()`. You can customize this function to any share * distribution mechanism you want. * * See `vault.report()` for further details. */ function distributeRewards() internal virtual { // Transfer 100% of newly-minted shares awarded to this contract to the rewards address. uint256 balance = vault.balanceOf(address(this)); if (balance > 0) { vault.transfer(rewards, balance); } } /** * @notice * Provide a signal to the keeper that `tend()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `tend()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `tend()` is not called * shortly, then this can return `true` even if the keeper might be * "at a loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `harvestTrigger()` should never return `true` at the same * time. * @param callCost The keeper's estimated cast cost to call `tend()`. * @return `true` if `tend()` should be called, `false` otherwise. */ function tendTrigger(uint256 callCost) public virtual view returns (bool) { // We usually don't need tend, but if there are positions that need // active maintainence, overriding this function is how you would // signal for that. return false; } /** * @notice * Adjust the Strategy's position. The purpose of tending isn't to * realize gains, but to maximize yield by reinvesting any returns. * * See comments on `adjustPosition()`. * * This may only be called by governance, the strategist, or the keeper. */ function tend() external onlyKeepers { // Don't take profits with this call, but adjust for better gains adjustPosition(vault.debtOutstanding()); } /** * @notice * Provide a signal to the keeper that `harvest()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `harvest()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `harvest()` is not called * shortly, then this can return `true` even if the keeper might be "at a * loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `tendTrigger` should never return `true` at the * same time. * * See `maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the * strategist-controlled parameters that will influence whether this call * returns `true` or not. These parameters will be used in conjunction * with the parameters reported to the Vault (see `params`) to determine * if calling `harvest()` is merited. * * It is expected that an external system will check `harvestTrigger()`. * This could be a script run off a desktop or cloud bot (e.g. * https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py), * or via an integration with the Keep3r network (e.g. * https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol). * @param callCost The keeper's estimated cast cost to call `harvest()`. * @return `true` if `harvest()` should be called, `false` otherwise. */ function harvestTrigger(uint256 callCost) public virtual view returns (bool) { StrategyParams memory params = vault.strategies(address(this)); // Should not trigger if Strategy is not activated if (params.activation == 0) return false; // Should trigger if hasn't been called in a while if (block.timestamp.sub(params.lastReport) >= maxReportDelay) return true; // If some amount is owed, pay it back // NOTE: Since debt is based on deposits, it makes sense to guard against large // changes to the value from triggering a harvest directly through user // behavior. This should ensure reasonable resistance to manipulation // from user-initiated withdrawals as the outstanding debt fluctuates. uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true; // Check for profits and losses uint256 total = estimatedTotalAssets(); // Trigger if we have a loss to report if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit! // Otherwise, only trigger if it "makes sense" economically (gas cost // is <N% of value moved) uint256 credit = vault.creditAvailable(); return (profitFactor.mul(callCost) < credit.add(profit)); } /** * @notice * Harvests the Strategy, recognizing any profits or losses and adjusting * the Strategy's position. * * In the rare case the Strategy is in emergency shutdown, this will exit * the Strategy's position. * * This may only be called by governance, the strategist, or the keeper. * @dev * When `harvest()` is called, the Strategy reports to the Vault (via * `vault.report()`), so in some cases `harvest()` must be called in order * to take in profits, to borrow newly available funds from the Vault, or * otherwise adjust its position. In other cases `harvest()` must be * called to report to the Vault on the Strategy's position, especially if * any losses have occurred. */ function harvest() external onlyKeepers { uint256 profit = 0; uint256 loss = 0; uint256 debtOutstanding = vault.debtOutstanding(); uint256 debtPayment = 0; if (emergencyExit) { // Free up as much capital as possible uint256 totalAssets = estimatedTotalAssets(); // NOTE: use the larger of total assets or debt outstanding to book losses properly (debtPayment, loss) = liquidatePosition(totalAssets > debtOutstanding ? totalAssets : debtOutstanding); // NOTE: take up any remainder here as profit if (debtPayment > debtOutstanding) { profit = debtPayment.sub(debtOutstanding); debtPayment = debtOutstanding; } } else { // Free up returns for Vault to pull (profit, loss, debtPayment) = prepareReturn(debtOutstanding); } // Allow Vault to take up to the "harvested" balance of this contract, // which is the amount it has earned since the last time it reported to // the Vault. debtOutstanding = vault.report(profit, loss, debtPayment); // Distribute any reward shares earned by the strategy on this report distributeRewards(); // Check if free returns are left, and re-invest them adjustPosition(debtOutstanding); emit Harvested(profit, loss, debtPayment, debtOutstanding); } /** * @notice * Withdraws `_amountNeeded` to `vault`. * * This may only be called by the Vault. * @param _amountNeeded How much `want` to withdraw. * @return _loss Any realized losses */ function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) { require(msg.sender == address(vault), "!vault"); // Liquidate as much as possible to `want`, up to `_amount` uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded); // Send it directly back (NOTE: Using `msg.sender` saves some gas here) want.transfer(msg.sender, amountFreed); // NOTE: Reinvest anything leftover on next `tend`/`harvest` } /** * Do anything necessary to prepare this Strategy for migration, such as * transferring any reserve or LP tokens, CDPs, or other tokens or stores of * value. */ function prepareMigration(address _newStrategy) internal virtual; /** * @notice * Transfers all `want` from this Strategy to `_newStrategy`. * * This may only be called by governance or the Vault. * @dev * The new Strategy's Vault must be the same as this Strategy's Vault. * @param _newStrategy The Strategy to migrate to. */ function migrate(address _newStrategy) external { require(msg.sender == address(vault) || msg.sender == governance()); require(BaseStrategy(_newStrategy).vault() == vault); prepareMigration(_newStrategy); want.transfer(_newStrategy, want.balanceOf(address(this))); } /** * @notice * Activates emergency exit. Once activated, the Strategy will exit its * position upon the next harvest, depositing all funds into the Vault as * quickly as is reasonable given on-chain conditions. * * This may only be called by governance or the strategist. * @dev * See `vault.setEmergencyShutdown()` and `harvest()` for further details. */ function setEmergencyExit() external onlyAuthorized { emergencyExit = true; vault.revokeStrategy(); emit EmergencyExitEnabled(); } /** * Override this to add all tokens/tokenized positions this contract * manages on a *persistent* basis (e.g. not just for swapping back to * want ephemerally). * * NOTE: Do *not* include `want`, already included in `sweep` below. * * Example: * * function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * } */ function protectedTokens() internal virtual view returns (address[] memory); /** * @notice * Removes tokens from this Strategy that are not the type of tokens * managed by this Strategy. This may be used in case of accidentally * sending the wrong kind of token to this Strategy. * * Tokens will be sent to `governance()`. * * This will fail if an attempt is made to sweep `want`, or any tokens * that are protected by this Strategy. * * This may only be called by governance. * @dev * Implement `protectedTokens()` to specify any additional tokens that * should be protected from sweeping in addition to `want`. * @param _token The token to transfer out of this vault. */ function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).transfer(governance(), IERC20(_token).balanceOf(address(this))); } } // File: Strategy.sol // Import interfaces for many popular DeFi projects, or add your own! //import "../interfaces/<protocol>/<Interface>.sol"; contract Strategy is BaseStrategy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address private uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address private sushiswapRouter = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F; address private mooniswappool = 0x1f629794B34FFb3B29FF206Be5478A52678b47ae; address private referal = 0xC3D6880fD95E06C816cB030fAc45b3ffe3651Cb0; address public constant gauge = address(0x182B723a58739a9c974cFDB385ceaDb237453c28); address public voter = address(0xF147b8125d2ef93FB6965Db97D6746952a133934); // Yearn's veCRV voter address public ldoRouter = 0x1f629794B34FFb3B29FF206Be5478A52678b47ae; address[] public ldoPath; address public crvRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address[] public crvPath; uint256 public keepCrvPercent = 1000; // over keepCrvDenominator uint256 public constant keepCrvDenominator = 10000; bool public checkLiqGauge = true; ICurveFi public StableSwapSTETH = ICurveFi(address(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022)); // IMinter public CrvMinter = IMinter(address(0xd061D61a4d941c39E5453435B6345Dc261C2fcE0)); //IStrategyProxy public proxy = IStrategyProxy(address(0x9a3a03C614dc467ACC3e81275468e033c98d960E)); IStrategyProxy public proxy = IStrategyProxy(address(0x9a165622a744C20E3B2CB443AeD98110a33a231b)); address public constant weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); ISteth public stETH = ISteth(address(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84)); IERC20 public LDO = IERC20(address(0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32)); ICrvV3 public CRV = ICrvV3(address(0xD533a949740bb3306d119CC777fa900bA034cd52)); constructor(address _vault) public BaseStrategy(_vault) { // You can set these parameters on deployment to whatever you want maxReportDelay = 43200; profitFactor = 2000; debtThreshold = 400*1e18; stETH.approve(address(StableSwapSTETH), uint256(-1)); LDO.safeApprove(ldoRouter, uint256(-1)); CRV.approve(crvRouter, uint256(-1)); ldoPath = new address[](2); ldoPath[0] = address(LDO); ldoPath[1] = weth; crvPath = new address[](2); crvPath[0] = address(CRV); crvPath[1] = weth; } //we get eth receive() external payable {} // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ //0 uniswap, 1 sushi, 2 inch function setLDORouter(uint256 exchange, address[] calldata _path) public onlyGovernance { if(exchange == 0){ ldoRouter = uniswapRouter; }else if (exchange == 1) { ldoRouter = sushiswapRouter; }else if (exchange == 2) { ldoRouter = mooniswappool; }else{ require(false, "incorrect pool"); } ldoPath = _path; LDO.safeApprove(ldoRouter, uint256(-1)); } function updateMooniswapPoolAddress(address newAddress) public onlyGovernance { mooniswappool = newAddress; } function updateReferal(address _referal) public onlyAuthorized { referal = _referal; } function updateCheckLiqGauge(bool _checkLiqGauge) public onlyAuthorized { checkLiqGauge = _checkLiqGauge; } function setCRVRouter(uint256 exchange, address[] calldata _path) public onlyGovernance { if(exchange == 0){ crvRouter = uniswapRouter; }else if (exchange == 1) { crvRouter = sushiswapRouter; }else{ require(false, "incorrect pool"); } crvPath = _path; CRV.approve(crvRouter, uint256(-1)); } function setProxy(address _proxy) external onlyGovernance { proxy = IStrategyProxy(_proxy); } function setVoter(address _voter) external onlyGovernance { voter = _voter; } function name() external override view returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return "StrategystETHCurve"; } function estimatedTotalAssets() public override view returns (uint256) { return proxy.balanceOf(gauge).add(want.balanceOf(address(this))); } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 gaugeTokens = proxy.balanceOf(gauge); if(gaugeTokens > 0){ proxy.harvest(gauge); proxy.claimRewards(gauge, address(LDO)); uint256 ldo_balance = LDO.balanceOf(address(this)); if(ldo_balance > 0){ _sell(address(LDO), ldo_balance); } uint256 crvBalance = CRV.balanceOf(address(this)); if(crvBalance > 0){ uint256 keepCrv = crvBalance.mul(keepCrvPercent).div(keepCrvDenominator); IERC20(address(CRV)).safeTransfer(voter, keepCrv); proxy.lock(); crvBalance = crvBalance.sub(keepCrv); _sell(address(CRV), crvBalance); } uint256 balance = address(this).balance; uint256 balance2 = stETH.balanceOf(address(this)); if(balance > 0 || balance2 > 0){ StableSwapSTETH.add_liquidity{value: balance}([balance, balance2], 0); } _profit = want.balanceOf(address(this)); } if(_debtOutstanding > 0){ uint256 stakedBal = proxy.balanceOf(gauge); proxy.withdraw(gauge, address(want), Math.min(stakedBal, _debtOutstanding)); _debtPayment = Math.min(_debtOutstanding, want.balanceOf(address(this))); } } function adjustPosition(uint256 _debtOutstanding) internal override { //when migrated to we will sometimes have liquidity guage balance. //this should be withdrawn and added to proxy if(checkLiqGauge){ uint256 liqGaugeBal = Gauge(gauge).balanceOf(address(this)); if(liqGaugeBal > 0){ Gauge(gauge).withdraw(liqGaugeBal); } } uint256 _toInvest = want.balanceOf(address(this)); want.safeTransfer(address(proxy), _toInvest); proxy.deposit(gauge, address(want)); } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { uint256 wantBal = want.balanceOf(address(this)); uint256 stakedBal = proxy.balanceOf(gauge); if(_amountNeeded > wantBal){ proxy.withdraw(gauge, address(want), Math.min(stakedBal, _amountNeeded - wantBal)); } _liquidatedAmount = Math.min(_amountNeeded, want.balanceOf(address(this))); } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function prepareMigration(address _newStrategy) internal override { uint256 gaugeTokens = proxy.balanceOf(gauge); if (gaugeTokens > 0) { proxy.withdraw(gauge, address(want), gaugeTokens); } } //sell all function function _sell(address currency, uint256 amount) internal { if(currency == address(LDO)){ if(ldoRouter == mooniswappool){ //we sell to stETH IMooniswap(mooniswappool).swap(currency, address(stETH), amount, 1, referal); }else{ IUniswapV2Router02(ldoRouter).swapExactTokensForETH(amount, uint256(0), ldoPath, address(this), now); } } else if(currency == address(CRV)){ IUniswapV2Router02(crvRouter).swapExactTokensForETH(amount, uint256(0), crvPath, address(this), now); }else{ require(false, "BAD SELL"); } } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal override view returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = gauge; return protected; } }
0x6080604052600436106102cd5760003560e01c806391397ab411610175578063c7b9d530116100dc578063efbb5cb011610095578063f3488c251161006f578063f3488c25146107af578063fbfa77cf146107cf578063fc5f489d146107e4578063fcf2d0ad146107f9576102d4565b8063efbb5cb014610765578063f017c92f1461077a578063f08f84591461079a576102d4565b8063c7b9d530146106bb578063ce5494bb146106db578063d88bba11146106fb578063ec38a86214610710578063ec55688914610730578063ed882c2b14610745576102d4565b8063a6f19c841161012e578063a6f19c8414610627578063aced16611461063c578063ad40950014610651578063b0c89fa914610671578063b65c47aa14610691578063c1fe3e48146106a6576102d4565b806391397ab414610588578063945c9142146105a857806397107d6d146105bd5780639dba9f99146105dd5780639ec5a894146105fd578063a639841114610612576102d4565b80633fc8cef3116102345780635641ec03116101ed5780637f173559116101c75780637f17355914610534578063801492d7146105495780638cdfe1661461055e5780638e6350e214610573576102d4565b80635641ec03146104df578063650d1880146104f4578063748747e614610514576102d4565b80633fc8cef31461044b578063440368a3146104605780634641257d1461047557806346c96aac1461048a5780634bc2a6571461049f578063510c10e4146104bf576102d4565b806322f3e2d41161028657806322f3e2d41461039f57806325829410146103c157806328b7ccf7146103d65780632c4f93f9146103eb5780632e1a7d4d1461040b57806332bf14921461042b576102d4565b806301681a62146102d957806306fdde03146102fb5780630f969b87146103265780631d12f28b146103465780631f1fcd51146103685780631fe4a6861461038a576102d4565b366102d457005b600080fd5b3480156102e557600080fd5b506102f96102f43660046132a6565b61080e565b005b34801561030757600080fd5b50610310610a18565b60405161031d91906135c0565b60405180910390f35b34801561033257600080fd5b506102f961034136600461341d565b610a44565b34801561035257600080fd5b5061035b610ad1565b60405161031d919061385a565b34801561037457600080fd5b5061037d610ad7565b60405161031d91906134e2565b34801561039657600080fd5b5061037d610ae6565b3480156103ab57600080fd5b506103b4610af5565b60405161031d91906135b5565b3480156103cd57600080fd5b50610310610b93565b3480156103e257600080fd5b5061035b610bb2565b3480156103f757600080fd5b5061037d61040636600461341d565b610bb8565b34801561041757600080fd5b5061035b61042636600461341d565b610bdf565b34801561043757600080fd5b506102f961044636600461344d565b610ca5565b34801561045757600080fd5b5061037d610db3565b34801561046c57600080fd5b506102f9610dcb565b34801561048157600080fd5b506102f9610eb2565b34801561049657600080fd5b5061037d6110e1565b3480156104ab57600080fd5b506102f96104ba3660046132a6565b6110f0565b3480156104cb57600080fd5b506102f96104da366004613373565b61114a565b3480156104eb57600080fd5b506103b46111aa565b34801561050057600080fd5b506103b461050f36600461341d565b6111b3565b34801561052057600080fd5b506102f961052f3660046132a6565b6111bb565b34801561054057600080fd5b5061037d611266565b34801561055557600080fd5b5061037d611275565b34801561056a57600080fd5b5061035b611289565b34801561057f57600080fd5b5061035b61128f565b34801561059457600080fd5b506102f96105a336600461341d565b611294565b3480156105b457600080fd5b5061037d611316565b3480156105c957600080fd5b506102f96105d83660046132a6565b611325565b3480156105e957600080fd5b506102f96105f836600461344d565b61137f565b34801561060957600080fd5b5061037d6114b2565b34801561061e57600080fd5b5061037d6114c1565b34801561063357600080fd5b5061037d6114d0565b34801561064857600080fd5b5061037d6114e2565b34801561065d57600080fd5b5061037d61066c36600461341d565b6114f1565b34801561067d57600080fd5b506102f961068c3660046132a6565b6114fe565b34801561069d57600080fd5b506103b4611558565b3480156106b257600080fd5b5061037d611561565b3480156106c757600080fd5b506102f96106d63660046132a6565b611570565b3480156106e757600080fd5b506102f96106f63660046132a6565b61161b565b34801561070757600080fd5b5061037d6117fb565b34801561071c57600080fd5b506102f961072b3660046132a6565b61180a565b34801561073c57600080fd5b5061037d611892565b34801561075157600080fd5b506103b461076036600461341d565b6118a1565b34801561077157600080fd5b5061035b611b0a565b34801561078657600080fd5b506102f961079536600461341d565b611c22565b3480156107a657600080fd5b5061035b611ca4565b3480156107bb57600080fd5b506102f96107ca3660046132a6565b611caa565b3480156107db57600080fd5b5061037d611d19565b3480156107f057600080fd5b5061035b611d28565b34801561080557600080fd5b506102f9611d2e565b610816611f1d565b6001600160a01b0316336001600160a01b03161461084f5760405162461bcd60e51b81526004016108469061374f565b60405180910390fd5b6004546001600160a01b038281169116141561087d5760405162461bcd60e51b815260040161084690613618565b6000546001600160a01b03828116911614156108ab5760405162461bcd60e51b8152600401610846906136f7565b60606108b5611fa4565b905060005b8151811015610910578181815181106108cf57fe5b60200260200101516001600160a01b0316836001600160a01b031614156109085760405162461bcd60e51b8152600401610846906137be565b6001016108ba565b50816001600160a01b031663a9059cbb610928611f1d565b6040516370a0823160e01b81526001600160a01b038616906370a08231906109549030906004016134e2565b60206040518083038186803b15801561096c57600080fd5b505afa158015610980573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a49190613435565b6040518363ffffffff1660e01b81526004016109c19291906134f6565b602060405180830381600087803b1580156109db57600080fd5b505af11580156109ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a13919061338f565b505050565b60408051808201909152601281527153747261746567797374455448437572766560701b602082015290565b6001546001600160a01b0316331480610a755750610a60611f1d565b6001600160a01b0316336001600160a01b0316145b610a915760405162461bcd60e51b81526004016108469061374f565b60078190556040517fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a860090610ac690839061385a565b60405180910390a150565b60075481565b6004546001600160a01b031681565b6001546001600160a01b031681565b600080546040516339ebf82360e01b815282916001600160a01b0316906339ebf82390610b269030906004016134e2565b6101006040518083038186803b158015610b3f57600080fd5b505afa158015610b53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7791906133ab565b604001511180610b8e57506000610b8c611b0a565b115b905090565b6040805180820190915260058152640302e332e360dc1b602082015290565b60055481565b600e8181548110610bc557fe5b6000918252602090912001546001600160a01b0316905081565b600080546001600160a01b03163314610c0a5760405162461bcd60e51b8152600401610846906136d7565b6000610c1583612002565b6004805460405163a9059cbb60e01b81529295509293506001600160a01b039092169163a9059cbb91610c4c9133918691016134f6565b602060405180830381600087803b158015610c6657600080fd5b505af1158015610c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c9e919061338f565b5050919050565b610cad611f1d565b6001600160a01b0316336001600160a01b031614610cdd5760405162461bcd60e51b81526004016108469061374f565b82610d0f57600854600d80546101009092046001600160a01b03166001600160a01b0319909216919091179055610d87565b8260011415610d3f57600954600d80546001600160a01b0319166001600160a01b03909216919091179055610d87565b8260021415610d6f57600a54600d80546001600160a01b0319166001600160a01b03909216919091179055610d87565b60405162461bcd60e51b81526004016108469061366e565b610d93600e83836131df565b50600d54601554610a13916001600160a01b039182169116600019611e0c565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6003546001600160a01b0316331480610dee57506001546001600160a01b031633145b80610e115750610dfc611f1d565b6001600160a01b0316336001600160a01b0316145b610e2d5760405162461bcd60e51b81526004016108469061374f565b6000546040805163bf3759b560e01b81529051610eb0926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015610e7357600080fd5b505afa158015610e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eab9190613435565b61225e565b565b6003546001600160a01b0316331480610ed557506001546001600160a01b031633145b80610ef85750610ee3611f1d565b6001600160a01b0316336001600160a01b0316145b610f145760405162461bcd60e51b81526004016108469061374f565b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b158015610f6657600080fd5b505afa158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190613435565b60085490915060009060ff1615610ff4576000610fb9611b0a565b9050610fd2838211610fcb5783610fcd565b815b612002565b9450915082821115610fee57610fe88284612476565b94508291505b50611005565b610ffd826124c1565b919550935090505b6000546040516328766ebf60e21b81526001600160a01b039091169063a1d9bafc90611039908790879086906004016138d6565b602060405180830381600087803b15801561105357600080fd5b505af1158015611067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108b9190613435565b9150611095612b61565b61109e8261225e565b7f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d509848483856040516110d394939291906138ec565b60405180910390a150505050565b600c546001600160a01b031681565b6110f8611f1d565b6001600160a01b0316336001600160a01b0316146111285760405162461bcd60e51b81526004016108469061374f565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633148061117b5750611166611f1d565b6001600160a01b0316336001600160a01b0316145b6111975760405162461bcd60e51b81526004016108469061374f565b6012805460ff1916911515919091179055565b60085460ff1681565b60005b919050565b6001546001600160a01b03163314806111ec57506111d7611f1d565b6001600160a01b0316336001600160a01b0316145b6112085760405162461bcd60e51b81526004016108469061374f565b6001600160a01b03811661121b57600080fd5b600380546001600160a01b0319166001600160a01b0383161790556040517f2f202ddb4a2e345f6323ed90f8fc8559d770a7abbbeee84dde8aca3351fe715490610ac69083906134e2565b600f546001600160a01b031681565b60125461010090046001600160a01b031681565b60065481565b600090565b6001546001600160a01b03163314806112c557506112b0611f1d565b6001600160a01b0316336001600160a01b0316145b6112e15760405162461bcd60e51b81526004016108469061374f565b60068190556040517fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec29890610ac690839061385a565b6016546001600160a01b031681565b61132d611f1d565b6001600160a01b0316336001600160a01b03161461135d5760405162461bcd60e51b81526004016108469061374f565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b611387611f1d565b6001600160a01b0316336001600160a01b0316146113b75760405162461bcd60e51b81526004016108469061374f565b826113e957600854600f80546101009092046001600160a01b03166001600160a01b0319909216919091179055611415565b8260011415610d6f57600954600f80546001600160a01b0319166001600160a01b039092169190911790555b611421601083836131df565b50601654600f5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261145a92911690600019906004016134f6565b602060405180830381600087803b15801561147457600080fd5b505af1158015611488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ac919061338f565b50505050565b6002546001600160a01b031681565b600d546001600160a01b031681565b60008051602061399e83398151915281565b6003546001600160a01b031681565b60108181548110610bc557fe5b611506611f1d565b6001600160a01b0316336001600160a01b0316146115365760405162461bcd60e51b81526004016108469061374f565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b60125460ff1681565b6014546001600160a01b031681565b6001546001600160a01b03163314806115a1575061158c611f1d565b6001600160a01b0316336001600160a01b0316145b6115bd5760405162461bcd60e51b81526004016108469061374f565b6001600160a01b0381166115d057600080fd5b600180546001600160a01b0319166001600160a01b0383161790556040517f352ececae6d7d1e6d26bcf2c549dfd55be1637e9b22dc0cf3b71ddb36097a6b490610ac69083906134e2565b6000546001600160a01b031633148061164c5750611637611f1d565b6001600160a01b0316336001600160a01b0316145b61165557600080fd5b60008054906101000a90046001600160a01b03166001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156116ab57600080fd5b505afa1580156116bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e391906132c2565b6001600160a01b0316146116f657600080fd5b6116ff81612c23565b600480546040516370a0823160e01b81526001600160a01b039091169163a9059cbb91849184916370a0823191611738913091016134e2565b60206040518083038186803b15801561175057600080fd5b505afa158015611764573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117889190613435565b6040518363ffffffff1660e01b81526004016117a59291906134f6565b602060405180830381600087803b1580156117bf57600080fd5b505af11580156117d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f7919061338f565b5050565b6015546001600160a01b031681565b6001546001600160a01b031633146118345760405162461bcd60e51b8152600401610846906135f3565b6001600160a01b03811661184757600080fd5b600280546001600160a01b0319166001600160a01b0383161790556040517fafbb66abf8f3b719799940473a4052a3717cdd8e40fb6c8a3faadab316b1a06990610ac69083906134e2565b6013546001600160a01b031681565b60006118ab613242565b6000546040516339ebf82360e01b81526001600160a01b03909116906339ebf823906118db9030906004016134e2565b6101006040518083038186803b1580156118f457600080fd5b505afa158015611908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192c91906133ab565b90508060200151600014156119455760009150506111b6565b6005546080820151611958904290612476565b106119675760019150506111b6565b60008060009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b1580156119b657600080fd5b505afa1580156119ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ee9190613435565b9050600754811115611a05576001925050506111b6565b6000611a0f611b0a565b90508260a00151611a2b60075483612d5190919063ffffffff16565b1015611a3d57600193505050506111b6565b60008360a00151821115611a5e5760a0840151611a5b908390612476565b90505b60008060009054906101000a90046001600160a01b03166001600160a01b031663112c1f9b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611aad57600080fd5b505afa158015611ac1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae59190613435565b9050611af18183612d51565b600654611afe9089612d76565b10979650505050505050565b600480546040516370a0823160e01b8152600092610b8e926001600160a01b0316916370a0823191611b3e913091016134e2565b60206040518083038186803b158015611b5657600080fd5b505afa158015611b6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8e9190613435565b6013546040516370a0823160e01b81526001600160a01b03909116906370a0823190611bcc9060008051602061399e833981519152906004016134e2565b60206040518083038186803b158015611be457600080fd5b505afa158015611bf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1c9190613435565b90612d51565b6001546001600160a01b0316331480611c535750611c3e611f1d565b6001600160a01b0316336001600160a01b0316145b611c6f5760405162461bcd60e51b81526004016108469061374f565b60058190556040517f4aaf232568bff365c53cad69bdb6e83014e79df80216ceba8ee01769723dfd6890610ac690839061385a565b61271081565b6001546001600160a01b0316331480611cdb5750611cc6611f1d565b6001600160a01b0316336001600160a01b0316145b611cf75760405162461bcd60e51b81526004016108469061374f565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031681565b60115481565b6001546001600160a01b0316331480611d5f5750611d4a611f1d565b6001600160a01b0316336001600160a01b0316145b611d7b5760405162461bcd60e51b81526004016108469061374f565b6008805460ff19166001179055600080546040805163507257cd60e11b815290516001600160a01b039092169263a0e4af9a9260048084019382900301818387803b158015611dc957600080fd5b505af1158015611ddd573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b801580611e945750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90611e42903090869060040161350f565b60206040518083038186803b158015611e5a57600080fd5b505afa158015611e6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e929190613435565b155b611eb05760405162461bcd60e51b815260040161084690613804565b610a138363095ea7b360e01b8484604051602401611ecf9291906134f6565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612db0565b6060611f158484600085612e3f565b949350505050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611f6c57600080fd5b505afa158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8e91906132c2565b6040805160018082528183019092526060918291906020808301908036833701905050905060008051602061399e83398151915281600081518110611fe557fe5b6001600160a01b0390921660209283029190910190910152905090565b600480546040516370a0823160e01b8152600092839283926001600160a01b03909116916370a0823191612038913091016134e2565b60206040518083038186803b15801561205057600080fd5b505afa158015612064573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120889190613435565b6013546040516370a0823160e01b81529192506000916001600160a01b03909116906370a08231906120cc9060008051602061399e833981519152906004016134e2565b60206040518083038186803b1580156120e457600080fd5b505afa1580156120f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211c9190613435565b9050818511156121cd576013546004546001600160a01b039182169163d9caed129160008051602061399e833981519152911661215b85878b03612f03565b6040518463ffffffff1660e01b815260040161217993929190613529565b602060405180830381600087803b15801561219357600080fd5b505af11580156121a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121cb9190613435565b505b600480546040516370a0823160e01b81526122559288926001600160a01b0316916370a0823191612200913091016134e2565b60206040518083038186803b15801561221857600080fd5b505afa15801561222c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122509190613435565b612f03565b93505050915091565b60125460ff161561235b576040516370a0823160e01b815260009060008051602061399e833981519152906370a082319061229d9030906004016134e2565b60206040518083038186803b1580156122b557600080fd5b505afa1580156122c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ed9190613435565b9050801561235957604051632e1a7d4d60e01b815260008051602061399e83398151915290632e1a7d4d9061232690849060040161385a565b600060405180830381600087803b15801561234057600080fd5b505af1158015612354573d6000803e3d6000fd5b505050505b505b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a082319161238d913091016134e2565b60206040518083038186803b1580156123a557600080fd5b505afa1580156123b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123dd9190613435565b6013546004549192506123fd916001600160a01b03908116911683612f19565b60135460048054604051631f2c13e160e31b81526001600160a01b039384169363f9609f08936124409360008051602061399e833981519152939216910161350f565b600060405180830381600087803b15801561245a57600080fd5b505af115801561246e573d6000803e3d6000fd5b505050505050565b60006124b883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f38565b90505b92915050565b6013546040516370a0823160e01b81526000918291829182916001600160a01b03909116906370a08231906125089060008051602061399e833981519152906004016134e2565b60206040518083038186803b15801561252057600080fd5b505afa158015612534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125589190613435565b905080156129e65760135460405163072e008f60e11b81526001600160a01b0390911690630e5c011e9061259e9060008051602061399e833981519152906004016134e2565b600060405180830381600087803b1580156125b857600080fd5b505af11580156125cc573d6000803e3d6000fd5b505060135460155460405163f1e42ccd60e01b81526001600160a01b03928316945063f1e42ccd93506126139260008051602061399e83398151915292169060040161350f565b600060405180830381600087803b15801561262d57600080fd5b505af1158015612641573d6000803e3d6000fd5b50506015546040516370a0823160e01b8152600093506001600160a01b0390911691506370a08231906126789030906004016134e2565b60206040518083038186803b15801561269057600080fd5b505afa1580156126a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c89190613435565b905080156126e6576015546126e6906001600160a01b031682612f64565b6016546040516370a0823160e01b81526000916001600160a01b0316906370a08231906127179030906004016134e2565b60206040518083038186803b15801561272f57600080fd5b505afa158015612743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127679190613435565b9050801561284857600061279261271061278c60115485612d7690919063ffffffff16565b9061312d565b600c546016549192506127b2916001600160a01b03908116911683612f19565b601360009054906101000a90046001600160a01b03166001600160a01b031663f83d08ba6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561280257600080fd5b505af1158015612816573d6000803e3d6000fd5b5050505061282d818361247690919063ffffffff16565b601654909250612846906001600160a01b031683612f64565b505b6014546040516370a0823160e01b815247916000916001600160a01b03909116906370a082319061287d9030906004016134e2565b60206040518083038186803b15801561289557600080fd5b505afa1580156128a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128cd9190613435565b905060008211806128de5750600081115b1561296057601254604080518082018252848152602081018490529051630b4c7e4d60e01b81526101009092046001600160a01b031691630b4c7e4d91859161292d919060009060040161357d565b6000604051808303818588803b15801561294657600080fd5b505af115801561295a573d6000803e3d6000fd5b50505050505b600480546040516370a0823160e01b81526001600160a01b03909116916370a082319161298f913091016134e2565b60206040518083038186803b1580156129a757600080fd5b505afa1580156129bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129df9190613435565b9750505050505b8415612b59576013546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612a2b9060008051602061399e833981519152906004016134e2565b60206040518083038186803b158015612a4357600080fd5b505afa158015612a57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b9190613435565b6013546004549192506001600160a01b039081169163d9caed129160008051602061399e8339815191529116612ab1858b612f03565b6040518463ffffffff1660e01b8152600401612acf93929190613529565b602060405180830381600087803b158015612ae957600080fd5b505af1158015612afd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b219190613435565b50600480546040516370a0823160e01b8152612b559289926001600160a01b0316916370a0823191612200913091016134e2565b9250505b509193909250565b600080546040516370a0823160e01b81526001600160a01b03909116906370a0823190612b929030906004016134e2565b60206040518083038186803b158015612baa57600080fd5b505afa158015612bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be29190613435565b90508015612c205760005460025460405163a9059cbb60e01b81526001600160a01b039283169263a9059cbb926117a59291169085906004016134f6565b50565b6013546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612c629060008051602061399e833981519152906004016134e2565b60206040518083038186803b158015612c7a57600080fd5b505afa158015612c8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb29190613435565b905080156117f75760135460048054604051636ce5768960e11b81526001600160a01b039384169363d9caed1293612cff9360008051602061399e83398151915293921691879101613529565b602060405180830381600087803b158015612d1957600080fd5b505af1158015612d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a139190613435565b6000828201838110156124b85760405162461bcd60e51b815260040161084690613637565b600082612d85575060006124bb565b82820282848281612d9257fe5b04146124b85760405162461bcd60e51b815260040161084690613696565b6060612e05826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f069092919063ffffffff16565b805190915015610a135780806020019051810190612e23919061338f565b610a135760405162461bcd60e51b815260040161084690613774565b6060612e4a8561316f565b612e665760405162461bcd60e51b815260040161084690613718565b60006060866001600160a01b03168587604051612e8391906134c6565b60006040518083038185875af1925050503d8060008114612ec0576040519150601f19603f3d011682016040523d82523d6000602084013e612ec5565b606091505b50915091508115612ed9579150611f159050565b805115612ee95780518082602001fd5b8360405162461bcd60e51b815260040161084691906135c0565b6000818310612f1257816124b8565b5090919050565b610a138363a9059cbb60e01b8484604051602401611ecf9291906134f6565b60008184841115612f5c5760405162461bcd60e51b815260040161084691906135c0565b505050900390565b6015546001600160a01b03838116911614156130c557600a54600d546001600160a01b039081169116141561302e57600a54601454600b5460405163d5bcb9b560e01b81526001600160a01b039384169363d5bcb9b593612fd69388939183169288926001929091169060040161354d565b602060405180830381600087803b158015612ff057600080fd5b505af1158015613004573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130289190613435565b506130c0565b600d546040516318cbafe560e01b81526001600160a01b03909116906318cbafe590613068908490600090600e9030904290600401613863565b600060405180830381600087803b15801561308257600080fd5b505af1158015613096573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130be91908101906132de565b505b6117f7565b6016546001600160a01b038381169116141561311557600f546040516318cbafe560e01b81526001600160a01b03909116906318cbafe59061306890849060009060109030904290600401613863565b60405162461bcd60e51b8152600401610846906137e2565b60006124b883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506131a8565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611f15575050151592915050565b600081836131c95760405162461bcd60e51b815260040161084691906135c0565b5060008385816131d557fe5b0495945050505050565b828054828255906000526020600020908101928215613232579160200282015b828111156132325781546001600160a01b0319166001600160a01b038435161782556020909201916001909101906131ff565b5061323e929150613287565b5090565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b5b8082111561323e5780546001600160a01b0319168155600101613288565b6000602082840312156132b7578081fd5b81356124b88161397a565b6000602082840312156132d3578081fd5b81516124b88161397a565b600060208083850312156132f0578182fd5b825167ffffffffffffffff811115613306578283fd5b8301601f81018513613316578283fd5b80516133296133248261392e565b613907565b8181528381019083850185840285018601891015613345578687fd5b8694505b83851015613367578051835260019490940193918501918501613349565b50979650505050505050565b600060208284031215613384578081fd5b81356124b88161398f565b6000602082840312156133a0578081fd5b81516124b88161398f565b60006101008083850312156133be578182fd5b6133c781613907565b9050825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201528091505092915050565b60006020828403121561342e578081fd5b5035919050565b600060208284031215613446578081fd5b5051919050565b600080600060408486031215613461578182fd5b83359250602084013567ffffffffffffffff8082111561347f578384fd5b818601915086601f830112613492578384fd5b8135818111156134a0578485fd5b87602080830285010111156134b3578485fd5b6020830194508093505050509250925092565b600082516134d881846020870161394e565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039586168152938516602085015260408401929092526060830152909116608082015260a00190565b60608101818460005b60028110156135a5578151835260209283019290910190600101613586565b5050508260408301529392505050565b901515815260200190565b60006020825282518060208401526135df81604085016020870161394e565b601f01601f19169190910160400192915050565b6020808252600b908201526a085cdd1c985d1959da5cdd60aa1b604082015260600190565b602080825260059082015264085dd85b9d60da1b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600e908201526d1a5b98dbdc9c9958dd081c1bdbdb60921b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260069082015265085d985d5b1d60d21b604082015260600190565b6020808252600790820152662173686172657360c81b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600a9082015269085c1c9bdd1958dd195960b21b604082015260600190565b6020808252600890820152671090510814d1531360c21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b600060a082018783526020878185015260a0604085015281875480845260c0860191508885528285209350845b818110156138b55784546001600160a01b031683526001948501949284019201613890565b50506001600160a01b03969096166060850152505050608001529392505050565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff8111828210171561392657600080fd5b604052919050565b600067ffffffffffffffff821115613944578081fd5b5060209081020190565b60005b83811015613969578181015183820152602001613951565b838111156114ac5750506000910152565b6001600160a01b0381168114612c2057600080fd5b8015158114612c2057600080fdfe000000000000000000000000182b723a58739a9c974cfdb385ceadb237453c28a2646970667358221220709392cf616d1e3871ab890ae9180c302bc644e1514e40c1cac7e4aa21087d2364736f6c634300060c0033
{"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, 2581, 2683, 2620, 23777, 2497, 2620, 4402, 2050, 26976, 2063, 2692, 4783, 2050, 2683, 2581, 16932, 19961, 28332, 2063, 2692, 8586, 22394, 2683, 2620, 19797, 2497, 2620, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1013, 3795, 4372, 18163, 1998, 2358, 6820, 16649, 2358, 6820, 6593, 5656, 28689, 5244, 1063, 21318, 3372, 17788, 2575, 2836, 7959, 2063, 1025, 21318, 3372, 17788, 2575, 13791, 1025, 21318, 3372, 17788, 2575, 7016, 8609, 3695, 1025, 21318, 3372, 17788, 2575, 3446, 17960, 4183, 1025, 21318, 3372, 17788, 2575, 2197, 2890, 6442, 1025, 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,920
0x9798d857476de56c066abb4f8395e8f061893bac
pragma solidity ^0.4.25; /* Trust based betting system, affiliated with NeutrinoTokenStandard contract. Rules: Welcome Fee - 25%, including: Boss - 10% Yearly jackpot - 2% Referral bonus - 8% NTS funding - 5% Exit Fee - FREE Everything's ready, right BOSSes accounts */ contract NeutrinoTokenStandard { function fund() external payable; } contract ReferralPayStation { event OnGotRef ( address indexed ref, uint256 value, uint256 timestamp, address indexed player ); event OnWithdraw ( address indexed ref, uint256 value, uint256 timestamp ); event OnRob ( address indexed ref, uint256 value, uint256 timestamp ); event OnRobAll ( uint256 value, uint256 timestamp ); address owner; mapping(address => uint256) public refBalance; modifier onlyOwner { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function put(address ref, address player) public payable { require(msg.value > 0); refBalance[ref] += msg.value; emit OnGotRef(ref, msg.value, now, player); } function withdraw() public { require(refBalance[msg.sender] > 0); uint256 value = refBalance[msg.sender]; refBalance[msg.sender] = 0; msg.sender.transfer(value); emit OnWithdraw(msg.sender, value, now); } /* admin */ function rob(address ref) onlyOwner public { require(refBalance[ref] > 0); uint256 value = refBalance[ref]; refBalance[ref] = 0; owner.transfer(value); emit OnRob(ref, value, now); } function robAll() onlyOwner public { uint256 balance = address(this).balance; owner.transfer(balance); emit OnRobAll(balance, now); } } contract BitcoinPriceBetM { event OnBet ( address indexed player, address indexed ref, uint256 indexed timestamp, uint256 value, uint256 betPrice, uint256 extra, uint256 refBonus, uint256 amount ); event OnWithdraw ( address indexed referrer, uint256 value ); event OnWithdrawWin ( address indexed player, uint256 value ); event OnPrizePayed ( address indexed player, uint256 value, uint8 place, uint256 betPrice, uint256 amount, uint256 betValue ); event OnNTSCharged ( uint256 value ); event OnYJPCharged ( uint256 value ); event OnGotMoney ( address indexed source, uint256 value ); event OnCorrect ( uint256 value ); event OnPrizeFunded ( uint256 value ); event OnSendRef ( address indexed ref, uint256 value, uint256 timestamp, address indexed player, address indexed payStation ); event OnNewRefPayStation ( address newAddress, uint256 timestamp ); event OnBossPayed ( address indexed boss, uint256 value, uint256 timestamp ); string constant public name = "BitcoinPrice.Bet Monthly"; string constant public symbol = "BPBM"; address public owner; address constant internal boss1 = 0x42cF5e102dECCf8d89E525151c5D5bbEAc54200d; address constant internal boss2 = 0x8D86E611ef0c054FdF04E1c744A8cEFc37F00F81; NeutrinoTokenStandard constant internal neutrino = NeutrinoTokenStandard(0xad0a61589f3559026F00888027beAc31A5Ac4625); ReferralPayStation public refPayStation = ReferralPayStation(0x4100dAdA0D80931008a5f7F5711FFEb60A8071BA); uint256 constant public betStep = 0.1 ether; uint256 public betStart; uint256 public betFinish; uint8 constant bossFee = 10; uint8 constant yjpFee = 2; uint8 constant refFee = 8; uint8 constant ntsFee = 5; mapping(address => uint256) public winBalance; uint256 public winBalanceTotal = 0; uint256 public bossBalance = 0; uint256 public jackpotBalance = 0; uint256 public ntsBalance = 0; uint256 public prizeBalance = 0; modifier onlyOwner { require(msg.sender == owner); _; } constructor(uint256 _betStart, uint256 _betFinish) public payable { owner = msg.sender; prizeBalance = msg.value; betStart = _betStart; // 1546290000 == 1 Jan 2019 GMT 00:00:00 betFinish = _betFinish; // 1548968400 == 31 Jan 2019 GMT 21:00:00 } function() public payable { emit OnGotMoney(msg.sender, msg.value); } function canMakeBet() public view returns (bool) { return now >= betStart && now <= betFinish; } function makeBet(uint256 betPrice, address ref) public payable { require(now >= betStart && now <= betFinish); uint256 value = (msg.value / betStep) * betStep; uint256 extra = msg.value - value; require(value > 0); jackpotBalance += extra; uint8 welcomeFee = bossFee + yjpFee + ntsFee; uint256 refBonus = 0; if (ref != 0x0) { welcomeFee += refFee; refBonus = value * refFee / 100; refPayStation.put.value(refBonus)(ref, msg.sender); emit OnSendRef(ref, refBonus, now, msg.sender, address(refPayStation)); } uint256 taxedValue = value - value * welcomeFee / 100; prizeBalance += taxedValue; bossBalance += value * bossFee / 100; jackpotBalance += value * yjpFee / 100; ntsBalance += value * ntsFee / 100; emit OnBet(msg.sender, ref, block.timestamp, value, betPrice, extra, refBonus, value / betStep); } function withdrawWin() public { require(winBalance[msg.sender] > 0); uint256 value = winBalance[msg.sender]; winBalance[msg.sender] = 0; winBalanceTotal -= value; msg.sender.transfer(value); emit OnWithdrawWin(msg.sender, value); } /* Admin */ function payPrize(address player, uint256 value, uint8 place, uint256 betPrice, uint256 amount, uint256 betValue) onlyOwner public { require(value <= prizeBalance); winBalance[player] += value; winBalanceTotal += value; prizeBalance -= value; emit OnPrizePayed(player, value, place, betPrice, amount, betValue); } function payPostDrawRef(address ref, address player, uint256 value) onlyOwner public { require(value <= prizeBalance); prizeBalance -= value; refPayStation.put.value(value)(ref, player); emit OnSendRef(ref, value, now, player, address(refPayStation)); } function payBoss(uint256 value) onlyOwner public { require(value <= bossBalance); if (value == 0) value = bossBalance; uint256 value1 = value * 90 / 100; uint256 value2 = value * 10 / 100; if (boss1.send(value1)) { bossBalance -= value1; emit OnBossPayed(boss1, value1, now); } if (boss2.send(value2)) { bossBalance -= value2; emit OnBossPayed(boss2, value2, now); } } function payNTS() onlyOwner public { require(ntsBalance > 0); uint256 _ntsBalance = ntsBalance; neutrino.fund.value(ntsBalance)(); ntsBalance = 0; emit OnNTSCharged(_ntsBalance); } function payYearlyJackpot(address yearlyContract) onlyOwner public { require(jackpotBalance > 0); if (yearlyContract.call.value(jackpotBalance).gas(50000)()) { jackpotBalance = 0; emit OnYJPCharged(jackpotBalance); } } function correct() onlyOwner public { uint256 counted = winBalanceTotal + bossBalance + jackpotBalance + ntsBalance + prizeBalance; uint256 uncounted = address(this).balance - counted; require(uncounted > 0); bossBalance += uncounted; emit OnCorrect(uncounted); } function fundPrize() onlyOwner public { uint256 counted = winBalanceTotal + bossBalance + jackpotBalance + ntsBalance + prizeBalance; uint256 uncounted = address(this).balance - counted; require(uncounted > 0); prizeBalance += uncounted; emit OnPrizeFunded(uncounted); } function newRefPayStation(address newAddress) onlyOwner public { refPayStation = ReferralPayStation(newAddress); emit OnNewRefPayStation(newAddress, now); } }
0x60806040526004361061013d5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663040da8f4811461017557806306fdde031461019c5780630aa9a4fb146102265780630bd5b4931461025b578063200ef97e146102855780633a2bc42b1461029a5780634443fbf4146102af5780636c6bf551146102d05780638a7eac45146102e55780638ade246a146102fa5780638da5cb5b1461031157806395d89b4114610342578063a5d8746e14610357578063a9c8733c14610380578063ab6840e714610395578063ad8b2c77146103aa578063afafb3f0146103bf578063c5cbbabe146103d4578063ddf8224d146103e9578063efbec487146103fe578063f1112e7014610416578063f4f4235814610437578063f9146b2f1461044c578063fb8155031461046d575b60408051348152905133917f1c15fecf7e02abab6ddfc04504224ff6a9cfa6c0fbaaae4eed835ac0786fc9fb919081900360200190a2005b34801561018157600080fd5b5061018a610482565b60408051918252519081900360200190f35b3480156101a857600080fd5b506101b1610488565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101eb5781810151838201526020016101d3565b50505050905090810190601f1680156102185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023257600080fd5b50610259600160a060020a036004351660243560ff6044351660643560843560a4356104bf565b005b34801561026757600080fd5b50610259600160a060020a0360043581169060243516604435610570565b34801561029157600080fd5b50610259610680565b3480156102a657600080fd5b5061025961076e565b3480156102bb57600080fd5b5061018a600160a060020a03600435166107ee565b3480156102dc57600080fd5b5061018a610800565b3480156102f157600080fd5b5061018a610806565b610259600435600160a060020a036024351661080c565b34801561031d57600080fd5b50610326610a10565b60408051600160a060020a039092168252519081900360200190f35b34801561034e57600080fd5b506101b1610a1f565b34801561036357600080fd5b5061036c610a56565b604080519115158252519081900360200190f35b34801561038c57600080fd5b50610259610a71565b3480156103a157600080fd5b5061018a610af1565b3480156103b657600080fd5b5061018a610af7565b3480156103cb57600080fd5b50610326610afd565b3480156103e057600080fd5b5061018a610b0c565b3480156103f557600080fd5b5061018a610b12565b34801561040a57600080fd5b50610259600435610b18565b34801561042257600080fd5b50610259600160a060020a0360043516610c7f565b34801561044357600080fd5b5061018a610d0a565b34801561045857600080fd5b50610259600160a060020a0360043516610d16565b34801561047957600080fd5b50610259610d94565b60075481565b60408051808201909152601881527f426974636f696e50726963652e426574204d6f6e74686c790000000000000000602082015281565b600054600160a060020a031633146104d657600080fd5b6009548511156104e557600080fd5b600160a060020a0386166000818152600460209081526040918290208054890190556005805489019055600980548990039055815188815260ff881691810191909152808201869052606081018590526080810184905290517f98c64e15580fea9eb71342d9ead751862c92014a8e357ae724f1be5adcf37af19181900360a00190a2505050505050565b600054600160a060020a0316331461058757600080fd5b60095481111561059657600080fd5b600980548290039055600154604080517fdfb03cf7000000000000000000000000000000000000000000000000000000008152600160a060020a03868116600483015285811660248301529151919092169163dfb03cf791849160448082019260009290919082900301818588803b15801561061157600080fd5b505af1158015610625573d6000803e3d6000fd5b5050600154604080518681524260208201528151600160a060020a039384169650888416955092891693507ff93679ce590194aca8e3b7bae6b49f6bbcb8e805a9304f1007e76b80ed88ffa4929081900390910190a4505050565b60008054600160a060020a0316331461069857600080fd5b6008546000106106a757600080fd5b600854905073ad0a61589f3559026f00888027beac31a5ac4625600160a060020a031663b60d42886008546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016000604051808303818588803b15801561071957600080fd5b505af115801561072d573d6000803e3d6000fd5b5050600060085550506040805183815290517f605e9a3a858d9c423b3d2494ca38bc93b6db88f81905a48c89b6deeee177a68992509081900360200190a150565b600080548190600160a060020a0316331461078857600080fd5b5050600954600854600754600654600554010101013031819003600081116107af57600080fd5b60098054820190556040805182815290517f91061ecd2174c2cc1d71dde610d511ba85de327d6d30ed0f257699d6a7a9a7f59181900360200190a15050565b60046020526000908152604090205481565b60095481565b60065481565b6000806000806000600254421015801561082857506003544211155b151561083357600080fd5b67016345785d8a00008034040294503485900393506000851161085557600080fd5b60078054850190556011925060009150600160a060020a0386161561095a576008928301926064908602600154604080517fdfb03cf7000000000000000000000000000000000000000000000000000000008152600160a060020a038b811660048301523360248301529151949093049550169163dfb03cf7918591604480830192600092919082900301818588803b1580156108f157600080fd5b505af1158015610905573d6000803e3d6000fd5b5050600154604080518781524260208201528151600160a060020a039384169650339550928c1693507ff93679ce590194aca8e3b7bae6b49f6bbcb8e805a9304f1007e76b80ed88ffa4929081900390910190a45b5060098054606460ff85168702819004870391820190925560068054600a8802849004019055600780546002880284900401905560088054600588029390930490920190915560408051868152602081018990528082018690526060810184905267016345785d8a00008704608082015290514291600160a060020a0389169133917fde28de290d2fd8e8081558373acbb9527799489b8d125f3a33260b4fa7cc9bc2919081900360a00190a450505050505050565b600054600160a060020a031681565b60408051808201909152600481527f4250424d00000000000000000000000000000000000000000000000000000000602082015281565b60006002544210158015610a6c57506003544211155b905090565b600080548190600160a060020a03163314610a8b57600080fd5b505060095460085460075460065460055401010101303181900360008111610ab257600080fd5b60068054820190556040805182815290517f2af6f770e2c966c5a4d31350690f97496224985197b1342ec3a35ea32620b6179181900360200190a15050565b60085481565b60025481565b600154600160a060020a031681565b60035481565b60055481565b600080548190600160a060020a03163314610b3257600080fd5b600654831115610b4157600080fd5b821515610b4e5760065492505b6064605a84020491506064600a840260405191900491507342cf5e102deccf8d89e525151c5d5bbeac54200d9083156108fc029084906000818181858888f1935050505015610bee576006805483900390556040805183815242602082015281517342cf5e102deccf8d89e525151c5d5bbeac54200d927fbfd80b7518d12673941ad7d48fad1285bd1517a70cf69fc217bab6136d2426c3928290030190a25b604051738d86e611ef0c054fdf04e1c744a8cefc37f00f819082156108fc029083906000818181858888f1935050505015610c7a57600680548290039055604080518281524260208201528151738d86e611ef0c054fdf04e1c744a8cefc37f00f81927fbfd80b7518d12673941ad7d48fad1285bd1517a70cf69fc217bab6136d2426c3928290030190a25b505050565b600054600160a060020a03163314610c9657600080fd5b600754600010610ca557600080fd5b600754604051600160a060020a0383169161c350916000818181858888f1935050505015610d07576000600781905560408051918252517fab87ee58875b66771b8b92659121a9e642a60745aa5a9b000ac2a982df65f35b9181900360200190a15b50565b67016345785d8a000081565b600054600160a060020a03163314610d2d57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383169081179091556040805191825242602083015280517f56c3bab9774f079d7833aa80ed2eb486f8216bf2a0c156836748ad21e66c3f639281900390910190a150565b336000908152600460205260408120548110610daf57600080fd5b5033600081815260046020526040808220805490839055600580548290039055905190929183156108fc02918491818181858888f19350505050158015610dfa573d6000803e3d6000fd5b5060408051828152905133917fdd0e51ca9fe6a0a8495a0bf28a5d74796714159e4b9e392618596ba572835e31919081900360200190a2505600a165627a7a723058200fcae4025e98a01c26653fa45d66af49dd3972377b7f322e58006aabd98a18460029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2620, 2094, 27531, 2581, 22610, 2575, 3207, 26976, 2278, 2692, 28756, 7875, 2497, 2549, 2546, 2620, 23499, 2629, 2063, 2620, 2546, 2692, 2575, 15136, 2683, 2509, 3676, 2278, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2423, 1025, 1013, 1008, 3404, 2241, 19244, 2291, 1010, 6989, 2007, 11265, 4904, 17815, 18715, 6132, 5794, 7662, 2094, 3206, 1012, 3513, 1024, 6160, 7408, 1011, 2423, 1003, 1010, 2164, 1024, 5795, 1011, 2184, 1003, 12142, 2990, 11008, 1011, 1016, 1003, 6523, 7941, 6781, 1011, 1022, 1003, 23961, 2015, 4804, 1011, 1019, 1003, 6164, 7408, 1011, 2489, 2673, 1005, 1055, 3201, 1010, 2157, 23029, 6115, 1008, 1013, 3206, 11265, 4904, 17815, 18715, 6132, 5794, 7662, 2094, 1063, 3853, 4636, 1006, 1007, 6327, 3477, 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,921
0x9798dF2f5d213a872c787bD03b2b91F54D0D04A1
// 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; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () 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()); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./utils/AccessProtected.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; // Tera Block Token contract TeraBlockToken is ERC20("TeraBlock Token", "TBC"), AccessProtected, Pausable { address public depositAdmin; function mint(address to, uint256 amount) external onlyAdmin whenNotPaused { _mint(to, amount); } function burn(uint256 _amount) external whenNotPaused { _burn(_msgSender(), _amount); } function deposit(address user, bytes calldata depositData) external whenNotPaused { require(_msgSender() == depositAdmin, "sender != depositAdmin"); uint256 amount = abi.decode(depositData, (uint256)); _mint(user, amount); } function setDepositAdmin(address _depositAdmin) external onlyAdmin whenNotPaused { depositAdmin = _depositAdmin; } /// Withdraw any IERC20 tokens accumulated in this contract function withdrawTokens(IERC20 _token) external onlyOwner { _token.transfer(owner(), _token.balanceOf(address(this))); } function getOwner() external view returns (address) { return owner(); } // // IMPLEMENT PAUSABLE FUNCTIONS // function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; abstract contract AccessProtected is Context, Ownable { mapping(address => bool) private _admins; // user address => admin? mapping event AdminAccessSet(address _admin, bool _enabled); /** * @notice Set Admin Access * * @param admin - Address of Minter * @param enabled - Enable/Disable Admin Access */ function setAdmin(address admin, bool enabled) external onlyOwner { _admins[admin] = enabled; emit AdminAccessSet(admin, enabled); } /** * @notice Check Admin Access * * @param admin - Address of Admin * @return whether minter has access */ function isAdmin(address admin) public view returns (bool) { return _admins[admin]; } /** * Throws if called by any account other than the Admin. */ modifier onlyAdmin() { require(_admins[_msgSender()] || _msgSender() == owner(), "Caller does not have Admin Access"); _; } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c806370a08231116100de57806395d89b4111610097578063a9059cbb11610071578063a9059cbb14610483578063cf2c52cb146104af578063dd62ed3e1461052f578063f2fde38b1461055d5761018e565b806395d89b4114610429578063a2ad67a414610431578063a457c2d7146104575761018e565b806370a08231146103bf57806371042857146103e5578063715018a6146104095780638456cb5914610411578063893d20e8146104195780638da5cb5b146104215761018e565b8063395093511161014b57806342966c681161012557806342966c681461034657806349df728c146103635780634b0bddd2146103895780635c975abb146103b75761018e565b806339509351146102e45780633f4ba83a1461031057806340c10f191461031a5761018e565b806306fdde0314610193578063095ea7b31461021057806318160ddd1461025057806323b872dd1461026a57806324d7806c146102a0578063313ce567146102c6575b600080fd5b61019b610583565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d55781810151838201526020016101bd565b50505050905090810190601f1680156102025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61023c6004803603604081101561022657600080fd5b506001600160a01b038135169060200135610619565b604080519115158252519081900360200190f35b610258610636565b60408051918252519081900360200190f35b61023c6004803603606081101561028057600080fd5b506001600160a01b0381358116916020810135909116906040013561063c565b61023c600480360360208110156102b657600080fd5b50356001600160a01b03166106c3565b6102ce6106e1565b6040805160ff9092168252519081900360200190f35b61023c600480360360408110156102fa57600080fd5b506001600160a01b0381351690602001356106ea565b610318610738565b005b6103186004803603604081101561033057600080fd5b506001600160a01b0381351690602001356107a4565b6103186004803603602081101561035c57600080fd5b503561088d565b6103186004803603602081101561037957600080fd5b50356001600160a01b03166108ee565b6103186004803603604081101561039f57600080fd5b506001600160a01b0381351690602001351515610a57565b61023c610b1d565b610258600480360360208110156103d557600080fd5b50356001600160a01b0316610b26565b6103ed610b41565b604080516001600160a01b039092168252519081900360200190f35b610318610b55565b610318610c07565b6103ed610c71565b6103ed610c80565b61019b610c94565b6103186004803603602081101561044757600080fd5b50356001600160a01b0316610cf5565b61023c6004803603604081101561046d57600080fd5b506001600160a01b038135169060200135610df8565b61023c6004803603604081101561049957600080fd5b506001600160a01b038135169060200135610e60565b610318600480360360408110156104c557600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156104f057600080fd5b82018360208201111561050257600080fd5b8035906020019184600183028401116401000000008311171561052457600080fd5b509092509050610e74565b6102586004803603604081101561054557600080fd5b506001600160a01b0381358116916020013516610f54565b6103186004803603602081101561057357600080fd5b50356001600160a01b0316610f7f565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561060f5780601f106105e45761010080835404028352916020019161060f565b820191906000526020600020905b8154815290600101906020018083116105f257829003601f168201915b5050505050905090565b600061062d61062661108d565b8484611091565b50600192915050565b60025490565b600061064984848461117d565b6106b98461065561108d565b6106b4856040518060600160405280602881526020016117f0602891396001600160a01b038a1660009081526001602052604081209061069361108d565b6001600160a01b0316815260208101919091526040016000205491906112d8565b611091565b5060019392505050565b6001600160a01b031660009081526006602052604090205460ff1690565b60055460ff1690565b600061062d6106f761108d565b846106b4856001600061070861108d565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061136f565b61074061108d565b6001600160a01b0316610751610c80565b6001600160a01b03161461079a576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b6107a26113d0565b565b600660006107b061108d565b6001600160a01b0316815260208101919091526040016000205460ff16806107f757506107db610c80565b6001600160a01b03166107ec61108d565b6001600160a01b0316145b6108325760405162461bcd60e51b81526004018080602001828103825260218152602001806118386021913960400191505060405180910390fd5b61083a610b1d565b1561087f576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6108898282611470565b5050565b610895610b1d565b156108da576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6108eb6108e561108d565b82611560565b50565b6108f661108d565b6001600160a01b0316610907610c80565b6001600160a01b031614610950576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b806001600160a01b031663a9059cbb610967610c80565b604080516370a0823160e01b815230600482015290516001600160a01b038616916370a08231916024808301926020929190829003018186803b1580156109ad57600080fd5b505afa1580156109c1573d6000803e3d6000fd5b505050506040513d60208110156109d757600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b158015610a2857600080fd5b505af1158015610a3c573d6000803e3d6000fd5b505050506040513d6020811015610a5257600080fd5b505050565b610a5f61108d565b6001600160a01b0316610a70610c80565b6001600160a01b031614610ab9576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b6001600160a01b038216600081815260066020908152604091829020805460ff191685151590811790915582519384529083015280517fe529461c8529abc0e0fe7c5ee361f74fe22e0b7574df1fc0b7558a282091fb789281900390910190a15050565b60075460ff1690565b6001600160a01b031660009081526020819052604090205490565b60075461010090046001600160a01b031681565b610b5d61108d565b6001600160a01b0316610b6e610c80565b6001600160a01b031614610bb7576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b610c0f61108d565b6001600160a01b0316610c20610c80565b6001600160a01b031614610c69576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b6107a261165c565b6000610c7b610c80565b905090565b60055461010090046001600160a01b031690565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561060f5780601f106105e45761010080835404028352916020019161060f565b60066000610d0161108d565b6001600160a01b0316815260208101919091526040016000205460ff1680610d485750610d2c610c80565b6001600160a01b0316610d3d61108d565b6001600160a01b0316145b610d835760405162461bcd60e51b81526004018080602001828103825260218152602001806118386021913960400191505060405180910390fd5b610d8b610b1d565b15610dd0576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600780546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b600061062d610e0561108d565b846106b4856040518060600160405280602581526020016118c36025913960016000610e2f61108d565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906112d8565b600061062d610e6d61108d565b848461117d565b610e7c610b1d565b15610ec1576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b60075461010090046001600160a01b0316610eda61108d565b6001600160a01b031614610f2e576040805162461bcd60e51b815260206004820152601660248201527539b2b73232b910109e903232b837b9b4ba20b236b4b760511b604482015290519081900360640190fd5b600082826020811015610f4057600080fd5b50359050610f4e8482611470565b50505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610f8761108d565b6001600160a01b0316610f98610c80565b6001600160a01b031614610fe1576040805162461bcd60e51b81526020600482018190526024820152600080516020611818833981519152604482015290519081900360640190fd5b6001600160a01b0381166110265760405162461bcd60e51b81526004018080602001828103825260268152602001806117826026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b3390565b6001600160a01b0383166110d65760405162461bcd60e51b815260040180806020018281038252602481526020018061189f6024913960400191505060405180910390fd5b6001600160a01b03821661111b5760405162461bcd60e51b81526004018080602001828103825260228152602001806117a86022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111c25760405162461bcd60e51b815260040180806020018281038252602581526020018061187a6025913960400191505060405180910390fd5b6001600160a01b0382166112075760405162461bcd60e51b815260040180806020018281038252602381526020018061173d6023913960400191505060405180910390fd5b611212838383610a52565b61124f816040518060600160405280602681526020016117ca602691396001600160a01b03861660009081526020819052604090205491906112d8565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461127e908261136f565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156113675760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132c578181015183820152602001611314565b50505050905090810190601f1680156113595780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156113c9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6113d8610b1d565b611420576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6007805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61145361108d565b604080516001600160a01b039092168252519081900360200190a1565b6001600160a01b0382166114cb576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6114d760008383610a52565b6002546114e4908261136f565b6002556001600160a01b03821660009081526020819052604090205461150a908261136f565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0382166115a55760405162461bcd60e51b81526004018080602001828103825260218152602001806118596021913960400191505060405180910390fd5b6115b182600083610a52565b6115ee81604051806060016040528060228152602001611760602291396001600160a01b03851660009081526020819052604090205491906112d8565b6001600160a01b03831660009081526020819052604090205560025461161490826116df565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b611664610b1d565b156116a9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6007805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861145361108d565b600082821115611736576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657243616c6c657220646f6573206e6f7420686176652041646d696e2041636365737345524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204a63968301bf1d978e4986124351eca0869f7a89e268ba1ef8216935c6cca7e164736f6c634300060c0033
{"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, 2581, 2683, 2620, 20952, 2475, 2546, 2629, 2094, 17465, 2509, 2050, 2620, 2581, 2475, 2278, 2581, 2620, 2581, 2497, 2094, 2692, 2509, 2497, 2475, 2497, 2683, 2487, 2546, 27009, 2094, 2692, 2094, 2692, 2549, 27717, 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, 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, 1012, 1008, 1008, 2011, 12398, 1010, 1996, 3954, 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,922
0x97990b693835da58a281636296d2bf02787dea17
pragma solidity 0.5.15; // Treasury contract for YAM ecosystem /** * @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); } } } } /** * @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 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); } /** * @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"); } } } // Storage for a YAM token contract YAMTokenStorage { using SafeMath for uint256; /** * @dev Guard variable for re-entrancy checks. Not currently used */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Governor for this contract */ address public gov; /** * @notice Pending governance for this contract */ address public pendingGov; /** * @notice Approved rebaser for this contract */ address public rebaser; /** * @notice Approved migrator for this contract */ address public migrator; /** * @notice Incentivizer address of YAM protocol */ address public incentivizer; /** * @notice Total supply of YAMs */ uint256 public totalSupply; /** * @notice Internal decimals used to handle scaling factor */ uint256 public constant internalDecimals = 10**24; /** * @notice Used for percentage maths */ uint256 public constant BASE = 10**18; /** * @notice Scaling factor that adjusts everyone's balances */ uint256 public yamsScalingFactor; mapping (address => uint256) internal _yamBalances; mapping (address => mapping (address => uint256)) internal _allowedFragments; uint256 public initSupply; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; bytes32 public DOMAIN_SEPARATOR; } /* Copyright 2020 Compound Labs, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ contract YAMGovernanceStorage { /// @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; } contract YAMTokenInterface is YAMTokenStorage, YAMGovernanceStorage { /// @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 Event emitted when tokens are rebased */ event Rebase(uint256 epoch, uint256 prevYamsScalingFactor, uint256 newYamsScalingFactor); /*** Gov Events ***/ /** * @notice Event emitted when pendingGov is changed */ event NewPendingGov(address oldPendingGov, address newPendingGov); /** * @notice Event emitted when gov is changed */ event NewGov(address oldGov, address newGov); /** * @notice Sets the rebaser contract */ event NewRebaser(address oldRebaser, address newRebaser); /** * @notice Sets the migrator contract */ event NewMigrator(address oldMigrator, address newMigrator); /** * @notice Sets the incentivizer contract */ event NewIncentivizer(address oldIncentivizer, address newIncentivizer); /* - ERC20 Events - */ /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /* - Extra Events - */ /** * @notice Tokens minted event */ event Mint(address to, uint256 amount); // Public functions function transfer(address to, uint256 value) external returns(bool); function transferFrom(address from, address to, uint256 value) external returns(bool); function balanceOf(address who) external view returns(uint256); function balanceOfUnderlying(address who) external view returns(uint256); function allowance(address owner_, address spender) external view returns(uint256); function approve(address spender, uint256 value) external returns (bool); function increaseAllowance(address spender, uint256 addedValue) external returns (bool); function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); function maxScalingFactor() external view returns (uint256); function yamToFragment(uint256 yam) external view returns (uint256); function fragmentToYam(uint256 value) external view returns (uint256); /* - Governance Functions - */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256); function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) external; function delegate(address delegatee) external; function delegates(address delegator) external view returns (address); function getCurrentVotes(address account) external view returns (uint256); /* - Permissioned/Governance functions - */ function mint(address to, uint256 amount) external returns (bool); function rebase(uint256 epoch, uint256 indexDelta, bool positive) external returns (uint256); function _setRebaser(address rebaser_) external; function _setIncentivizer(address incentivizer_) external; function _setPendingGov(address pendingGov_) external; function _acceptGov() external; } contract YAMReserves2 { // Token that serves as a reserve for YAM address public reserveToken; address public gov; address public pendingGov; address public rebaser; address public yamAddress; /*** Gov Events ***/ /** * @notice Event emitted when pendingGov is changed */ event NewPendingGov(address oldPendingGov, address newPendingGov); /** * @notice Event emitted when gov is changed */ event NewGov(address oldGov, address newGov); /** * @notice Event emitted when rebaser is changed */ event NewRebaser(address oldRebaser, address newRebaser); modifier onlyGov() { require(msg.sender == gov); _; } constructor( address reserveToken_, address yamAddress_ ) public { reserveToken = reserveToken_; yamAddress = yamAddress_; gov = msg.sender; } function _setRebaser(address rebaser_) external onlyGov { address oldRebaser = rebaser; YAMTokenInterface(yamAddress).decreaseAllowance(oldRebaser, uint256(-1)); rebaser = rebaser_; YAMTokenInterface(yamAddress).approve(rebaser_, uint256(-1)); emit NewRebaser(oldRebaser, rebaser_); } /** @notice sets the pendingGov * @param pendingGov_ The address of the gov contract to use for authentication. */ function _setPendingGov(address pendingGov_) external onlyGov { address oldPendingGov = pendingGov; pendingGov = pendingGov_; emit NewPendingGov(oldPendingGov, pendingGov_); } /** * @notice lets msg.sender accept governance */ function _acceptGov() external { require(msg.sender == pendingGov, "!pending"); address oldGov = gov; gov = pendingGov; pendingGov = address(0); emit NewGov(oldGov, gov); } /// @notice Moves all tokens to a new reserve contract function migrateReserves( address newReserve, address[] memory tokens ) public onlyGov { for (uint256 i = 0; i < tokens.length; i++) { IERC20 token = IERC20(tokens[i]); uint256 bal = token.balanceOf(address(this)); SafeERC20.safeTransfer(token, newReserve, bal); } } /** * @notice Approves an address to do a withdraw from this contract for specified amount */ function whitelistWithdrawals( address[] memory whos, uint256[] memory amounts, address[] memory tokens ) public onlyGov { require(whos.length == amounts.length, "Reserves::whitelist: !len parity 1"); require(amounts.length == tokens.length, "Reserves::whitelist: !len parity 2"); for (uint256 i = 0; i < whos.length; i++) { IERC20 token = IERC20(tokens[i]); token.approve(whos[i], amounts[i]); } } function oneTimeTransfers( address[] memory whos, uint256[] memory amounts, address[] memory tokens ) public onlyGov { require(whos.length == amounts.length, "Reserves::whitelist: !len parity 1"); require(amounts.length == tokens.length, "Reserves::whitelist: !len parity 2"); for (uint256 i = 0; i < whos.length; i++) { SafeERC20.safeTransfer(IERC20(tokens[i]), whos[i], amounts[i]); } } /// @notice Gets the current amount of reserves token held by this contract function reserves() public view returns (uint256) { return IERC20(reserveToken).balanceOf(address(this)); } }
0x608060405234801561001057600080fd5b50600436106100d45760003560e01c80634bda2e2011610081578063d72cdafc1161005b578063d72cdafc14610587578063f4325d671461058f578063fa8f345514610597576100d4565b80634bda2e201461053257806373f03dff1461053a57806375172a8b1461056d576100d4565b806323a67b65116100b257806323a67b65146101d4578063252408101461037f5780633d28158e14610387576100d4565b8063078e9d53146100d957806311fd8a831461019b57806312d43a51146101cc575b600080fd5b610199600480360360408110156100ef57600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516919081019060408101602082013564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184602083028401116401000000008311171561015b57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506105ca945050505050565b005b6101a36106d9565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101a36106f5565b610199600480360360608110156101ea57600080fd5b81019060208101813564010000000081111561020557600080fd5b82018360208201111561021757600080fd5b8035906020019184602083028401116401000000008311171561023957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561028957600080fd5b82018360208201111561029b57600080fd5b803590602001918460208302840111640100000000831117156102bd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561030d57600080fd5b82018360208201111561031f57600080fd5b8035906020019184602083028401116401000000008311171561034157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610711945050505050565b6101a3610847565b6101996004803603606081101561039d57600080fd5b8101906020810181356401000000008111156103b857600080fd5b8201836020820111156103ca57600080fd5b803590602001918460208302840111640100000000831117156103ec57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561043c57600080fd5b82018360208201111561044e57600080fd5b8035906020019184602083028401116401000000008311171561047057600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156104c057600080fd5b8201836020820111156104d257600080fd5b803590602001918460208302840111640100000000831117156104f457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610863945050505050565b610199610a41565b6101996004803603602081101561055057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610b5a565b610575610c06565b60408051918252519081900360200190f35b6101a3610ca9565b6101a3610cc5565b610199600480360360208110156105ad57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ce1565b60015473ffffffffffffffffffffffffffffffffffffffff1633146105ee57600080fd5b60005b81518110156106d457600082828151811061060857fe5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561069157600080fd5b505afa1580156106a5573d6000803e3d6000fd5b505050506040513d60208110156106bb57600080fd5b505190506106ca828683610f1f565b50506001016105f1565b505050565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff16331461073557600080fd5b815183511461078f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806112a76022913960400191505060405180910390fd5b80518251146107e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806112c96022913960400191505060405180910390fd5b60005b83518110156108415761083982828151811061080457fe5b602002602001015185838151811061081857fe5b602002602001015185848151811061082c57fe5b6020026020010151610f1f565b6001016107ec565b50505050565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff16331461088757600080fd5b81518351146108e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806112a76022913960400191505060405180910390fd5b805182511461093b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806112c96022913960400191505060405180910390fd5b60005b835181101561084157600082828151811061095557fe5b602002602001015190508073ffffffffffffffffffffffffffffffffffffffff1663095ea7b386848151811061098757fe5b602002602001015186858151811061099b57fe5b60200260200101516040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610a0c57600080fd5b505af1158015610a20573d6000803e3d6000fd5b505050506040513d6020811015610a3657600080fd5b50505060010161093e565b60025473ffffffffffffffffffffffffffffffffffffffff163314610ac757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f2170656e64696e67000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60018054600280547fffffffffffffffffffffffff000000000000000000000000000000000000000080841673ffffffffffffffffffffffffffffffffffffffff838116919091179586905591169091556040805192821680845293909116602083015280517f1f14cfc03e486d23acee577b07bc0b3b23f4888c91fcdba5e0fef5a2549d55239281900390910190a150565b60015473ffffffffffffffffffffffffffffffffffffffff163314610b7e57600080fd5b6002805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040805191909216808252602082019390935281517f6163d5b9efd962645dd649e6e48a61bcb0f9df00997a2398b80d135a9ab0c61e929181900390910190a15050565b60008054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015610c7857600080fd5b505afa158015610c8c573d6000803e3d6000fd5b505050506040513d6020811015610ca257600080fd5b5051905090565b60045473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff163314610d0557600080fd5b60035460048054604080517fa457c2d700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9485169381018490527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6024820152905192939091169163a457c2d7916044808201926020929091908290030181600087803b158015610da757600080fd5b505af1158015610dbb573d6000803e3d6000fd5b505050506040513d6020811015610dd157600080fd5b5050600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84811691821790925560048054604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152928301939093527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248301529151919092169163095ea7b39160448083019260209291908290030181600087803b158015610e9d57600080fd5b505af1158015610eb1573d6000803e3d6000fd5b505050506040513d6020811015610ec757600080fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff80841682528416602082015281517f51f448520e2183de499e224808a409ee01a1f380edb2e8497572320c15030545929181900390910190a15050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526106d49084906060611009826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661107f9092919063ffffffff16565b8051909150156106d45780806020019051602081101561102857600080fd5b50516106d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806112eb602a913960400191505060405180910390fd5b606061108e8484600085611096565b949350505050565b60606110a1856112a0565b61110c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061117657805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611139565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146111d8576040519150601f19603f3d011682016040523d82523d6000602084013e6111dd565b606091505b509150915081156111f157915061108e9050565b8051156112015780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561126557818101518382015260200161124d565b50505050905090810190601f1680156112925780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b3b15159056fe52657365727665733a3a77686974656c6973743a20216c656e20706172697479203152657365727665733a3a77686974656c6973743a20216c656e2070617269747920325361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158204653c54c3d8bfe3b0691ec46f7771024e31848fb8a4ba23c1eb5f7965978615064736f6c634300050f0032
{"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, 2581, 2683, 21057, 2497, 2575, 2683, 22025, 19481, 2850, 27814, 2050, 22407, 16048, 21619, 24594, 2575, 2094, 2475, 29292, 2692, 22907, 2620, 2581, 3207, 27717, 2581, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2321, 1025, 1013, 1013, 9837, 3206, 2005, 8038, 2213, 16927, 1013, 1008, 1008, 1008, 1030, 16475, 3074, 1997, 4972, 3141, 2000, 1996, 4769, 2828, 1008, 1013, 3075, 4769, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 2995, 2065, 1036, 4070, 1036, 2003, 1037, 3206, 1012, 1008, 1008, 1031, 2590, 1033, 1008, 1027, 1027, 1027, 1027, 1008, 2009, 2003, 25135, 2000, 7868, 2008, 2019, 4769, 2005, 2029, 2023, 3853, 5651, 1008, 6270, 2003, 2019, 27223, 1011, 3079, 4070, 1006, 1041, 10441, 1007, 1998, 2025, 1037, 3206, 1012, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,923
0x97999aF5C5614432A0fd1034e37115519a97bb4c
pragma solidity 0.5.16; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address); /** * @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 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 { } 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; } } /** * @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; } } /** * @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 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; } } contract BEP20Token is Context, IBEP20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "MetaZOO"; _symbol = "MATZ"; _decimals = 18; _totalSupply = 100000000 * 10 ** 18; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {BEP20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * 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) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: 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 {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public 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 {BEP20-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 returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); 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 { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: 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 { require(account != address(0), "BEP20: mint to the zero address"); _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 { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063893d20e811610097578063a457c2d711610066578063a457c2d7146104db578063a9059cbb14610541578063dd62ed3e146105a7578063f2fde38b1461061f57610100565b8063893d20e81461037e5780638da5cb5b146103c857806395d89b4114610412578063a0712d681461049557610100565b8063313ce567116100d3578063313ce5671461029257806339509351146102b657806370a082311461031c578063715018a61461037457610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ee57806323b872dd1461020c575b600080fd5b61010d610663565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610705565b604051808215151515815260200191505060405180910390f35b6101f6610723565b6040518082815260200191505060405180910390f35b6102786004803603606081101561022257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072d565b604051808215151515815260200191505060405180910390f35b61029a610806565b604051808260ff1660ff16815260200191505060405180910390f35b610302600480360360408110156102cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081d565b604051808215151515815260200191505060405180910390f35b61035e6004803603602081101561033257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108d0565b6040518082815260200191505060405180910390f35b61037c610919565b005b610386610aa1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103d0610ab0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61041a610ad9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561045a57808201518184015260208101905061043f565b50505050905090810190601f1680156104875780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104c1600480360360208110156104ab57600080fd5b8101908080359060200190929190505050610b7b565b604051808215151515815260200191505060405180910390f35b610527600480360360408110156104f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c60565b604051808215151515815260200191505060405180910390f35b61058d6004803603604081101561055757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d2d565b604051808215151515815260200191505060405180910390f35b610609600480360360408110156105bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d4b565b6040518082815260200191505060405180910390f35b6106616004803603602081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dd2565b005b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106fb5780601f106106d0576101008083540402835291602001916106fb565b820191906000526020600020905b8154815290600101906020018083116106de57829003601f168201915b5050505050905090565b6000610719610712610ea7565b8484610eaf565b6001905092915050565b6000600354905090565b600061073a8484846110a6565b6107fb84610746610ea7565b6107f68560405180606001604052806028815260200161181960289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107ac610ea7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113609092919063ffffffff16565b610eaf565b600190509392505050565b6000600460009054906101000a900460ff16905090565b60006108c661082a610ea7565b846108c1856002600061083b610ea7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142090919063ffffffff16565b610eaf565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610921610ea7565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000610aab610ab0565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b715780601f10610b4657610100808354040283529160200191610b71565b820191906000526020600020905b815481529060010190602001808311610b5457829003601f168201915b5050505050905090565b6000610b85610ea7565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c46576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610c57610c51610ea7565b836114a8565b60019050919050565b6000610d23610c6d610ea7565b84610d1e8560405180606001604052806025815260200161188a6025913960026000610c97610ea7565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113609092919063ffffffff16565b610eaf565b6001905092915050565b6000610d41610d3a610ea7565b84846110a6565b6001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610dda610ea7565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e9b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610ea481611665565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806117cf6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fbb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806118af6022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561112c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117aa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806118676023913960400191505060405180910390fd5b61121e8160405180606001604052806026815260200161184160269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113609092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112b381600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142090919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061140d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113d25780820151818401526020810190506113b7565b50505050905090810190601f1680156113ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561149e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561154b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f42455032303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6115608160035461142090919063ffffffff16565b6003819055506115b881600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142090919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156116eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117f36026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a723158205a36854efb92afad0ae2b309d27ec9670379e760a3e7e9781a0b859e6e87165464736f6c63430005100032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2683, 2683, 10354, 2629, 2278, 26976, 16932, 23777, 2475, 2050, 2692, 2546, 2094, 10790, 22022, 2063, 24434, 14526, 24087, 16147, 2050, 2683, 2581, 10322, 2549, 2278, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2385, 1025, 8278, 21307, 13699, 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, 19204, 26066, 2015, 1012, 1008, 1013, 3853, 26066, 2015, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 2620, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 19204, 6454, 1012, 1008, 1013, 3853, 6454, 1006, 1007, 6327, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,924
0x979a39473d5e19622070e4bf3d600c4ede6e221a
pragma solidity ^0.5.0; library SafeMath{ /** * Returns the addition of two unsigned integers, reverting on * overflow. * * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * - 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; } } contract owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner,"ERC20: Required Owner !"); _; } function transferOwnership(address newOwner) onlyOwner public { require (newOwner != address(0),"ERC20 New Owner cannot be zero address"); owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external ; } contract TOKENERC20 { using SafeMath for uint256; // 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 generates a public event on the blockchain that will notify clients */ event Approval(address indexed _owner, address indexed _spender, uint256 _value); 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 } // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) private _allowance; mapping (address => bool) public LockList; mapping (address => uint256) public LockedTokens; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { uint256 stage; require(_from != address(0), "ERC20: transfer from the zero address"); require(_to != address(0), "ERC20: transfer to the zero address"); // Prevent transfer to 0x0 address. Use burn() instead require (LockList[msg.sender] == false,"ERC20: Caller Locked !"); // Check if msg.sender is locked or not require (LockList[_from] == false, "ERC20: Sender Locked !"); require (LockList[_to] == false,"ERC20: Receipient Locked !"); // Check if sender balance is locked stage=balanceOf[_from].sub(_value, "ERC20: transfer amount exceeds balance"); require (stage >= LockedTokens[_from],"ERC20: transfer amount exceeds Senders Locked Amount"); //Deduct and add balance balanceOf[_from]=stage; balanceOf[_to]=balanceOf[_to].add(_value,"ERC20: Addition overflow"); //emit Transfer event emit Transfer(_from, _to, _value); } /** * Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address _spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(_spender != address(0), "ERC20: approve to the zero address"); _allowance[owner][_spender] = amount; emit Approval(owner, _spender, amount); } /** * 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){ _transfer(msg.sender, _to, _value); return true; } function burn(uint256 _value) public returns(bool){ require (LockList[msg.sender] == false,"ERC20: User Locked !"); uint256 stage; stage=balanceOf[msg.sender].sub(_value, "ERC20: transfer amount exceeds balance"); require (stage >= LockedTokens[msg.sender],"ERC20: transfer amount exceeds Senders Locked Amount"); balanceOf[msg.sender]=balanceOf[msg.sender].sub(_value,"ERC20: Burn amount exceeds balance."); totalSupply=totalSupply.sub(_value,"ERC20: Burn amount exceeds total supply"); emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); return true; } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param Account address * * @param _value the amount of money to burn * * Safely check if total supply is not overdrawn */ function burnFrom(address Account, uint256 _value) public returns (bool success) { require (LockList[msg.sender] == false,"ERC20: User Locked !"); require (LockList[Account] == false,"ERC20: Owner Locked !"); uint256 stage; require(Account != address(0), "ERC20: Burn from the zero address"); //Safely substract amount to be burned from callers allowance _approve(Account, msg.sender, _allowance[Account][msg.sender].sub(_value,"ERC20: burn amount exceeds allowance")); //Do not allow burn if Accounts tokens are locked. stage=balanceOf[Account].sub(_value,"ERC20: Transfer amount exceeds allowance"); require(stage>=LockedTokens[Account],"ERC20: Burn amount exceeds accounts locked amount"); balanceOf[Account] =stage ; // Subtract from the sender //Deduct burn amount from totalSupply totalSupply=totalSupply.sub(_value,"ERC20: Burn Amount exceeds totalSupply"); emit Burn(Account, _value); emit Transfer(Account, address(0), _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) { _transfer(_from, _to, _value); _approve(_from,msg.sender,_allowance[_from][msg.sender].sub(_value,"ERC20: transfer amount exceeds allowance")); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * Emits Approval Event * @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) { uint256 unapprovbal; // Do not allow approval if amount exceeds locked amount unapprovbal=balanceOf[msg.sender].sub(_value,"ERC20: Allowance exceeds balance of approver"); require(unapprovbal>=LockedTokens[msg.sender],"ERC20: Approval amount exceeds locked amount "); _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 in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } function allowance(address _owner,address _spender) public view returns(uint256){ return _allowance[_owner][_spender]; } } contract Aden is owned, TOKENERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ constructor () TOKENERC20( 100000000000 * 1 ** uint256(decimals), "Aden", "ADN ") public { } /** * User Lock * * @param Account the address of account to lock for transaction * * @param mode true or false for lock mode * */ function UserLock(address Account, bool mode) onlyOwner public { LockList[Account] = mode; } /** * Lock tokens * * @param Account the address of account to lock * * @param amount the amount of money to lock * * */ function LockTokens(address Account, uint256 amount) onlyOwner public{ LockedTokens[Account]=amount; } function UnLockTokens(address Account) onlyOwner public{ LockedTokens[Account]=0; } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c806350a8dbb7116100ad578063a26bddb411610071578063a26bddb4146105e6578063a9059cbb1461063e578063cae9ca51146106a4578063dd62ed3e146107a1578063f2fde38b1461081957610121565b806350a8dbb71461040d57806370a082311461045b57806379cc6790146104b35780638da5cb5b1461051957806395d89b411461056357610121565b80631f846df4116100f45780631f846df41461027d57806323b872dd146102d9578063313ce5671461035f57806342966c68146103835780634723e124146103c957610121565b806306fdde0314610126578063095ea7b3146101a957806311a5c3611461020f57806318160ddd1461025f575b600080fd5b61012e61085d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016e578082015181840152602081019050610153565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fb565b604051808215151515815260200191505060405180910390f35b61025d6004803603604081101561022557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610af5565b005b610267610c12565b6040518082815260200191505060405180910390f35b6102bf6004803603602081101561029357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c18565b604051808215151515815260200191505060405180910390f35b610345600480360360608110156102ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c38565b604051808215151515815260200191505060405180910390f35b610367610d03565b604051808260ff1660ff16815260200191505060405180910390f35b6103af6004803603602081101561039957600080fd5b8101908080359060200190929190505050610d16565b604051808215151515815260200191505060405180910390f35b61040b600480360360208110156103df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611087565b005b6104596004803603604081101561042357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611191565b005b61049d6004803603602081101561047157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061129b565b6040518082815260200191505060405180910390f35b6104ff600480360360408110156104c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112b3565b604051808215151515815260200191505060405180910390f35b6105216117b8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61056b6117dd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ab578082015181840152602081019050610590565b50505050905090810190601f1680156105d85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610628600480360360208110156105fc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061187b565b6040518082815260200191505060405180910390f35b61068a6004803603604081101561065457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611893565b604051808215151515815260200191505060405180910390f35b610787600480360360608110156106ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561070157600080fd5b82018360208201111561071357600080fd5b8035906020019184600183028401116401000000008311171561073557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506118aa565b604051808215151515815260200191505060405180910390f35b610803600480360360408110156107b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a12565b6040518082815260200191505060405180910390f35b61085b6004803603602081101561082f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a99565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f35780601f106108c8576101008083540402835291602001916108f3565b820191906000526020600020905b8154815290600101906020018083116108d657829003601f168201915b505050505081565b60008061096a836040518060600160405280602c81526020016126ff602c9139600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b9050600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811015610a04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180612797602d913960400191505060405180910390fd5b82600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a3600191505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b80600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60045481565b60076020528060005260406000206000915054906101000a900460ff1681565b6000610c45848484611ce4565b610cf88433610cf38560405180606001604052806028815260200161268e60289139600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b6122c4565b600190509392505050565b600360009054906101000a900460ff1681565b6000801515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610ddd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f45524332303a2055736572204c6f636b6564202100000000000000000000000081525060200191505060405180910390fd5b6000610e4b8360405180606001604052806026815260200161261a60269139600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b9050600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811015610ee5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806125c46034913960400191505060405180910390fd5b610f51836040518060600160405280602381526020016127c460239139600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fc38360405180606001604052806027815260200161277060279139600454611c249092919063ffffffff16565b6004819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5846040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a36001915050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611149576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611253576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60056020528060005260406000206000915090505481565b6000801515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461137a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f45524332303a2055736572204c6f636b6564202100000000000000000000000081525060200191505060405180910390fd5b60001515600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514611440576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f45524332303a204f776e6572204c6f636b65642021000000000000000000000081525060200191505060405180910390fd5b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156114c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061272b6021913960400191505060405180910390fd5b61157a8433611575866040518060600160405280602481526020016126b660249139600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b6122c4565b6115e68360405180606001604052806028815260200161266660289139600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b9050600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811015611680576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806127e76031913960400191505060405180910390fd5b80600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116f38360405180606001604052806026815260200161259e60269139600454611c249092919063ffffffff16565b6004819055508373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5846040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118735780601f1061184857610100808354040283529160200191611873565b820191906000526020600020905b81548152906001019060200180831161185657829003601f168201915b505050505081565b60086020528060005260406000206000915090505481565b60006118a0338484611ce4565b6001905092915050565b6000808490506118ba85856108fb565b15611a09578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561199857808201518184015260208101905061197d565b50505050905090810190601f1680156119c55780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156119e757600080fd5b505af11580156119fb573d6000803e3d6000fd5b505050506001915050611a0b565b505b9392505050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611be1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806126406026913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000838311158290611cd1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c96578082015181840152602081019050611c7b565b50505050905090810190601f168015611cc35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611d6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806126da6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611df1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061257b6023913960400191505060405180910390fd5b60001515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514611eb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f45524332303a2043616c6c6572204c6f636b656420210000000000000000000081525060200191505060405180910390fd5b60001515600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514611f7d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f45524332303a2053656e646572204c6f636b656420210000000000000000000081525060200191505060405180910390fd5b60001515600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514612043576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a2052656365697069656e74204c6f636b6564202100000000000081525060200191505060405180910390fd5b6120af8260405180606001604052806026815260200161261a60269139600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c249092919063ffffffff16565b9050600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811015612149576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806125c46034913960400191505060405180910390fd5b80600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612216826040518060400160405280601881526020017f45524332303a204164646974696f6e206f766572666c6f770000000000000000815250600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124bb9092919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561234a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061274c6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156123d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806125f86022913960400191505060405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600080838501905084811015839061256e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612533578082015181840152602081019050612518565b50505050905090810190601f1680156125605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a204275726e20416d6f756e74206578636565647320746f74616c537570706c7945524332303a207472616e7366657220616d6f756e7420657863656564732053656e64657273204c6f636b656420416d6f756e7445524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654552433230204e6577204f776e65722063616e6e6f74206265207a65726f206164647265737345524332303a205472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20416c6c6f77616e636520657863656564732062616c616e6365206f6620617070726f76657245524332303a204275726e2066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a204275726e20616d6f756e74206578636565647320746f74616c20737570706c7945524332303a20417070726f76616c20616d6f756e742065786365656473206c6f636b656420616d6f756e742045524332303a204275726e20616d6f756e7420657863656564732062616c616e63652e45524332303a204275726e20616d6f756e742065786365656473206163636f756e7473206c6f636b656420616d6f756e74a265627a7a72315820f687ab0d1d42cd26b2b71510216beb2f8ff20c69f00f28df3fd5a0f854cad79864736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2050, 23499, 22610, 29097, 2629, 2063, 16147, 2575, 19317, 2692, 19841, 2063, 2549, 29292, 29097, 16086, 2692, 2278, 2549, 14728, 2575, 2063, 19317, 2487, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 5651, 1996, 2804, 1997, 2048, 27121, 24028, 1010, 7065, 8743, 2075, 2006, 1008, 2058, 12314, 1012, 1008, 1008, 1011, 2804, 3685, 2058, 12314, 1012, 1008, 1013, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1010, 5164, 3638, 7561, 7834, 3736, 3351, 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, 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,925
0x979a3a210F4323d87a45dc060F53F5a7785B0B9A
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./libraries/math/SafeMath.sol"; import "./libraries/token/IERC20.sol"; import "./interfaces/IX2TimeDistributor.sol"; import "./interfaces/IX2Farm.sol"; contract X2StakeReader { using SafeMath for uint256; uint256 constant PRECISION = 1e30; function getTokenInfo( address _farm, address _stakingToken, address _account ) public view returns (uint256[] memory) { uint256[] memory amounts = new uint256[](4); amounts[0] = IERC20(_farm).totalSupply(); amounts[1] = IERC20(_stakingToken).balanceOf(_account); amounts[2] = IERC20(_farm).balanceOf(_account); amounts[3] = IERC20(_stakingToken).allowance(_account, _farm); return amounts; } function getStakeInfo( address _xlgeFarm, address _uniFarm, address _burnVault, address _timeVault, address _xlgeWeth, address _xvixEth, address _xvix, address _weth, address _account ) public view returns (uint256[] memory) { uint256[] memory amounts = new uint256[](16); amounts[0] = IERC20(_timeVault).balanceOf(_account); amounts[1] = IERC20(_burnVault).balanceOf(_account); amounts[2] = IERC20(_timeVault).totalSupply(); amounts[3] = IERC20(_burnVault).totalSupply(); amounts[4] = IERC20(_xlgeFarm).totalSupply(); amounts[5] = IERC20(_uniFarm).totalSupply(); amounts[6] = IERC20(_xvix).balanceOf(_account); amounts[7] = IERC20(_xlgeWeth).balanceOf(_account); amounts[8] = IERC20(_xlgeFarm).balanceOf(_account); amounts[9] = IERC20(_xlgeWeth).allowance(_account, _xlgeFarm); amounts[10] = IERC20(_xvixEth).balanceOf(_account); amounts[11] = IERC20(_uniFarm).balanceOf(_account); amounts[12] = IERC20(_xvixEth).allowance(_account, _uniFarm); amounts[13] = IERC20(_xvixEth).totalSupply(); amounts[14] = IERC20(_weth).balanceOf(_xvixEth); amounts[15] = IERC20(_xvix).balanceOf(_xvixEth); return amounts; } function getRewards(address _farm, address _account, address _distributor) public view returns (uint256[] memory) { uint256[] memory amounts = new uint256[](2); amounts[0] = IX2TimeDistributor(_distributor).ethPerInterval(_farm); uint256 balance = IERC20(_farm).balanceOf(_account); uint256 supply = IERC20(_farm).totalSupply(); uint256 pendingRewards = IX2TimeDistributor(_distributor).getDistributionAmount(_farm); uint256 cumulativeRewardPerToken = IX2Farm(_farm).cumulativeRewardPerToken(); uint256 claimableReward = IX2Farm(_farm).claimableReward(_account); uint256 previousCumulatedRewardPerToken = IX2Farm(_farm).previousCumulatedRewardPerToken(_account); if (supply > 0) { uint256 rewards = claimableReward.add(pendingRewards.mul(balance).div(supply)); uint256 additionalRewards = balance.mul(cumulativeRewardPerToken.sub(previousCumulatedRewardPerToken)).div(PRECISION); amounts[1] = rewards.add(additionalRewards); } return amounts; } function getRawRewards(address _farm, address _account, address _distributor) public view returns (uint256[] memory) { uint256[] memory amounts = new uint256[](2); amounts[0] = IX2TimeDistributor(_distributor).ethPerInterval(_farm); uint256 balance = IX2Farm(_farm).balances(_account); uint256 supply = IERC20(_farm).totalSupply(); uint256 pendingRewards = IX2TimeDistributor(_distributor).getDistributionAmount(_farm); uint256 cumulativeRewardPerToken = IX2Farm(_farm).cumulativeRewardPerToken(); uint256 claimableReward = IX2Farm(_farm).claimableReward(_account); uint256 previousCumulatedRewardPerToken = IX2Farm(_farm).previousCumulatedRewardPerToken(_account); if (supply > 0) { uint256 rewards = claimableReward.add(pendingRewards.mul(balance).div(supply)); uint256 additionalRewards = balance.mul(cumulativeRewardPerToken.sub(previousCumulatedRewardPerToken)).div(PRECISION); amounts[1] = rewards.add(additionalRewards); } return amounts; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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.12; interface IX2TimeDistributor { function getDistributionAmount(address receiver) external view returns (uint256); function ethPerInterval(address receiver) external view returns (uint256); function lastDistributionTime(address receiver) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IX2Farm { function balances(address account) external view returns (uint256); function cumulativeRewardPerToken() external view returns (uint256); function claimableReward(address account) external view returns (uint256); function previousCumulatedRewardPerToken(address account) external view returns (uint256); }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c8063a2aaf19514610051578063a8f9bc4a146100d9578063b30160c214610111578063f57c82fa14610149575b600080fd5b6100896004803603606081101561006757600080fd5b506001600160a01b0381358116916020810135821691604090910135166101b3565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156100c55781810151838201526020016100ad565b505050509050019250505060405180910390f35b610089600480360360608110156100ef57600080fd5b506001600160a01b0381358116916020810135821691604090910135166105c4565b6100896004803603606081101561012757600080fd5b506001600160a01b0381358116916020810135821691604090910135166106c9565b610089600480360361012081101561016057600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a081013582169160c082013581169160e08101358216916101009091013516610941565b604080516002808252606080830184529283929190602083019080368337019050509050826001600160a01b0316637f7743f5866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561022457600080fd5b505afa158015610238573d6000803e3d6000fd5b505050506040513d602081101561024e57600080fd5b50518151829060009061025d57fe5b6020026020010181815250506000856001600160a01b03166327e235e3866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156102b857600080fd5b505afa1580156102cc573d6000803e3d6000fd5b505050506040513d60208110156102e257600080fd5b5051604080516318160ddd60e01b815290519192506000916001600160a01b038916916318160ddd916004808301926020929190829003018186803b15801561032a57600080fd5b505afa15801561033e573d6000803e3d6000fd5b505050506040513d602081101561035457600080fd5b505160408051635bfdd4fb60e11b81526001600160a01b038a8116600483015291519293506000929188169163b7fba9f691602480820192602092909190829003018186803b1580156103a657600080fd5b505afa1580156103ba573d6000803e3d6000fd5b505050506040513d60208110156103d057600080fd5b505160408051637afe283b60e11b815290519192506000916001600160a01b038b169163f5fc5076916004808301926020929190829003018186803b15801561041857600080fd5b505afa15801561042c573d6000803e3d6000fd5b505050506040513d602081101561044257600080fd5b50516040805163e950342560e01b81526001600160a01b038b811660048301529151929350600092918c169163e950342591602480820192602092909190829003018186803b15801561049457600080fd5b505afa1580156104a8573d6000803e3d6000fd5b505050506040513d60208110156104be57600080fd5b5051604080516344a0841160e01b81526001600160a01b038c811660048301529151929350600092918d16916344a0841191602480820192602092909190829003018186803b15801561051057600080fd5b505afa158015610524573d6000803e3d6000fd5b505050506040513d602081101561053a57600080fd5b5051905084156105b557600061056461055d87610557888b611272565b906112d4565b8490611316565b9050600061058d6c0c9f2c9cd04674edea400000006105576105868887611370565b8b90611272565b90506105998282611316565b896001815181106105a657fe5b60200260200101818152505050505b50949998505050505050505050565b604080516002808252606080830184529283929190602083019080368337019050509050826001600160a01b0316637f7743f5866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561063557600080fd5b505afa158015610649573d6000803e3d6000fd5b505050506040513d602081101561065f57600080fd5b50518151829060009061066e57fe5b6020026020010181815250506000856001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156102b857600080fd5b60408051600480825260a0820190925260609182919060208201608080368337019050509050846001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561072857600080fd5b505afa15801561073c573d6000803e3d6000fd5b505050506040513d602081101561075257600080fd5b50518151829060009061076157fe5b602002602001018181525050836001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156107ba57600080fd5b505afa1580156107ce573d6000803e3d6000fd5b505050506040513d60208110156107e457600080fd5b50518151829060019081106107f557fe5b602002602001018181525050846001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561084e57600080fd5b505afa158015610862573d6000803e3d6000fd5b505050506040513d602081101561087857600080fd5b505181518290600290811061088957fe5b602002602001018181525050836001600160a01b031663dd62ed3e84876040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b1580156108f357600080fd5b505afa158015610907573d6000803e3d6000fd5b505050506040513d602081101561091d57600080fd5b505181518290600390811061092e57fe5b6020908102919091010152949350505050565b60408051601080825261022082019092526060918291906020820161020080368337019050509050876001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d60208110156109e057600080fd5b5051815182906000906109ef57fe5b602002602001018181525050886001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610a4857600080fd5b505afa158015610a5c573d6000803e3d6000fd5b505050506040513d6020811015610a7257600080fd5b5051815182906001908110610a8357fe5b602002602001018181525050876001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ac857600080fd5b505afa158015610adc573d6000803e3d6000fd5b505050506040513d6020811015610af257600080fd5b5051815182906002908110610b0357fe5b602002602001018181525050886001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b4857600080fd5b505afa158015610b5c573d6000803e3d6000fd5b505050506040513d6020811015610b7257600080fd5b5051815182906003908110610b8357fe5b6020026020010181815250508a6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bc857600080fd5b505afa158015610bdc573d6000803e3d6000fd5b505050506040513d6020811015610bf257600080fd5b5051815182906004908110610c0357fe5b602002602001018181525050896001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4857600080fd5b505afa158015610c5c573d6000803e3d6000fd5b505050506040513d6020811015610c7257600080fd5b5051815182906005908110610c8357fe5b602002602001018181525050846001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610cdc57600080fd5b505afa158015610cf0573d6000803e3d6000fd5b505050506040513d6020811015610d0657600080fd5b5051815182906006908110610d1757fe5b602002602001018181525050866001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610d7057600080fd5b505afa158015610d84573d6000803e3d6000fd5b505050506040513d6020811015610d9a57600080fd5b5051815182906007908110610dab57fe5b6020026020010181815250508a6001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610e0457600080fd5b505afa158015610e18573d6000803e3d6000fd5b505050506040513d6020811015610e2e57600080fd5b5051815182906008908110610e3f57fe5b602002602001018181525050866001600160a01b031663dd62ed3e848d6040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015610ea957600080fd5b505afa158015610ebd573d6000803e3d6000fd5b505050506040513d6020811015610ed357600080fd5b5051815182906009908110610ee457fe5b602002602001018181525050856001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610f3d57600080fd5b505afa158015610f51573d6000803e3d6000fd5b505050506040513d6020811015610f6757600080fd5b505181518290600a908110610f7857fe5b602002602001018181525050896001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610fd157600080fd5b505afa158015610fe5573d6000803e3d6000fd5b505050506040513d6020811015610ffb57600080fd5b505181518290600b90811061100c57fe5b602002602001018181525050856001600160a01b031663dd62ed3e848c6040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b15801561107657600080fd5b505afa15801561108a573d6000803e3d6000fd5b505050506040513d60208110156110a057600080fd5b505181518290600c9081106110b157fe5b602002602001018181525050856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110f657600080fd5b505afa15801561110a573d6000803e3d6000fd5b505050506040513d602081101561112057600080fd5b505181518290600d90811061113157fe5b602002602001018181525050836001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561118a57600080fd5b505afa15801561119e573d6000803e3d6000fd5b505050506040513d60208110156111b457600080fd5b505181518290600e9081106111c557fe5b602002602001018181525050846001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561121e57600080fd5b505afa158015611232573d6000803e3d6000fd5b505050506040513d602081101561124857600080fd5b505181518290600f90811061125957fe5b60209081029190910101529a9950505050505050505050565b600082611281575060006112ce565b8282028284828161128e57fe5b04146112cb5760405162461bcd60e51b81526004018080602001828103825260218152602001806114af6021913960400191505060405180910390fd5b90505b92915050565b60006112cb83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506113b2565b6000828201838110156112cb576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006112cb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611454565b6000818361143e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114035781810151838201526020016113eb565b50505050905090810190601f1680156114305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161144a57fe5b0495945050505050565b600081848411156114a65760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156114035781810151838201526020016113eb565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122089c51fa248f4b8c343c5f16dcc264ad3b2811d122fc4de88a5b4e14d468b21f464736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2050, 2509, 2050, 17465, 2692, 2546, 23777, 21926, 2094, 2620, 2581, 2050, 19961, 16409, 2692, 16086, 2546, 22275, 2546, 2629, 2050, 2581, 2581, 27531, 2497, 2692, 2497, 2683, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 12324, 1000, 1012, 1013, 8860, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 8860, 1013, 19204, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 11814, 2475, 7292, 10521, 18886, 8569, 4263, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 11814, 2475, 14971, 2213, 1012, 14017, 1000, 1025, 3206, 1060, 2475, 9153, 5484, 13775, 2121, 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,926
0x979A5902baa728034Ff342172Eda64FCe416d0a4
/* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { FlexibleLeverageStrategyExtension } from "../adapters/FlexibleLeverageStrategyExtension.sol"; import { IFLIStrategyExtension } from "../interfaces/IFLIStrategyExtension.sol"; import { IQuoter } from "../interfaces/IQuoter.sol"; import { IUniswapV2Router } from "../interfaces/IUniswapV2Router.sol"; import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol"; import { StringArrayUtils } from "../lib/StringArrayUtils.sol"; /** * @title FLIRebalanceViewer * @author Set Protocol * * Viewer contract for FlexibleLeverageStrategyExtension. Used by keeper bots to determine which exchanges to use when rebalancing. * This contract can only determine whether to use Uniswap V3 or Uniswap V2 (or forks) for rebalancing. Since AMMTradeSplitter adheres to * the Uniswap V2 router interface, this contract is compatible with that as well. */ contract FLIRebalanceViewer { using PreciseUnitMath for uint256; using SafeMath for uint256; using StringArrayUtils for string[]; /* ============ Structs ============ */ struct ActionInfo { string[] exchangeNames; // List of enabled exchange names FlexibleLeverageStrategyExtension.ShouldRebalance[] rebalanceActions; // List of rebalance actions with respect to exchangeNames uint256 uniV3Index; // Index of Uni V3 in both lists uint256 uniV2Index; // Index of Uni V2 in both lists uint256 minLeverage; // Minimum leverage ratio of strategy uint256 maxLeverage; // Maximum leverage ratio of strategy uint256[] chunkSendQuantity; // Size of rebalances (quoted in sell asset units) address sellAsset; // Address of asset to sell during rebalance address buyAsset; // Address of asset to buy during rebalance bool isLever; // Whether the rebalance is a lever or delever } /* ============ State Variables ============ */ IFLIStrategyExtension public fliStrategyExtension; IQuoter public uniswapV3Quoter; IUniswapV2Router public uniswapV2Router; string public uniswapV3ExchangeName; string public uniswapV2ExchangeName; /* ============ Constructor ============ */ /** * Sets state variables * * @param _fliStrategyExtension FlexibleLeverageStrategyAdapter contract address * @param _uniswapV3Quoter Uniswap V3 Quoter contract address * @param _uniswapV2Router Uniswap v2 Router contract address * @param _uniswapV3ExchangeName Name of Uniswap V3 exchange in Set's IntegrationRegistry (ex: UniswapV3ExchangeAdapter) * @param _uniswapV2ExchangeName Name of Uniswap V2 exchange in Set's IntegrationRegistry (ex: AMMSplitterExchangeAdapter) */ constructor( IFLIStrategyExtension _fliStrategyExtension, IQuoter _uniswapV3Quoter, IUniswapV2Router _uniswapV2Router, string memory _uniswapV3ExchangeName, string memory _uniswapV2ExchangeName ) public { fliStrategyExtension = _fliStrategyExtension; uniswapV3Quoter = _uniswapV3Quoter; uniswapV2Router = _uniswapV2Router; uniswapV3ExchangeName = _uniswapV3ExchangeName; uniswapV2ExchangeName = _uniswapV2ExchangeName; } /* =========== External Functions ============ */ /** * Gets the priority order for which exchange should be used while rebalancing. Mimics the interface for * shouldRebalanceWithBound of FlexibleLeverageStrategyExtension. Note: this function is not marked as view * due to a quirk in the Uniswap V3 Quoter contract, but should be static called to save gas * * @param _minLeverageRatio Min leverage ratio * @param _maxLeverageRatio Max leverage ratio * * @return string[] memory Ordered array of exchange names to use. Earlier elements in the array produce the best trades * @return ShouldRebalance[] memory Array of ShouldRebalance Enums. Ordered relative to returned exchange names array */ function shouldRebalanceWithBounds( uint256 _minLeverageRatio, uint256 _maxLeverageRatio ) external returns(string[2] memory, FlexibleLeverageStrategyExtension.ShouldRebalance[2] memory) { ActionInfo memory actionInfo = _getActionInfo(_minLeverageRatio, _maxLeverageRatio); (uint256 uniswapV3Price, uint256 uniswapV2Price) = _getPrices(actionInfo); return _getExchangePriority( uniswapV3Price, uniswapV2Price, actionInfo ); } /* ================= Internal Functions ================= */ /** * Fetches prices for rebalancing trades on Uniswap V3 and Uniswap V2. Trade sizes are determined by FlexibleLeverageStrategyExtension's * getChunkRebalanceNotional. * * @param _actionInfo ActionInfo struct * * @return uniswapV3Price price of rebalancing trade on Uniswap V3 (scaled by trade size) * @return uniswapV2Price price of rebalancing trade on Uniswap V2 (scaled by trade size) */ function _getPrices(ActionInfo memory _actionInfo) internal returns (uint256 uniswapV3Price, uint256 uniswapV2Price) { uniswapV3Price = _getV3Price(_actionInfo.chunkSendQuantity[_actionInfo.uniV3Index], _actionInfo.isLever); uniswapV2Price = _getV2Price( _actionInfo.chunkSendQuantity[_actionInfo.uniV2Index], _actionInfo.isLever, _actionInfo.sellAsset, _actionInfo.buyAsset ); } /** * Fetches price of a Uniswap V3 trade. Uniswap V3 fetches quotes using a write function that always reverts. This means that * this function cannot be view only. Additionally, the Uniswap V3 quoting function cannot be static called in solidity due to the * internal revert. To save on gas, static call the top level shouldRebalanceWithBounds function when interacting with this contact * * @param _sellSize quantity of asset to sell * @param _isLever whether FLI needs to lever or delever * * @return uint256 price of trade on Uniswap V3 */ function _getV3Price(uint256 _sellSize, bool _isLever) internal returns (uint256) { bytes memory uniswapV3TradePath = _isLever ? fliStrategyExtension.getExchangeSettings(uniswapV3ExchangeName).leverExchangeData : fliStrategyExtension.getExchangeSettings(uniswapV3ExchangeName).deleverExchangeData; uint256 outputAmount = uniswapV3Quoter.quoteExactInput(uniswapV3TradePath, _sellSize); // Divide to get ratio of quote / base asset. Don't care about decimals here. Standardizes to 10e18 with preciseDiv return outputAmount.preciseDiv(_sellSize); } /** * Fetches price of a Uniswap V2 trade * * @param _sellSize quantity of asset to sell * @param _isLever whether FLI needs to lever or delever * * @return uint256 price of trade on Uniswap V2 */ function _getV2Price(uint256 _sellSize, bool _isLever, address _sellAsset, address _buyAsset) internal view returns (uint256) { bytes memory uniswapV2TradePathRaw = _isLever ? fliStrategyExtension.getExchangeSettings(uniswapV2ExchangeName).leverExchangeData : fliStrategyExtension.getExchangeSettings(uniswapV2ExchangeName).deleverExchangeData; address[] memory uniswapV2TradePath; if (uniswapV2TradePathRaw.length == 0) { uniswapV2TradePath = new address[](2); uniswapV2TradePath[0] = _sellAsset; uniswapV2TradePath[1] = _buyAsset; } else { uniswapV2TradePath = abi.decode(uniswapV2TradePathRaw, (address[])); } uint256 outputAmount = uniswapV2Router.getAmountsOut(_sellSize, uniswapV2TradePath)[uniswapV2TradePath.length.sub(1)]; // Divide to get ratio of quote / base asset. Don't care about decimals here. Standardizes to 10e18 with preciseDiv return outputAmount.preciseDiv(_sellSize); } /** * Gets the ordered priority of which exchanges to use for a rebalance * * @param _uniswapV3Price price of rebalance trade on Uniswap V3 * @param _uniswapV2Price price of rebalance trade on Uniswap V2 * @param _actionInfo ActionInfo struct * * @return string[] memory Ordered array of exchange names to use. Earlier elements in the array produce the best trades * @return ShouldRebalance[] memory Array of ShouldRebalance Enums. Ordered relative to returned exchange names array */ function _getExchangePriority( uint256 _uniswapV3Price, uint256 _uniswapV2Price, ActionInfo memory _actionInfo ) internal view returns (string[2] memory, FlexibleLeverageStrategyExtension.ShouldRebalance[2] memory) { // If no rebalance is required, set price to 0 so it is ordered last if (_actionInfo.rebalanceActions[_actionInfo.uniV3Index] == FlexibleLeverageStrategyExtension.ShouldRebalance.NONE) _uniswapV3Price = 0; if (_actionInfo.rebalanceActions[_actionInfo.uniV2Index] == FlexibleLeverageStrategyExtension.ShouldRebalance.NONE) _uniswapV2Price = 0; if (_uniswapV3Price > _uniswapV2Price) { return ([ uniswapV3ExchangeName, uniswapV2ExchangeName ], [ _actionInfo.rebalanceActions[_actionInfo.uniV3Index], _actionInfo.rebalanceActions[_actionInfo.uniV2Index] ]); } else { return ([ uniswapV2ExchangeName, uniswapV3ExchangeName ], [ _actionInfo.rebalanceActions[_actionInfo.uniV2Index], _actionInfo.rebalanceActions[_actionInfo.uniV3Index] ]); } } /** * Creates the an ActionInfo struct containing information about the rebalancing action * * @param _minLeverage Min leverage ratio * @param _maxLeverage Max leverage ratio * * @return actionInfo Populated ActionInfo struct */ function _getActionInfo(uint256 _minLeverage, uint256 _maxLeverage) internal view returns (ActionInfo memory actionInfo) { (actionInfo.exchangeNames, actionInfo.rebalanceActions) = fliStrategyExtension.shouldRebalanceWithBounds( _minLeverage, _maxLeverage ); (actionInfo.uniV3Index, ) = actionInfo.exchangeNames.indexOf(uniswapV3ExchangeName); (actionInfo.uniV2Index, ) = actionInfo.exchangeNames.indexOf(uniswapV2ExchangeName); actionInfo.minLeverage = _minLeverage; actionInfo.maxLeverage = _maxLeverage; (actionInfo.chunkSendQuantity, actionInfo.sellAsset, actionInfo.buyAsset) = fliStrategyExtension.getChunkRebalanceNotional( actionInfo.exchangeNames ); actionInfo.isLever = actionInfo.sellAsset == fliStrategyExtension.getStrategy().borrowAsset; } } // 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, 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; } } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { Math } from "@openzeppelin/contracts/math/Math.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol"; import { BaseAdapter } from "../lib/BaseAdapter.sol"; import { ICErc20 } from "../interfaces/ICErc20.sol"; import { IBaseManager } from "../interfaces/IBaseManager.sol"; import { IChainlinkAggregatorV3 } from "../interfaces/IChainlinkAggregatorV3.sol"; import { IComptroller } from "../interfaces/IComptroller.sol"; import { ICompoundLeverageModule } from "../interfaces/ICompoundLeverageModule.sol"; import { ICompoundPriceOracle } from "../interfaces/ICompoundPriceOracle.sol"; import { ISetToken } from "../interfaces/ISetToken.sol"; import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol"; import { StringArrayUtils } from "../lib/StringArrayUtils.sol"; /** * @title FlexibleLeverageStrategyExtension * @author Set Protocol * * Smart contract that enables trustless leverage tokens using the flexible leverage methodology. This extension is paired with the CompoundLeverageModule from Set * protocol where module interactions are invoked via the IBaseManager contract. Any leveraged token can be constructed as long as the collateral and borrow * asset is available on Compound. This extension contract also allows the operator to set an ETH reward to incentivize keepers calling the rebalance function at * different leverage thresholds. * * CHANGELOG 4/14/2021: * - Update ExecutionSettings struct to split exchangeData into leverExchangeData and deleverExchangeData * - Update _lever and _delever internal functions with struct changes * - Update setExecutionSettings to account for leverExchangeData and deleverExchangeData * * CHANGELOG 5/24/2021: * - Update _calculateActionInfo to add chainlink prices * - Update _calculateBorrowUnits and _calculateMinRepayUnits to use chainlink as an oracle in * * CHANGELOG 6/29/2021: c55bd3cdb0fd43c03da9904493dcc23771ef0f71 * - Add ExchangeSettings struct that contains exchange specific information * - Update ExecutionSettings struct to not include exchange information * - Add mapping of exchange names to ExchangeSettings structs and a list of enabled exchange names * - Update constructor to take an array of exchange names and an array of ExchangeSettings * - Add _exchangeName parameter to rebalancing functions to select which exchange to use * - Add permissioned addEnabledExchange, updateEnabledExchange, and removeEnabledExchange functions * - Add getChunkRebalanceNotional function * - Update shouldRebalance and shouldRebalanceWithBounds to return an array of ShouldRebalance enums and an array of exchange names * - Update _shouldRebalance to use exchange specific last trade timestamps * - Update _validateRipcord and _validateNormalRebalance to take in a timestamp parameter (so we can pass either global or exchange specific timestamp) * - Add _updateLastTradeTimestamp function to update global and exchange specific timestamp * - Change contract name to FlexibleLeverageStrategyExtension */ contract FlexibleLeverageStrategyExtension is BaseAdapter { using Address for address; using PreciseUnitMath for uint256; using SafeMath for uint256; using SafeCast for int256; using StringArrayUtils for string[]; /* ============ Enums ============ */ enum ShouldRebalance { NONE, // Indicates no rebalance action can be taken REBALANCE, // Indicates rebalance() function can be successfully called ITERATE_REBALANCE, // Indicates iterateRebalance() function can be successfully called RIPCORD // Indicates ripcord() function can be successfully called } /* ============ Structs ============ */ struct ActionInfo { uint256 collateralBalance; // Balance of underlying held in Compound in base units (e.g. USDC 10e6) uint256 borrowBalance; // Balance of underlying borrowed from Compound in base units uint256 collateralValue; // Valuation in USD adjusted for decimals in precise units (10e18) uint256 borrowValue; // Valuation in USD adjusted for decimals in precise units (10e18) uint256 collateralPrice; // Price of collateral in precise units (10e18) from Chainlink uint256 borrowPrice; // Price of borrow asset in precise units (10e18) from Chainlink uint256 setTotalSupply; // Total supply of SetToken } struct LeverageInfo { ActionInfo action; uint256 currentLeverageRatio; // Current leverage ratio of Set uint256 slippageTolerance; // Allowable percent trade slippage in preciseUnits (1% = 10^16) uint256 twapMaxTradeSize; // Max trade size in collateral units allowed for rebalance action string exchangeName; // Exchange to use for trade } struct ContractSettings { ISetToken setToken; // Instance of leverage token ICompoundLeverageModule leverageModule; // Instance of Compound leverage module IComptroller comptroller; // Instance of Compound Comptroller IChainlinkAggregatorV3 collateralPriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for collateral asset IChainlinkAggregatorV3 borrowPriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for borrow asset ICErc20 targetCollateralCToken; // Instance of target collateral cToken asset ICErc20 targetBorrowCToken; // Instance of target borrow cToken asset address collateralAsset; // Address of underlying collateral address borrowAsset; // Address of underlying borrow asset uint256 collateralDecimalAdjustment; // Decimal adjustment for chainlink oracle of the collateral asset. Equal to 28-collateralDecimals (10^18 * 10^18 / 10^decimals / 10^8) uint256 borrowDecimalAdjustment; // Decimal adjustment for chainlink oracle of the borrowing asset. Equal to 28-borrowDecimals (10^18 * 10^18 / 10^decimals / 10^8) } struct MethodologySettings { uint256 targetLeverageRatio; // Long term target ratio in precise units (10e18) uint256 minLeverageRatio; // In precise units (10e18). If current leverage is below, rebalance target is this ratio uint256 maxLeverageRatio; // In precise units (10e18). If current leverage is above, rebalance target is this ratio uint256 recenteringSpeed; // % at which to rebalance back to target leverage in precise units (10e18) uint256 rebalanceInterval; // Period of time required since last rebalance timestamp in seconds } struct ExecutionSettings { uint256 unutilizedLeveragePercentage; // Percent of max borrow left unutilized in precise units (1% = 10e16) uint256 slippageTolerance; // % in precise units to price min token receive amount from trade quantities uint256 twapCooldownPeriod; // Cooldown period required since last trade timestamp in seconds } struct ExchangeSettings { uint256 twapMaxTradeSize; // Max trade size in collateral base units uint256 exchangeLastTradeTimestamp; // Timestamp of last trade made with this exchange uint256 incentivizedTwapMaxTradeSize; // Max trade size for incentivized rebalances in collateral base units bytes leverExchangeData; // Arbitrary exchange data passed into rebalance function for levering up bytes deleverExchangeData; // Arbitrary exchange data passed into rebalance function for delevering } struct IncentiveSettings { uint256 etherReward; // ETH reward for incentivized rebalances uint256 incentivizedLeverageRatio; // Leverage ratio for incentivized rebalances uint256 incentivizedSlippageTolerance; // Slippage tolerance percentage for incentivized rebalances uint256 incentivizedTwapCooldownPeriod; // TWAP cooldown in seconds for incentivized rebalances } /* ============ Events ============ */ event Engaged(uint256 _currentLeverageRatio, uint256 _newLeverageRatio, uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional); event Rebalanced( uint256 _currentLeverageRatio, uint256 _newLeverageRatio, uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional ); event RebalanceIterated( uint256 _currentLeverageRatio, uint256 _newLeverageRatio, uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional ); event RipcordCalled( uint256 _currentLeverageRatio, uint256 _newLeverageRatio, uint256 _rebalanceNotional, uint256 _etherIncentive ); event Disengaged(uint256 _currentLeverageRatio, uint256 _newLeverageRatio, uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional); event MethodologySettingsUpdated( uint256 _targetLeverageRatio, uint256 _minLeverageRatio, uint256 _maxLeverageRatio, uint256 _recenteringSpeed, uint256 _rebalanceInterval ); event ExecutionSettingsUpdated( uint256 _unutilizedLeveragePercentage, uint256 _twapCooldownPeriod, uint256 _slippageTolerance ); event IncentiveSettingsUpdated( uint256 _etherReward, uint256 _incentivizedLeverageRatio, uint256 _incentivizedSlippageTolerance, uint256 _incentivizedTwapCooldownPeriod ); event ExchangeUpdated( string _exchangeName, uint256 twapMaxTradeSize, uint256 exchangeLastTradeTimestamp, uint256 incentivizedTwapMaxTradeSize, bytes leverExchangeData, bytes deleverExchangeData ); event ExchangeAdded( string _exchangeName, uint256 twapMaxTradeSize, uint256 exchangeLastTradeTimestamp, uint256 incentivizedTwapMaxTradeSize, bytes leverExchangeData, bytes deleverExchangeData ); event ExchangeRemoved( string _exchangeName ); /* ============ Modifiers ============ */ /** * Throws if rebalance is currently in TWAP` */ modifier noRebalanceInProgress() { require(twapLeverageRatio == 0, "Rebalance is currently in progress"); _; } /* ============ State Variables ============ */ ContractSettings internal strategy; // Struct of contracts used in the strategy (SetToken, price oracles, leverage module etc) MethodologySettings internal methodology; // Struct containing methodology parameters ExecutionSettings internal execution; // Struct containing execution parameters mapping(string => ExchangeSettings) internal exchangeSettings; // Mapping from exchange name to exchange settings IncentiveSettings internal incentive; // Struct containing incentive parameters for ripcord string[] public enabledExchanges; // Array containing enabled exchanges uint256 public twapLeverageRatio; // Stored leverage ratio to keep track of target between TWAP rebalances uint256 public globalLastTradeTimestamp; // Last rebalance timestamp. Current timestamp must be greater than this variable + rebalance interval to rebalance /* ============ Constructor ============ */ /** * Instantiate addresses, methodology parameters, execution parameters, and incentive parameters. * * @param _manager Address of IBaseManager contract * @param _strategy Struct of contract addresses * @param _methodology Struct containing methodology parameters * @param _execution Struct containing execution parameters * @param _incentive Struct containing incentive parameters for ripcord * @param _exchangeNames List of initial exchange names * @param _exchangeSettings List of structs containing exchange parameters for the initial exchanges */ constructor( IBaseManager _manager, ContractSettings memory _strategy, MethodologySettings memory _methodology, ExecutionSettings memory _execution, IncentiveSettings memory _incentive, string[] memory _exchangeNames, ExchangeSettings[] memory _exchangeSettings ) public BaseAdapter(_manager) { strategy = _strategy; methodology = _methodology; execution = _execution; incentive = _incentive; for (uint256 i = 0; i < _exchangeNames.length; i++) { _validateExchangeSettings(_exchangeSettings[i]); exchangeSettings[_exchangeNames[i]] = _exchangeSettings[i]; enabledExchanges.push(_exchangeNames[i]); } _validateNonExchangeSettings(methodology, execution, incentive); } /* ============ External Functions ============ */ /** * OPERATOR ONLY: Engage to target leverage ratio for the first time. SetToken will borrow debt position from Compound and trade for collateral asset. If target * leverage ratio is above max borrow or max trade size, then TWAP is kicked off. To complete engage if TWAP, any valid caller must call iterateRebalance until target * is met. * * @param _exchangeName the exchange used for trading */ function engage(string memory _exchangeName) external onlyOperator { ActionInfo memory engageInfo = _createActionInfo(); require(engageInfo.setTotalSupply > 0, "SetToken must have > 0 supply"); require(engageInfo.collateralBalance > 0, "Collateral balance must be > 0"); require(engageInfo.borrowBalance == 0, "Debt must be 0"); LeverageInfo memory leverageInfo = LeverageInfo({ action: engageInfo, currentLeverageRatio: PreciseUnitMath.preciseUnit(), // 1x leverage in precise units slippageTolerance: execution.slippageTolerance, twapMaxTradeSize: exchangeSettings[_exchangeName].twapMaxTradeSize, exchangeName: _exchangeName }); // Calculate total rebalance units and kick off TWAP if above max borrow or max trade size ( uint256 chunkRebalanceNotional, uint256 totalRebalanceNotional ) = _calculateChunkRebalanceNotional(leverageInfo, methodology.targetLeverageRatio, true); _lever(leverageInfo, chunkRebalanceNotional); _updateRebalanceState( chunkRebalanceNotional, totalRebalanceNotional, methodology.targetLeverageRatio, _exchangeName ); emit Engaged( leverageInfo.currentLeverageRatio, methodology.targetLeverageRatio, chunkRebalanceNotional, totalRebalanceNotional ); } /** * ONLY EOA AND ALLOWED CALLER: Rebalance according to flexible leverage methodology. If current leverage ratio is between the max and min bounds, then rebalance * can only be called once the rebalance interval has elapsed since last timestamp. If outside the max and min, rebalance can be called anytime to bring leverage * ratio back to the max or min bounds. The methodology will determine whether to delever or lever. * * Note: If the calculated current leverage ratio is above the incentivized leverage ratio or in TWAP then rebalance cannot be called. Instead, you must call * ripcord() which is incentivized with a reward in Ether or iterateRebalance(). * * @param _exchangeName the exchange used for trading */ function rebalance(string memory _exchangeName) external onlyEOA onlyAllowedCaller(msg.sender) { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( execution.slippageTolerance, exchangeSettings[_exchangeName].twapMaxTradeSize, _exchangeName ); // use globalLastTradeTimestamps to prevent multiple rebalances being called with different exchanges during the epoch rebalance _validateNormalRebalance(leverageInfo, methodology.rebalanceInterval, globalLastTradeTimestamp); _validateNonTWAP(); uint256 newLeverageRatio = _calculateNewLeverageRatio(leverageInfo.currentLeverageRatio); ( uint256 chunkRebalanceNotional, uint256 totalRebalanceNotional ) = _handleRebalance(leverageInfo, newLeverageRatio); _updateRebalanceState(chunkRebalanceNotional, totalRebalanceNotional, newLeverageRatio, _exchangeName); emit Rebalanced( leverageInfo.currentLeverageRatio, newLeverageRatio, chunkRebalanceNotional, totalRebalanceNotional ); } /** * ONLY EOA AND ALLOWED CALLER: Iterate a rebalance when in TWAP. TWAP cooldown period must have elapsed. If price moves advantageously, then exit without rebalancing * and clear TWAP state. This function can only be called when below incentivized leverage ratio and in TWAP state. * * @param _exchangeName the exchange used for trading */ function iterateRebalance(string memory _exchangeName) external onlyEOA onlyAllowedCaller(msg.sender) { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( execution.slippageTolerance, exchangeSettings[_exchangeName].twapMaxTradeSize, _exchangeName ); // Use the exchangeLastTradeTimestamp since cooldown periods are measured on a per-exchange basis, allowing it to rebalance multiple time in quick // succession with different exchanges _validateNormalRebalance(leverageInfo, execution.twapCooldownPeriod, exchangeSettings[_exchangeName].exchangeLastTradeTimestamp); _validateTWAP(); uint256 chunkRebalanceNotional; uint256 totalRebalanceNotional; if (!_isAdvantageousTWAP(leverageInfo.currentLeverageRatio)) { (chunkRebalanceNotional, totalRebalanceNotional) = _handleRebalance(leverageInfo, twapLeverageRatio); } // If not advantageous, then rebalance is skipped and chunk and total rebalance notional are both 0, which means TWAP state is // cleared _updateIterateState(chunkRebalanceNotional, totalRebalanceNotional, _exchangeName); emit RebalanceIterated( leverageInfo.currentLeverageRatio, twapLeverageRatio, chunkRebalanceNotional, totalRebalanceNotional ); } /** * ONLY EOA: In case the current leverage ratio exceeds the incentivized leverage threshold, the ripcord function can be called by anyone to return leverage ratio * back to the max leverage ratio. This function typically would only be called during times of high downside volatility and / or normal keeper malfunctions. The caller * of ripcord() will receive a reward in Ether. The ripcord function uses it's own TWAP cooldown period, slippage tolerance and TWAP max trade size which are typically * looser than in regular rebalances. * * @param _exchangeName the exchange used for trading */ function ripcord(string memory _exchangeName) external onlyEOA { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( incentive.incentivizedSlippageTolerance, exchangeSettings[_exchangeName].incentivizedTwapMaxTradeSize, _exchangeName ); // Use the exchangeLastTradeTimestamp so it can ripcord quickly with multiple exchanges _validateRipcord(leverageInfo, exchangeSettings[_exchangeName].exchangeLastTradeTimestamp); ( uint256 chunkRebalanceNotional, ) = _calculateChunkRebalanceNotional(leverageInfo, methodology.maxLeverageRatio, false); _delever(leverageInfo, chunkRebalanceNotional); _updateRipcordState(_exchangeName); uint256 etherTransferred = _transferEtherRewardToCaller(incentive.etherReward); emit RipcordCalled( leverageInfo.currentLeverageRatio, methodology.maxLeverageRatio, chunkRebalanceNotional, etherTransferred ); } /** * OPERATOR ONLY: Return leverage ratio to 1x and delever to repay loan. This can be used for upgrading or shutting down the strategy. SetToken will redeem * collateral position and trade for debt position to repay Compound. If the chunk rebalance size is less than the total notional size, then this function will * delever and repay entire borrow balance on Compound. If chunk rebalance size is above max borrow or max trade size, then operator must * continue to call this function to complete repayment of loan. The function iterateRebalance will not work. * * Note: Delever to 0 will likely result in additional units of the borrow asset added as equity on the SetToken due to oracle price / market price mismatch * * @param _exchangeName the exchange used for trading */ function disengage(string memory _exchangeName) external onlyOperator { LeverageInfo memory leverageInfo = _getAndValidateLeveragedInfo( execution.slippageTolerance, exchangeSettings[_exchangeName].twapMaxTradeSize, _exchangeName ); uint256 newLeverageRatio = PreciseUnitMath.preciseUnit(); ( uint256 chunkRebalanceNotional, uint256 totalRebalanceNotional ) = _calculateChunkRebalanceNotional(leverageInfo, newLeverageRatio, false); if (totalRebalanceNotional > chunkRebalanceNotional) { _delever(leverageInfo, chunkRebalanceNotional); } else { _deleverToZeroBorrowBalance(leverageInfo, totalRebalanceNotional); } emit Disengaged( leverageInfo.currentLeverageRatio, newLeverageRatio, chunkRebalanceNotional, totalRebalanceNotional ); } /** * OPERATOR ONLY: Set methodology settings and check new settings are valid. Note: Need to pass in existing parameters if only changing a few settings. Must not be * in a rebalance. * * @param _newMethodologySettings Struct containing methodology parameters */ function setMethodologySettings(MethodologySettings memory _newMethodologySettings) external onlyOperator noRebalanceInProgress { methodology = _newMethodologySettings; _validateNonExchangeSettings(methodology, execution, incentive); emit MethodologySettingsUpdated( methodology.targetLeverageRatio, methodology.minLeverageRatio, methodology.maxLeverageRatio, methodology.recenteringSpeed, methodology.rebalanceInterval ); } /** * OPERATOR ONLY: Set execution settings and check new settings are valid. Note: Need to pass in existing parameters if only changing a few settings. Must not be * in a rebalance. * * @param _newExecutionSettings Struct containing execution parameters */ function setExecutionSettings(ExecutionSettings memory _newExecutionSettings) external onlyOperator noRebalanceInProgress { execution = _newExecutionSettings; _validateNonExchangeSettings(methodology, execution, incentive); emit ExecutionSettingsUpdated( execution.unutilizedLeveragePercentage, execution.twapCooldownPeriod, execution.slippageTolerance ); } /** * OPERATOR ONLY: Set incentive settings and check new settings are valid. Note: Need to pass in existing parameters if only changing a few settings. Must not be * in a rebalance. * * @param _newIncentiveSettings Struct containing incentive parameters */ function setIncentiveSettings(IncentiveSettings memory _newIncentiveSettings) external onlyOperator noRebalanceInProgress { incentive = _newIncentiveSettings; _validateNonExchangeSettings(methodology, execution, incentive); emit IncentiveSettingsUpdated( incentive.etherReward, incentive.incentivizedLeverageRatio, incentive.incentivizedSlippageTolerance, incentive.incentivizedTwapCooldownPeriod ); } /** * OPERATOR ONLY: Add a new enabled exchange for trading during rebalances. New exchanges will have their exchangeLastTradeTimestamp set to 0. Adding * exchanges during rebalances is allowed, as it is not possible to enter an unexpected state while doing so. * * @param _exchangeName Name of the exchange * @param _exchangeSettings Struct containing exchange parameters */ function addEnabledExchange( string memory _exchangeName, ExchangeSettings memory _exchangeSettings ) external onlyOperator { require(exchangeSettings[_exchangeName].twapMaxTradeSize == 0, "Exchange already enabled"); _validateExchangeSettings(_exchangeSettings); exchangeSettings[_exchangeName].twapMaxTradeSize = _exchangeSettings.twapMaxTradeSize; exchangeSettings[_exchangeName].incentivizedTwapMaxTradeSize = _exchangeSettings.incentivizedTwapMaxTradeSize; exchangeSettings[_exchangeName].leverExchangeData = _exchangeSettings.leverExchangeData; exchangeSettings[_exchangeName].deleverExchangeData = _exchangeSettings.deleverExchangeData; exchangeSettings[_exchangeName].exchangeLastTradeTimestamp = 0; enabledExchanges.push(_exchangeName); emit ExchangeAdded( _exchangeName, _exchangeSettings.twapMaxTradeSize, _exchangeSettings.exchangeLastTradeTimestamp, _exchangeSettings.incentivizedTwapMaxTradeSize, _exchangeSettings.leverExchangeData, _exchangeSettings.deleverExchangeData ); } /** * OPERATOR ONLY: Removes an exchange. Reverts if the exchange is not already enabled. Removing exchanges during rebalances is allowed, * as it is not possible to enter an unexpected state while doing so. * * @param _exchangeName Name of exchange to remove */ function removeEnabledExchange(string memory _exchangeName) external onlyOperator { require(exchangeSettings[_exchangeName].twapMaxTradeSize != 0, "Exchange not enabled"); delete exchangeSettings[_exchangeName]; enabledExchanges.removeStorage(_exchangeName); emit ExchangeRemoved(_exchangeName); } /** * OPERATOR ONLY: Updates the settings of an exchange. Reverts if exchange is not already added. When updating an exchange, exchangeLastTradeTimestamp * is preserved. Updating exchanges during rebalances is allowed, as it is not possible to enter an unexpected state while doing so. Note: Need to * pass in all existing parameters even if only changing a few settings. * * @param _exchangeName Name of the exchange * @param _exchangeSettings Struct containing exchange parameters */ function updateEnabledExchange( string memory _exchangeName, ExchangeSettings memory _exchangeSettings ) external onlyOperator { require(exchangeSettings[_exchangeName].twapMaxTradeSize != 0, "Exchange not enabled"); _validateExchangeSettings(_exchangeSettings); exchangeSettings[_exchangeName].twapMaxTradeSize = _exchangeSettings.twapMaxTradeSize; exchangeSettings[_exchangeName].incentivizedTwapMaxTradeSize = _exchangeSettings.incentivizedTwapMaxTradeSize; exchangeSettings[_exchangeName].leverExchangeData = _exchangeSettings.leverExchangeData; exchangeSettings[_exchangeName].deleverExchangeData = _exchangeSettings.deleverExchangeData; emit ExchangeUpdated( _exchangeName, _exchangeSettings.twapMaxTradeSize, _exchangeSettings.exchangeLastTradeTimestamp, _exchangeSettings.incentivizedTwapMaxTradeSize, _exchangeSettings.leverExchangeData, _exchangeSettings.deleverExchangeData ); } /** * OPERATOR ONLY: Withdraw entire balance of ETH in this contract to operator. Rebalance must not be in progress */ function withdrawEtherBalance() external onlyOperator noRebalanceInProgress { msg.sender.transfer(address(this).balance); } receive() external payable {} /* ============ External Getter Functions ============ */ /** * Get current leverage ratio. Current leverage ratio is defined as the USD value of the collateral divided by the USD value of the SetToken. Prices for collateral * and borrow asset are retrieved from the Compound Price Oracle. * * return currentLeverageRatio Current leverage ratio in precise units (10e18) */ function getCurrentLeverageRatio() public view returns(uint256) { ActionInfo memory currentLeverageInfo = _createActionInfo(); return _calculateCurrentLeverageRatio(currentLeverageInfo.collateralValue, currentLeverageInfo.borrowValue); } /** * Calculates the chunk rebalance size. This can be used by external contracts and keeper bots to calculate the optimal exchange to rebalance with. * Note: this function does not take into account timestamps, so it may return a nonzero value even when shouldRebalance would return ShouldRebalance.NONE for * all exchanges (since minimum delays have not elapsed) * * @param _exchangeNames Array of exchange names to get rebalance sizes for * * @return sizes Array of total notional chunk size. Measured in the asset that would be sold * @return sellAsset Asset that would be sold during a rebalance * @return buyAsset Asset that would be purchased during a rebalance */ function getChunkRebalanceNotional( string[] calldata _exchangeNames ) external view returns(uint256[] memory sizes, address sellAsset, address buyAsset) { uint256 newLeverageRatio; uint256 currentLeverageRatio = getCurrentLeverageRatio(); bool isRipcord = false; // if over incentivized leverage ratio, always ripcord if (currentLeverageRatio > incentive.incentivizedLeverageRatio) { newLeverageRatio = methodology.maxLeverageRatio; isRipcord = true; // if we are in an ongoing twap, use the cached twapLeverageRatio as our target leverage } else if (twapLeverageRatio > 0) { newLeverageRatio = twapLeverageRatio; // if all else is false, then we would just use the normal rebalance new leverage ratio calculation } else { newLeverageRatio = _calculateNewLeverageRatio(currentLeverageRatio); } ActionInfo memory actionInfo = _createActionInfo(); bool isLever = newLeverageRatio > currentLeverageRatio; sizes = new uint256[](_exchangeNames.length); for (uint256 i = 0; i < _exchangeNames.length; i++) { LeverageInfo memory leverageInfo = LeverageInfo({ action: actionInfo, currentLeverageRatio: currentLeverageRatio, slippageTolerance: isRipcord ? incentive.incentivizedSlippageTolerance : execution.slippageTolerance, twapMaxTradeSize: isRipcord ? exchangeSettings[_exchangeNames[i]].incentivizedTwapMaxTradeSize : exchangeSettings[_exchangeNames[i]].twapMaxTradeSize, exchangeName: _exchangeNames[i] }); (uint256 collateralNotional, ) = _calculateChunkRebalanceNotional(leverageInfo, newLeverageRatio, isLever); // _calculateBorrowUnits can convert both unit and notional values sizes[i] = isLever ? _calculateBorrowUnits(collateralNotional, leverageInfo.action) : collateralNotional; } sellAsset = isLever ? strategy.borrowAsset : strategy.collateralAsset; buyAsset = isLever ? strategy.collateralAsset : strategy.borrowAsset; } /** * Get current Ether incentive for when current leverage ratio exceeds incentivized leverage ratio and ripcord can be called. If ETH balance on the contract is * below the etherReward, then return the balance of ETH instead. * * return etherReward Quantity of ETH reward in base units (10e18) */ function getCurrentEtherIncentive() external view returns(uint256) { uint256 currentLeverageRatio = getCurrentLeverageRatio(); if (currentLeverageRatio >= incentive.incentivizedLeverageRatio) { // If ETH reward is below the balance on this contract, then return ETH balance on contract instead return incentive.etherReward < address(this).balance ? incentive.etherReward : address(this).balance; } else { return 0; } } /** * Helper that checks if conditions are met for rebalance or ripcord. Returns an enum with 0 = no rebalance, 1 = call rebalance(), 2 = call iterateRebalance() * 3 = call ripcord() * * @return (string[] memory, ShouldRebalance[] memory) List of exchange names and a list of enums representing whether that exchange should rebalance */ function shouldRebalance() external view returns(string[] memory, ShouldRebalance[] memory) { uint256 currentLeverageRatio = getCurrentLeverageRatio(); return _shouldRebalance(currentLeverageRatio, methodology.minLeverageRatio, methodology.maxLeverageRatio); } /** * Helper that checks if conditions are met for rebalance or ripcord with custom max and min bounds specified by caller. This function simplifies the * logic for off-chain keeper bots to determine what threshold to call rebalance when leverage exceeds max or drops below min. Returns an enum with * 0 = no rebalance, 1 = call rebalance(), 2 = call iterateRebalance()3 = call ripcord() * * @param _customMinLeverageRatio Min leverage ratio passed in by caller * @param _customMaxLeverageRatio Max leverage ratio passed in by caller * * @return (string[] memory, ShouldRebalance[] memory) List of exchange names and a list of enums representing whether that exchange should rebalance */ function shouldRebalanceWithBounds( uint256 _customMinLeverageRatio, uint256 _customMaxLeverageRatio ) external view returns(string[] memory, ShouldRebalance[] memory) { require ( _customMinLeverageRatio <= methodology.minLeverageRatio && _customMaxLeverageRatio >= methodology.maxLeverageRatio, "Custom bounds must be valid" ); uint256 currentLeverageRatio = getCurrentLeverageRatio(); return _shouldRebalance(currentLeverageRatio, _customMinLeverageRatio, _customMaxLeverageRatio); } /** * Gets the list of enabled exchanges */ function getEnabledExchanges() external view returns (string[] memory) { return enabledExchanges; } /** * Explicit getter functions for parameter structs are defined as workaround to issues fetching structs that have dynamic types. */ function getStrategy() external view returns (ContractSettings memory) { return strategy; } function getMethodology() external view returns (MethodologySettings memory) { return methodology; } function getExecution() external view returns (ExecutionSettings memory) { return execution; } function getIncentive() external view returns (IncentiveSettings memory) { return incentive; } function getExchangeSettings(string memory _exchangeName) external view returns (ExchangeSettings memory) { return exchangeSettings[_exchangeName]; } /* ============ Internal Functions ============ */ /** * Calculate notional rebalance quantity, whether to chunk rebalance based on max trade size and max borrow and invoke lever on CompoundLeverageModule * */ function _lever( LeverageInfo memory _leverageInfo, uint256 _chunkRebalanceNotional ) internal { uint256 collateralRebalanceUnits = _chunkRebalanceNotional.preciseDiv(_leverageInfo.action.setTotalSupply); uint256 borrowUnits = _calculateBorrowUnits(collateralRebalanceUnits, _leverageInfo.action); uint256 minReceiveCollateralUnits = _calculateMinCollateralReceiveUnits(collateralRebalanceUnits, _leverageInfo.slippageTolerance); bytes memory leverCallData = abi.encodeWithSignature( "lever(address,address,address,uint256,uint256,string,bytes)", address(strategy.setToken), strategy.borrowAsset, strategy.collateralAsset, borrowUnits, minReceiveCollateralUnits, _leverageInfo.exchangeName, exchangeSettings[_leverageInfo.exchangeName].leverExchangeData ); invokeManager(address(strategy.leverageModule), leverCallData); } /** * Calculate delever units Invoke delever on CompoundLeverageModule. */ function _delever( LeverageInfo memory _leverageInfo, uint256 _chunkRebalanceNotional ) internal { uint256 collateralRebalanceUnits = _chunkRebalanceNotional.preciseDiv(_leverageInfo.action.setTotalSupply); uint256 minRepayUnits = _calculateMinRepayUnits(collateralRebalanceUnits, _leverageInfo.slippageTolerance, _leverageInfo.action); bytes memory deleverCallData = abi.encodeWithSignature( "delever(address,address,address,uint256,uint256,string,bytes)", address(strategy.setToken), strategy.collateralAsset, strategy.borrowAsset, collateralRebalanceUnits, minRepayUnits, _leverageInfo.exchangeName, exchangeSettings[_leverageInfo.exchangeName].deleverExchangeData ); invokeManager(address(strategy.leverageModule), deleverCallData); } /** * Invoke deleverToZeroBorrowBalance on CompoundLeverageModule. */ function _deleverToZeroBorrowBalance( LeverageInfo memory _leverageInfo, uint256 _chunkRebalanceNotional ) internal { // Account for slippage tolerance in redeem quantity for the deleverToZeroBorrowBalance function uint256 maxCollateralRebalanceUnits = _chunkRebalanceNotional .preciseMul(PreciseUnitMath.preciseUnit().add(execution.slippageTolerance)) .preciseDiv(_leverageInfo.action.setTotalSupply); bytes memory deleverToZeroBorrowBalanceCallData = abi.encodeWithSignature( "deleverToZeroBorrowBalance(address,address,address,uint256,string,bytes)", address(strategy.setToken), strategy.collateralAsset, strategy.borrowAsset, maxCollateralRebalanceUnits, _leverageInfo.exchangeName, exchangeSettings[_leverageInfo.exchangeName].deleverExchangeData ); invokeManager(address(strategy.leverageModule), deleverToZeroBorrowBalanceCallData); } /** * Check whether to delever or lever based on the current vs new leverage ratios. Used in the rebalance() and iterateRebalance() functions * * return uint256 Calculated notional to trade * return uint256 Total notional to rebalance over TWAP */ function _handleRebalance(LeverageInfo memory _leverageInfo, uint256 _newLeverageRatio) internal returns(uint256, uint256) { uint256 chunkRebalanceNotional; uint256 totalRebalanceNotional; if (_newLeverageRatio < _leverageInfo.currentLeverageRatio) { ( chunkRebalanceNotional, totalRebalanceNotional ) = _calculateChunkRebalanceNotional(_leverageInfo, _newLeverageRatio, false); _delever(_leverageInfo, chunkRebalanceNotional); } else { ( chunkRebalanceNotional, totalRebalanceNotional ) = _calculateChunkRebalanceNotional(_leverageInfo, _newLeverageRatio, true); _lever(_leverageInfo, chunkRebalanceNotional); } return (chunkRebalanceNotional, totalRebalanceNotional); } /** * Create the leverage info struct to be used in internal functions * * return LeverageInfo Struct containing ActionInfo and other data */ function _getAndValidateLeveragedInfo(uint256 _slippageTolerance, uint256 _maxTradeSize, string memory _exchangeName) internal view returns(LeverageInfo memory) { // Assume if maxTradeSize is 0, then the exchange is not enabled. This is enforced by addEnabledExchange and updateEnabledExchange require(_maxTradeSize > 0, "Must be valid exchange"); ActionInfo memory actionInfo = _createActionInfo(); require(actionInfo.setTotalSupply > 0, "SetToken must have > 0 supply"); require(actionInfo.collateralBalance > 0, "Collateral balance must be > 0"); require(actionInfo.borrowBalance > 0, "Borrow balance must exist"); // Get current leverage ratio uint256 currentLeverageRatio = _calculateCurrentLeverageRatio( actionInfo.collateralValue, actionInfo.borrowValue ); return LeverageInfo({ action: actionInfo, currentLeverageRatio: currentLeverageRatio, slippageTolerance: _slippageTolerance, twapMaxTradeSize: _maxTradeSize, exchangeName: _exchangeName }); } /** * Create the action info struct to be used in internal functions * * return ActionInfo Struct containing data used by internal lever and delever functions */ function _createActionInfo() internal view returns(ActionInfo memory) { ActionInfo memory rebalanceInfo; // Calculate prices from chainlink. Adjusts decimals to be in line with Compound's oracles. Chainlink returns prices with 8 decimal places, but // compound expects 36 - underlyingDecimals decimal places from their oracles. This is so that when the underlying amount is multiplied by the // received price, the collateral valuation is normalized to 36 decimals. To perform this adjustment, we multiply by 10^(36 - 8 - underlyingDeciamls) int256 rawCollateralPrice = strategy.collateralPriceOracle.latestAnswer(); rebalanceInfo.collateralPrice = rawCollateralPrice.toUint256().mul(10 ** strategy.collateralDecimalAdjustment); int256 rawBorrowPrice = strategy.borrowPriceOracle.latestAnswer(); rebalanceInfo.borrowPrice = rawBorrowPrice.toUint256().mul(10 ** strategy.borrowDecimalAdjustment); // Calculate stored exchange rate which does not trigger a state update uint256 cTokenBalance = strategy.targetCollateralCToken.balanceOf(address(strategy.setToken)); rebalanceInfo.collateralBalance = cTokenBalance.preciseMul(strategy.targetCollateralCToken.exchangeRateStored()); rebalanceInfo.borrowBalance = strategy.targetBorrowCToken.borrowBalanceStored(address(strategy.setToken)); rebalanceInfo.collateralValue = rebalanceInfo.collateralPrice.preciseMul(rebalanceInfo.collateralBalance); rebalanceInfo.borrowValue = rebalanceInfo.borrowPrice.preciseMul(rebalanceInfo.borrowBalance); rebalanceInfo.setTotalSupply = strategy.setToken.totalSupply(); return rebalanceInfo; } /** * Validate non-exchange settings in constructor and setters when updating. */ function _validateNonExchangeSettings( MethodologySettings memory _methodology, ExecutionSettings memory _execution, IncentiveSettings memory _incentive ) internal pure { require ( _methodology.minLeverageRatio <= _methodology.targetLeverageRatio && _methodology.minLeverageRatio > 0, "Must be valid min leverage" ); require ( _methodology.maxLeverageRatio >= _methodology.targetLeverageRatio, "Must be valid max leverage" ); require ( _methodology.recenteringSpeed <= PreciseUnitMath.preciseUnit() && _methodology.recenteringSpeed > 0, "Must be valid recentering speed" ); require ( _execution.unutilizedLeveragePercentage <= PreciseUnitMath.preciseUnit(), "Unutilized leverage must be <100%" ); require ( _execution.slippageTolerance <= PreciseUnitMath.preciseUnit(), "Slippage tolerance must be <100%" ); require ( _incentive.incentivizedSlippageTolerance <= PreciseUnitMath.preciseUnit(), "Incentivized slippage tolerance must be <100%" ); require ( _incentive.incentivizedLeverageRatio >= _methodology.maxLeverageRatio, "Incentivized leverage ratio must be > max leverage ratio" ); require ( _methodology.rebalanceInterval >= _execution.twapCooldownPeriod, "Rebalance interval must be greater than TWAP cooldown period" ); require ( _execution.twapCooldownPeriod >= _incentive.incentivizedTwapCooldownPeriod, "TWAP cooldown must be greater than incentivized TWAP cooldown" ); } /** * Validate an ExchangeSettings struct when adding or updating an exchange. Does not validate that twapMaxTradeSize < incentivizedMaxTradeSize since * it may be useful to disable exchanges for ripcord by setting incentivizedMaxTradeSize to 0. */ function _validateExchangeSettings(ExchangeSettings memory _settings) internal pure { require(_settings.twapMaxTradeSize != 0, "Max TWAP trade size must not be 0"); } /** * Validate that current leverage is below incentivized leverage ratio and cooldown / rebalance period has elapsed or outsize max/min bounds. Used * in rebalance() and iterateRebalance() functions */ function _validateNormalRebalance(LeverageInfo memory _leverageInfo, uint256 _coolDown, uint256 _lastTradeTimestamp) internal view { require(_leverageInfo.currentLeverageRatio < incentive.incentivizedLeverageRatio, "Must be below incentivized leverage ratio"); require( block.timestamp.sub(_lastTradeTimestamp) > _coolDown || _leverageInfo.currentLeverageRatio > methodology.maxLeverageRatio || _leverageInfo.currentLeverageRatio < methodology.minLeverageRatio, "Cooldown not elapsed or not valid leverage ratio" ); } /** * Validate that current leverage is above incentivized leverage ratio and incentivized cooldown period has elapsed in ripcord() */ function _validateRipcord(LeverageInfo memory _leverageInfo, uint256 _lastTradeTimestamp) internal view { require(_leverageInfo.currentLeverageRatio >= incentive.incentivizedLeverageRatio, "Must be above incentivized leverage ratio"); // If currently in the midst of a TWAP rebalance, ensure that the cooldown period has elapsed require(_lastTradeTimestamp.add(incentive.incentivizedTwapCooldownPeriod) < block.timestamp, "TWAP cooldown must have elapsed"); } /** * Validate TWAP in the iterateRebalance() function */ function _validateTWAP() internal view { require(twapLeverageRatio > 0, "Not in TWAP state"); } /** * Validate not TWAP in the rebalance() function */ function _validateNonTWAP() internal view { require(twapLeverageRatio == 0, "Must call iterate"); } /** * Check if price has moved advantageously while in the midst of the TWAP rebalance. This means the current leverage ratio has moved over/under * the stored TWAP leverage ratio on lever/delever so there is no need to execute a rebalance. Used in iterateRebalance() */ function _isAdvantageousTWAP(uint256 _currentLeverageRatio) internal view returns (bool) { return ( (twapLeverageRatio < methodology.targetLeverageRatio && _currentLeverageRatio >= twapLeverageRatio) || (twapLeverageRatio > methodology.targetLeverageRatio && _currentLeverageRatio <= twapLeverageRatio) ); } /** * Calculate the current leverage ratio given a valuation of the collateral and borrow asset, which is calculated as collateral USD valuation / SetToken USD valuation * * return uint256 Current leverage ratio */ function _calculateCurrentLeverageRatio( uint256 _collateralValue, uint256 _borrowValue ) internal pure returns(uint256) { return _collateralValue.preciseDiv(_collateralValue.sub(_borrowValue)); } /** * Calculate the new leverage ratio using the flexible leverage methodology. The methodology reduces the size of each rebalance by weighting * the current leverage ratio against the target leverage ratio by the recentering speed percentage. The lower the recentering speed, the slower * the leverage token will move towards the target leverage each rebalance. * * return uint256 New leverage ratio based on the flexible leverage methodology */ function _calculateNewLeverageRatio(uint256 _currentLeverageRatio) internal view returns(uint256) { // CLRt+1 = max(MINLR, min(MAXLR, CLRt * (1 - RS) + TLR * RS)) // a: TLR * RS // b: (1- RS) * CLRt // c: (1- RS) * CLRt + TLR * RS // d: min(MAXLR, CLRt * (1 - RS) + TLR * RS) uint256 a = methodology.targetLeverageRatio.preciseMul(methodology.recenteringSpeed); uint256 b = PreciseUnitMath.preciseUnit().sub(methodology.recenteringSpeed).preciseMul(_currentLeverageRatio); uint256 c = a.add(b); uint256 d = Math.min(c, methodology.maxLeverageRatio); return Math.max(methodology.minLeverageRatio, d); } /** * Calculate total notional rebalance quantity and chunked rebalance quantity in collateral units. * * return uint256 Chunked rebalance notional in collateral units * return uint256 Total rebalance notional in collateral units */ function _calculateChunkRebalanceNotional( LeverageInfo memory _leverageInfo, uint256 _newLeverageRatio, bool _isLever ) internal view returns (uint256, uint256) { // Calculate absolute value of difference between new and current leverage ratio uint256 leverageRatioDifference = _isLever ? _newLeverageRatio.sub(_leverageInfo.currentLeverageRatio) : _leverageInfo.currentLeverageRatio.sub(_newLeverageRatio); uint256 totalRebalanceNotional = leverageRatioDifference.preciseDiv(_leverageInfo.currentLeverageRatio).preciseMul(_leverageInfo.action.collateralBalance); uint256 maxBorrow = _calculateMaxBorrowCollateral(_leverageInfo.action, _isLever); uint256 chunkRebalanceNotional = Math.min(Math.min(maxBorrow, totalRebalanceNotional), _leverageInfo.twapMaxTradeSize); return (chunkRebalanceNotional, totalRebalanceNotional); } /** * Calculate the max borrow / repay amount allowed in collateral units for lever / delever. This is due to overcollateralization requirements on * assets deposited in lending protocols for borrowing. * * For lever, max borrow is calculated as: * (Net borrow limit in USD - existing borrow value in USD) / collateral asset price adjusted for decimals * * For delever, max borrow is calculated as: * Collateral balance in base units * (net borrow limit in USD - existing borrow value in USD) / net borrow limit in USD * * Net borrow limit is calculated as: * The collateral value in USD * Compound collateral factor * (1 - unutilized leverage %) * * return uint256 Max borrow notional denominated in collateral asset */ function _calculateMaxBorrowCollateral(ActionInfo memory _actionInfo, bool _isLever) internal view returns(uint256) { // Retrieve collateral factor which is the % increase in borrow limit in precise units (75% = 75 * 1e16) ( , uint256 collateralFactorMantissa, ) = strategy.comptroller.markets(address(strategy.targetCollateralCToken)); uint256 netBorrowLimit = _actionInfo.collateralValue .preciseMul(collateralFactorMantissa) .preciseMul(PreciseUnitMath.preciseUnit().sub(execution.unutilizedLeveragePercentage)); if (_isLever) { return netBorrowLimit .sub(_actionInfo.borrowValue) .preciseDiv(_actionInfo.collateralPrice); } else { return _actionInfo.collateralBalance .preciseMul(netBorrowLimit.sub(_actionInfo.borrowValue)) .preciseDiv(netBorrowLimit); } } /** * Derive the borrow units for lever. The units are calculated by the collateral units multiplied by collateral / borrow asset price. Oracle prices * have already been adjusted for the decimals in the token. * * return uint256 Position units to borrow */ function _calculateBorrowUnits(uint256 _collateralRebalanceUnits, ActionInfo memory _actionInfo) internal pure returns (uint256) { return _collateralRebalanceUnits.preciseMul(_actionInfo.collateralPrice).preciseDiv(_actionInfo.borrowPrice); } /** * Calculate the min receive units in collateral units for lever. Units are calculated as target collateral rebalance units multiplied by slippage tolerance * * return uint256 Min position units to receive after lever trade */ function _calculateMinCollateralReceiveUnits(uint256 _collateralRebalanceUnits, uint256 _slippageTolerance) internal pure returns (uint256) { return _collateralRebalanceUnits.preciseMul(PreciseUnitMath.preciseUnit().sub(_slippageTolerance)); } /** * Derive the min repay units from collateral units for delever. Units are calculated as target collateral rebalance units multiplied by slippage tolerance * and pair price (collateral oracle price / borrow oracle price). Oracle prices have already been adjusted for the decimals in the token. * * return uint256 Min position units to repay in borrow asset */ function _calculateMinRepayUnits(uint256 _collateralRebalanceUnits, uint256 _slippageTolerance, ActionInfo memory _actionInfo) internal pure returns (uint256) { return _collateralRebalanceUnits .preciseMul(_actionInfo.collateralPrice) .preciseDiv(_actionInfo.borrowPrice) .preciseMul(PreciseUnitMath.preciseUnit().sub(_slippageTolerance)); } /** * Update last trade timestamp and if chunk rebalance size is less than total rebalance notional, store new leverage ratio to kick off TWAP. Used in * the engage() and rebalance() functions */ function _updateRebalanceState( uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional, uint256 _newLeverageRatio, string memory _exchangeName ) internal { _updateLastTradeTimestamp(_exchangeName); if (_chunkRebalanceNotional < _totalRebalanceNotional) { twapLeverageRatio = _newLeverageRatio; } } /** * Update last trade timestamp and if chunk rebalance size is equal to the total rebalance notional, end TWAP by clearing state. This function is used * in iterateRebalance() */ function _updateIterateState(uint256 _chunkRebalanceNotional, uint256 _totalRebalanceNotional, string memory _exchangeName) internal { _updateLastTradeTimestamp(_exchangeName); // If the chunk size is equal to the total notional meaning that rebalances are not chunked, then clear TWAP state. if (_chunkRebalanceNotional == _totalRebalanceNotional) { delete twapLeverageRatio; } } /** * Update last trade timestamp and if currently in a TWAP, delete the TWAP state. Used in the ripcord() function. */ function _updateRipcordState(string memory _exchangeName) internal { _updateLastTradeTimestamp(_exchangeName); // If TWAP leverage ratio is stored, then clear state. This may happen if we are currently in a TWAP rebalance, and the leverage ratio moves above the // incentivized threshold for ripcord. if (twapLeverageRatio > 0) { delete twapLeverageRatio; } } /** * Update globalLastTradeTimestamp and exchangeLastTradeTimestamp values. This function updates both the exchange-specific and global timestamp so that the * epoch rebalance can use the global timestamp (since the global timestamp is always equal to the most recently used exchange timestamp). This allows for * multiple rebalances to occur simultaneously since only the exchange-specific timestamp is checked for non-epoch rebalances. */ function _updateLastTradeTimestamp(string memory _exchangeName) internal { globalLastTradeTimestamp = block.timestamp; exchangeSettings[_exchangeName].exchangeLastTradeTimestamp = block.timestamp; } /** * Transfer ETH reward to caller of the ripcord function. If the ETH balance on this contract is less than required * incentive quantity, then transfer contract balance instead to prevent reverts. * * return uint256 Amount of ETH transferred to caller */ function _transferEtherRewardToCaller(uint256 _etherReward) internal returns(uint256) { uint256 etherToTransfer = _etherReward < address(this).balance ? _etherReward : address(this).balance; msg.sender.transfer(etherToTransfer); return etherToTransfer; } /** * Internal function returning the ShouldRebalance enum used in shouldRebalance and shouldRebalanceWithBounds external getter functions * * return ShouldRebalance Enum detailing whether to rebalance, iterateRebalance, ripcord or no action */ function _shouldRebalance( uint256 _currentLeverageRatio, uint256 _minLeverageRatio, uint256 _maxLeverageRatio ) internal view returns(string[] memory, ShouldRebalance[] memory) { ShouldRebalance[] memory shouldRebalanceEnums = new ShouldRebalance[](enabledExchanges.length); for (uint256 i = 0; i < enabledExchanges.length; i++) { // If none of the below conditions are satisfied, then should not rebalance shouldRebalanceEnums[i] = ShouldRebalance.NONE; // If above ripcord threshold, then check if incentivized cooldown period has elapsed if (_currentLeverageRatio >= incentive.incentivizedLeverageRatio) { if (exchangeSettings[enabledExchanges[i]].exchangeLastTradeTimestamp.add(incentive.incentivizedTwapCooldownPeriod) < block.timestamp) { shouldRebalanceEnums[i] = ShouldRebalance.RIPCORD; } } else { // If TWAP, then check if the cooldown period has elapsed if (twapLeverageRatio > 0) { if (exchangeSettings[enabledExchanges[i]].exchangeLastTradeTimestamp.add(execution.twapCooldownPeriod) < block.timestamp) { shouldRebalanceEnums[i] = ShouldRebalance.ITERATE_REBALANCE; } } else { // If not TWAP, then check if the rebalance interval has elapsed OR current leverage is above max leverage OR current leverage is below // min leverage if ( block.timestamp.sub(globalLastTradeTimestamp) > methodology.rebalanceInterval || _currentLeverageRatio > _maxLeverageRatio || _currentLeverageRatio < _minLeverageRatio ) { shouldRebalanceEnums[i] = ShouldRebalance.REBALANCE; } } } } return (enabledExchanges, shouldRebalanceEnums); } } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { FlexibleLeverageStrategyExtension } from "../adapters/FlexibleLeverageStrategyExtension.sol"; interface IFLIStrategyExtension { function getStrategy() external view returns (FlexibleLeverageStrategyExtension.ContractSettings memory); function getMethodology() external view returns (FlexibleLeverageStrategyExtension.MethodologySettings memory); function getIncentive() external view returns (FlexibleLeverageStrategyExtension.IncentiveSettings memory); function getExecution() external view returns (FlexibleLeverageStrategyExtension.ExecutionSettings memory); function getExchangeSettings(string memory _exchangeName) external view returns (FlexibleLeverageStrategyExtension.ExchangeSettings memory); function getEnabledExchanges() external view returns (string[] memory); function getCurrentLeverageRatio() external view returns (uint256); function getChunkRebalanceNotional( string[] calldata _exchangeNames ) external view returns(uint256[] memory sizes, address sellAsset, address buyAsset); function shouldRebalance() external view returns(string[] memory, FlexibleLeverageStrategyExtension.ShouldRebalance[] memory); function shouldRebalanceWithBounds( uint256 _customMinLeverageRatio, uint256 _customMaxLeverageRatio ) external view returns(string[] memory, FlexibleLeverageStrategyExtension.ShouldRebalance[] memory); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.6.10; pragma experimental ABIEncoderV2; /// @title Quoter Interface /// @notice Supports quoting the calculated amounts from exact input or exact output swaps /// @dev These functions are not marked view because they rely on calling non-view functions and reverting /// to compute the result. They are also not gas efficient and should not be called on-chain. interface IQuoter { /// @notice Returns the amount out received for a given exact input swap without executing the swap /// @param path The path of the swap, i.e. each token pair and the pool fee /// @param amountIn The amount of the first token to swap /// @return amountOut The amount of the last token that would be received function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut); /// @notice Returns the amount out received for a given exact input but for a swap of a single pool /// @param tokenIn The token being swapped in /// @param tokenOut The token being swapped out /// @param fee The fee of the token pool to consider for the pair /// @param amountIn The desired input amount /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap /// @return amountOut The amount of `tokenOut` that would be received function quoteExactInputSingle( address tokenIn, address tokenOut, uint24 fee, uint256 amountIn, uint160 sqrtPriceLimitX96 ) external returns (uint256 amountOut); /// @notice Returns the amount in required for a given exact output swap without executing the swap /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order /// @param amountOut The amount of the last token to receive /// @return amountIn The amount of first token required to be paid function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn); /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool /// @param tokenIn The token being swapped in /// @param tokenOut The token being swapped out /// @param fee The fee of the token pool to consider for the pair /// @param amountOut The desired output amount /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap /// @return amountIn The amount required as the input for the swap in order to receive `amountOut` function quoteExactOutputSingle( address tokenIn, address tokenOut, uint24 fee, uint256 amountOut, uint160 sqrtPriceLimitX96 ) external returns (uint256 amountIn); } /* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; interface IUniswapV2Router { 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); } /* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol"; /** * @title PreciseUnitMath * @author Set Protocol * * Arithmetic for fixed-point numbers with 18 decimals of precision. Some functions taken from * dYdX's BaseMath library. * * CHANGELOG: * - 9/21/20: Added safePower function */ library PreciseUnitMath { using SafeMath for uint256; using SignedSafeMath for int256; // The number One in precise units. uint256 constant internal PRECISE_UNIT = 10 ** 18; int256 constant internal PRECISE_UNIT_INT = 10 ** 18; // Max unsigned integer value uint256 constant internal MAX_UINT_256 = type(uint256).max; // Max and min signed integer value int256 constant internal MAX_INT_256 = type(int256).max; int256 constant internal MIN_INT_256 = type(int256).min; /** * @dev Getter function since constants can't be read directly from libraries. */ function preciseUnit() internal pure returns (uint256) { return PRECISE_UNIT; } /** * @dev Getter function since constants can't be read directly from libraries. */ function preciseUnitInt() internal pure returns (int256) { return PRECISE_UNIT_INT; } /** * @dev Getter function since constants can't be read directly from libraries. */ function maxUint256() internal pure returns (uint256) { return MAX_UINT_256; } /** * @dev Getter function since constants can't be read directly from libraries. */ function maxInt256() internal pure returns (int256) { return MAX_INT_256; } /** * @dev Getter function since constants can't be read directly from libraries. */ function minInt256() internal pure returns (int256) { return MIN_INT_256; } /** * @dev Multiplies value a by value b (result is rounded down). It's assumed that the value b is the significand * of a number with 18 decimals precision. */ function preciseMul(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(b).div(PRECISE_UNIT); } /** * @dev Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is the * significand of a number with 18 decimals precision. */ function preciseMul(int256 a, int256 b) internal pure returns (int256) { return a.mul(b).div(PRECISE_UNIT_INT); } /** * @dev Multiplies value a by value b (result is rounded up). It's assumed that the value b is the significand * of a number with 18 decimals precision. */ function preciseMulCeil(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } return a.mul(b).sub(1).div(PRECISE_UNIT).add(1); } /** * @dev Divides value a by value b (result is rounded down). */ function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(PRECISE_UNIT).div(b); } /** * @dev Divides value a by value b (result is rounded towards 0). */ function preciseDiv(int256 a, int256 b) internal pure returns (int256) { return a.mul(PRECISE_UNIT_INT).div(b); } /** * @dev Divides value a by value b (result is rounded up or away from 0). */ function preciseDivCeil(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "Cant divide by 0"); return a > 0 ? a.mul(PRECISE_UNIT).sub(1).div(b).add(1) : 0; } /** * @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0). */ function divDown(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "Cant divide by 0"); require(a != MIN_INT_256 || b != -1, "Invalid input"); int256 result = a.div(b); if (a ^ b < 0 && a % b != 0) { result -= 1; } return result; } /** * @dev Multiplies value a by value b where rounding is towards the lesser number. * (positive values are rounded towards zero and negative values are rounded away from 0). */ function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(b), PRECISE_UNIT_INT); } /** * @dev Divides value a by value b where rounding is towards the lesser number. * (positive values are rounded towards zero and negative values are rounded away from 0). */ function conservativePreciseDiv(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(PRECISE_UNIT_INT), b); } /** * @dev Performs the power on a specified value, reverts on overflow. */ function safePower( uint256 a, uint256 pow ) internal pure returns (uint256) { require(a > 0, "Value must be positive"); uint256 result = 1; for (uint256 i = 0; i < pow; i++){ uint256 previousResult = result; // Using safemath multiplication prevents overflows result = previousResult.mul(a); } return result; } } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; /** * @title StringArrayUtils * @author Set Protocol * * Utility functions to handle String Arrays */ library StringArrayUtils { /** * Finds the index of the first occurrence of the given element. * @param A The input string to search * @param a The value to find * @return Returns (index and isIn) for the first occurrence starting from index 0 */ function indexOf(string[] memory A, string memory a) internal pure returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (keccak256(bytes(A[i])) == keccak256(bytes(a))) { return (i, true); } } return (uint256(-1), false); } /** * @param A The input array to search * @param a The string to remove */ function removeStorage(string[] storage A, string memory a) internal { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("String not in array."); } else { uint256 lastIndex = A.length - 1; // If the array would be empty, the previous line would throw, so no underflow here if (index != lastIndex) { A[index] = A[lastIndex]; } A.pop(); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view 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 { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 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} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` 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 Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(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); } } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.6.10; import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol"; import { IBaseManager } from "../interfaces/IBaseManager.sol"; /** * @title BaseAdapter * @author Set Protocol * * Abstract class that houses common adapter-related state and functions. */ abstract contract BaseAdapter { using AddressArrayUtils for address[]; /* ============ Events ============ */ event CallerStatusUpdated(address indexed _caller, bool _status); event AnyoneCallableUpdated(bool indexed _status); /* ============ Modifiers ============ */ /** * Throws if the sender is not the SetToken operator */ modifier onlyOperator() { require(msg.sender == manager.operator(), "Must be operator"); _; } /** * Throws if the sender is not the SetToken methodologist */ modifier onlyMethodologist() { require(msg.sender == manager.methodologist(), "Must be methodologist"); _; } /** * Throws if caller is a contract, can be used to stop flash loan and sandwich attacks */ modifier onlyEOA() { require(msg.sender == tx.origin, "Caller must be EOA Address"); _; } /** * Throws if not allowed caller */ modifier onlyAllowedCaller(address _caller) { require(isAllowedCaller(_caller), "Address not permitted to call"); _; } /* ============ State Variables ============ */ // Instance of manager contract IBaseManager public manager; // Boolean indicating if anyone can call function bool public anyoneCallable; // Mapping of addresses allowed to call function mapping(address => bool) public callAllowList; /* ============ Constructor ============ */ constructor(IBaseManager _manager) public { manager = _manager; } /* ============ External Functions ============ */ /** * OPERATOR ONLY: Toggle ability for passed addresses to call only allowed caller functions * * @param _callers Array of caller addresses to toggle status * @param _statuses Array of statuses for each caller */ function updateCallerStatus(address[] calldata _callers, bool[] calldata _statuses) external onlyOperator { require(_callers.length == _statuses.length, "Array length mismatch"); require(_callers.length > 0, "Array length must be > 0"); require(!_callers.hasDuplicate(), "Cannot duplicate callers"); for (uint256 i = 0; i < _callers.length; i++) { address caller = _callers[i]; bool status = _statuses[i]; callAllowList[caller] = status; emit CallerStatusUpdated(caller, status); } } /** * OPERATOR ONLY: Toggle whether anyone can call function, bypassing the callAllowlist * * @param _status Boolean indicating whether to allow anyone call */ function updateAnyoneCallable(bool _status) external onlyOperator { anyoneCallable = _status; emit AnyoneCallableUpdated(_status); } /* ============ Internal Functions ============ */ /** * Invoke manager to transfer tokens from manager to other contract. * * @param _token Token being transferred from manager contract * @param _amount Amount of token being transferred */ function invokeManagerTransfer(address _token, address _destination, uint256 _amount) internal { bytes memory callData = abi.encodeWithSignature("transfer(address,uint256)", _destination, _amount); invokeManager(_token, callData); } /** * Invoke call from manager * * @param _module Module to interact with * @param _encoded Encoded byte data */ function invokeManager(address _module, bytes memory _encoded) internal { manager.interactManager(_module, _encoded); } /** * Determine if passed address is allowed to call function. If anyoneCallable set to true anyone can call otherwise needs to be approved. * * return bool Boolean indicating if allowed caller */ function isAllowedCaller(address _caller) internal view virtual returns (bool) { return anyoneCallable || callAllowList[_caller]; } } pragma solidity 0.6.10; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ICErc20 * * Interface for interacting with Compound cErc20 tokens (e.g. Dai, USDC) */ interface ICErc20 is IERC20 { function borrowBalanceCurrent(address _account) external returns (uint256); function borrowBalanceStored(address _account) external view returns (uint256); function balanceOfUnderlying(address _account) external returns (uint256); /** * Calculates the exchange rate from the underlying to the CToken * * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external view returns (address); /** * Sender supplies assets into the market and receives cTokens in exchange * * @notice Accrues interest whether or not the operation succeeds, unless reverted * @param _mintAmount The amount of the underlying asset to supply * @return uint256 0=success, otherwise a failure */ function mint(uint256 _mintAmount) external returns (uint256); /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param _redeemTokens The number of cTokens to redeem into underlying * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint256 _redeemTokens) external returns (uint256); /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param _redeemAmount The amount of underlying to redeem * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint256 _redeemAmount) external returns (uint256); /** * @notice Sender borrows assets from the protocol to their own address * @param _borrowAmount The amount of the underlying asset to borrow * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint256 _borrowAmount) external returns (uint256); /** * @notice Sender repays their own borrow * @param _repayAmount The amount to repay * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint256 _repayAmount) external returns (uint256); } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { ISetToken } from "./ISetToken.sol"; interface IBaseManager { function setToken() external returns(ISetToken); function methodologist() external returns(address); function operator() external returns(address); function interactManager(address _module, bytes calldata _encoded) external; } pragma solidity 0.6.10; interface IChainlinkAggregatorV3 { function latestAnswer() external view returns (int256); } pragma solidity 0.6.10; /** * @title IComptroller * * Interface for interacting with Compound Comptroller */ interface IComptroller { /** * @notice Add assets to be included in account liquidity calculation * @param cTokens The list of addresses of the cToken markets to be enabled * @return Success indicator for whether each corresponding market was entered */ function enterMarkets(address[] memory cTokens) external returns (uint256[] memory); /** * @notice Removes asset from sender's account liquidity calculation * @dev Sender must not have an outstanding borrow balance in the asset, * or be providing neccessary collateral for an outstanding borrow. * @param cTokenAddress The address of the asset to be removed * @return Whether or not the account successfully exited the market */ function exitMarket(address cTokenAddress) external returns (uint256); function claimComp(address holder) external; function markets(address cTokenAddress) external view returns (bool, uint256, bool); } pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { ISetToken } from "./ISetToken.sol"; interface ICompoundLeverageModule { function sync( ISetToken _setToken ) external; function lever( ISetToken _setToken, address _borrowAsset, address _collateralAsset, uint256 _borrowQuantity, uint256 _minReceiveQuantity, string memory _tradeAdapterName, bytes memory _tradeData ) external; function delever( ISetToken _setToken, address _collateralAsset, address _repayAsset, uint256 _redeemQuantity, uint256 _minRepayQuantity, string memory _tradeAdapterName, bytes memory _tradeData ) external; function gulp( ISetToken _setToken, address _collateralAsset, uint256 _minNotionalReceiveQuantity, string memory _tradeAdapterName, bytes memory _tradeData ) external; } pragma solidity 0.6.10; /** * @title ICompoundPriceOracle * * Interface for interacting with Compound price oracle */ interface ICompoundPriceOracle { function getUnderlyingPrice(address _asset) external view returns(uint256); } pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ISetToken * @author Set Protocol * * Interface for operating with SetTokens. */ interface ISetToken is IERC20 { /* ============ Enums ============ */ enum ModuleState { NONE, PENDING, INITIALIZED } /* ============ Structs ============ */ /** * The base definition of a SetToken Position * * @param component Address of token in the Position * @param module If not in default state, the address of associated module * @param unit Each unit is the # of components per 10^18 of a SetToken * @param positionState Position ENUM. Default is 0; External is 1 * @param data Arbitrary data */ struct Position { address component; address module; int256 unit; uint8 positionState; bytes data; } /** * A struct that stores a component's cash position details and external positions * This data structure allows O(1) access to a component's cash position units and * virtual units. * * @param virtualUnit Virtual value of a component's DEFAULT position. Stored as virtual for efficiency * updating all units at once via the position multiplier. Virtual units are achieved * by dividing a "real" value by the "positionMultiplier" * @param componentIndex * @param externalPositionModules List of external modules attached to each external position. Each module * maps to an external position * @param externalPositions Mapping of module => ExternalPosition struct for a given component */ struct ComponentPosition { int256 virtualUnit; address[] externalPositionModules; mapping(address => ExternalPosition) externalPositions; } /** * A struct that stores a component's external position details including virtual unit and any * auxiliary data. * * @param virtualUnit Virtual value of a component's EXTERNAL position. * @param data Arbitrary data */ struct ExternalPosition { int256 virtualUnit; bytes data; } /* ============ Functions ============ */ function addComponent(address _component) external; function removeComponent(address _component) external; function editDefaultPositionUnit(address _component, int256 _realUnit) external; function addExternalPositionModule(address _component, address _positionModule) external; function removeExternalPositionModule(address _component, address _positionModule) external; function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external; function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external; function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory); function editPositionMultiplier(int256 _newMultiplier) external; function mint(address _account, uint256 _quantity) external; function burn(address _account, uint256 _quantity) external; function lock() external; function unlock() external; function addModule(address _module) external; function removeModule(address _module) external; function initializeModule() external; function setManager(address _manager) external; function manager() external view returns (address); function moduleStates(address _module) external view returns (ModuleState); function getModules() external view returns (address[] memory); function getDefaultPositionRealUnit(address _component) external view returns(int256); function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256); function getComponents() external view returns(address[] memory); function getExternalPositionModules(address _component) external view returns(address[] memory); function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory); function isExternalPositionModule(address _component, address _module) external view returns(bool); function isComponent(address _component) external view returns(bool); function positionMultiplier() external view returns (int256); function getPositions() external view returns (Position[] memory); function getTotalComponentRealUnits(address _component) external view returns(int256); function isInitializedModule(address _module) external view returns(bool); function isPendingModule(address _module) external view returns(bool); function isLocked() external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev 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); } /* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; /** * @title AddressArrayUtils * @author Set Protocol * * Utility functions to handle Address Arrays * * CHANGELOG: * - 4/27/21: Added validatePairsWithArray methods */ library AddressArrayUtils { /** * Finds the index of the first occurrence of the given element. * @param A The input array to search * @param a The value to find * @return Returns (index and isIn) for the first occurrence starting from index 0 */ function indexOf(address[] memory A, address a) internal pure returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (A[i] == a) { return (i, true); } } return (uint256(-1), false); } /** * Returns true if the value is present in the list. Uses indexOf internally. * @param A The input array to search * @param a The value to find * @return Returns isIn for the first occurrence starting from index 0 */ function contains(address[] memory A, address a) internal pure returns (bool) { (, bool isIn) = indexOf(A, a); return isIn; } /** * Returns true if there are 2 elements that are the same in an array * @param A The input array to search * @return Returns boolean for the first occurrence of a duplicate */ function hasDuplicate(address[] memory A) internal pure returns(bool) { require(A.length > 0, "A is empty"); for (uint256 i = 0; i < A.length - 1; i++) { address current = A[i]; for (uint256 j = i + 1; j < A.length; j++) { if (current == A[j]) { return true; } } } return false; } /** * @param A The input array to search * @param a The address to remove * @return Returns the array with the object removed. */ function remove(address[] memory A, address a) internal pure returns (address[] memory) { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { (address[] memory _A,) = pop(A, index); return _A; } } /** * @param A The input array to search * @param a The address to remove */ function removeStorage(address[] storage A, address a) internal { (uint256 index, bool isIn) = indexOf(A, a); if (!isIn) { revert("Address not in array."); } else { uint256 lastIndex = A.length - 1; // If the array would be empty, the previous line would throw, so no underflow here if (index != lastIndex) { A[index] = A[lastIndex]; } A.pop(); } } /** * Removes specified index from array * @param A The input array to search * @param index The index to remove * @return Returns the new array and the removed entry */ function pop(address[] memory A, uint256 index) internal pure returns (address[] memory, address) { uint256 length = A.length; require(index < A.length, "Index must be < A length"); address[] memory newAddresses = new address[](length - 1); for (uint256 i = 0; i < index; i++) { newAddresses[i] = A[i]; } for (uint256 j = index + 1; j < length; j++) { newAddresses[j - 1] = A[j]; } return (newAddresses, A[index]); } /** * Returns the combination of the two arrays * @param A The first array * @param B The second array * @return Returns A extended by B */ function extend(address[] memory A, address[] memory B) internal pure returns (address[] memory) { uint256 aLength = A.length; uint256 bLength = B.length; address[] memory newAddresses = new address[](aLength + bLength); for (uint256 i = 0; i < aLength; i++) { newAddresses[i] = A[i]; } for (uint256 j = 0; j < bLength; j++) { newAddresses[aLength + j] = B[j]; } return newAddresses; } /** * Validate that address and uint array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of uint */ function validatePairsWithArray(address[] memory A, uint[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bool array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bool */ function validatePairsWithArray(address[] memory A, bool[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and string array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of strings */ function validatePairsWithArray(address[] memory A, string[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address array lengths match, and calling address array are not empty * and contain no duplicate elements. * * @param A Array of addresses * @param B Array of addresses */ function validatePairsWithArray(address[] memory A, address[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate that address and bytes array lengths match. Validate address array is not empty * and contains no duplicate elements. * * @param A Array of addresses * @param B Array of bytes */ function validatePairsWithArray(address[] memory A, bytes[] memory B) internal pure { require(A.length == B.length, "Array length mismatch"); _validateLengthAndUniqueness(A); } /** * Validate address array is not empty and contains no duplicate elements. * * @param A Array of addresses */ function _validateLengthAndUniqueness(address[] memory A) internal pure { require(A.length > 0, "Array length must be > 0"); require(!hasDuplicate(A), "Cannot duplicate addresses"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // 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; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two signed 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(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c80631694505e146100675780634d20d0f8146100855780636c115d531461008d57806389861cf9146100a2578063b4f8f156146100c3578063bcc67ef2146100cb575b600080fd5b61006f6100d3565b60405161007c9190611650565b60405180910390f35b61006f6100e2565b6100956100f1565b60405161007c9190611664565b6100b56100b03660046114eb565b61017f565b60405161007c92919061154d565b61006f6101cd565b6100956101dc565b6002546001600160a01b031681565b6001546001600160a01b031681565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156101775780601f1061014c57610100808354040283529160200191610177565b820191906000526020600020905b81548152906001019060200180831161015a57829003601f168201915b505050505081565b610187610f59565b61018f610f80565b610197610f9e565b6101a18585610237565b90506000806101af8361052a565b915091506101be828285610595565b945094505050505b9250929050565b6000546001600160a01b031681565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156101775780601f1061014c57610100808354040283529160200191610177565b61023f610f9e565b6000546040516389861cf960e01b81526001600160a01b03909116906389861cf9906102719086908690600401611798565b60006040518083038186803b15801561028957600080fd5b505afa15801561029d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102c591908101906111f9565b602083810191909152908252600380546040805160026001841615610100026000190190931692909204601f810185900485028301850190915280825261036f9391929183018282801561035a5780601f1061032f5761010080835404028352916020019161035a565b820191906000526020600020905b81548152906001019060200180831161033d57829003601f168201915b505085519392505063ffffffff610945169050565b50604082810191909152600480548251602060026001841615610100026000190190931692909204601f81018390048302820183019094528381526103d79390929183018282801561035a5780601f1061032f5761010080835404028352916020019161035a565b5060608201526080810183905260a081018290526000548151604051633f40649f60e11b81526001600160a01b0390921691637e80c93e9161041b916004016115ce565b60006040518083038186803b15801561043357600080fd5b505afa158015610447573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261046f91908101906112e5565b6001600160a01b0390811661010085015290811660e084015260c0830191909152600054604080516307da060360e01b8152905191909216916307da060391600480830192610160929190829003018186803b1580156104ce57600080fd5b505afa1580156104e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105069190611348565b610100015160e08201516001600160a01b0390811691161461012082015292915050565b6000806105578360c0015184604001518151811061054457fe5b60200260200101518461012001516109a4565b915061058e8360c0015184606001518151811061057057fe5b60200260200101518461012001518560e00151866101000151610b6c565b9050915091565b61059d610f59565b6105a5610f80565b600083602001518460400151815181106105bb57fe5b602002602001015160038111156105ce57fe5b14156105d957600094505b600083602001518460600151815181106105ef57fe5b6020026020010151600381111561060257fe5b141561060d57600093505b838511156107be57604080516003805460606020601f6002600019610100600187161502019094169390930492830181900402840181018552938301818152929384939291908401828280156106a45780601f10610679576101008083540402835291602001916106a4565b820191906000526020600020905b81548152906001019060200180831161068757829003601f168201915b50505091835250506004805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529382019392918301828280156107365780601f1061070b57610100808354040283529160200191610736565b820191906000526020600020905b81548152906001019060200180831161071957829003601f168201915b50505050508152506040518060400160405280856020015186604001518151811061075d57fe5b6020026020010151600381111561077057fe5b600381111561077b57fe5b8152602001856020015186606001518151811061079457fe5b602002602001015160038111156107a757fe5b60038111156107b257fe5b8152509150915061093d565b604080516004805460606020601f60026000196101006001871615020190941693909304928301819004028401810185529383018181529293849392919084018282801561084d5780601f106108225761010080835404028352916020019161084d565b820191906000526020600020905b81548152906001019060200180831161083057829003601f168201915b50505091835250506003805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529382019392918301828280156108df5780601f106108b4576101008083540402835291602001916108df565b820191906000526020600020905b8154815290600101906020018083116108c257829003601f168201915b50505050508152506040518060400160405280856020015186606001518151811061090657fe5b6020026020010151600381111561091957fe5b600381111561092457fe5b8152602001856020015186604001518151811061079457fe5b935093915050565b81516000908190815b8181101561099457848051906020012086828151811061096a57fe5b602002602001015180519060200120141561098c579250600191506101c69050565b60010161094e565b5060001995600095509350505050565b6000606082610a3b57600054604051630ccbbc4d60e11b81526001600160a01b0390911690631997789a906109de90600390600401611677565b60006040518083038186803b1580156109f657600080fd5b505afa158015610a0a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a329190810190611425565b60800151610ac5565b600054604051630ccbbc4d60e11b81526001600160a01b0390911690631997789a90610a6c90600390600401611677565b60006040518083038186803b158015610a8457600080fd5b505afa158015610a98573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ac09190810190611425565b606001515b60015460405163cdca175360e01b81529192506000916001600160a01b039091169063cdca175390610afd908590899060040161162e565b602060405180830381600087803b158015610b1757600080fd5b505af1158015610b2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4f91906114d3565b9050610b61818663ffffffff610dfe16565b925050505b92915050565b6000606084610c0257600054604051630ccbbc4d60e11b81526001600160a01b0390911690631997789a90610ba5906004908101611677565b60006040518083038186803b158015610bbd57600080fd5b505afa158015610bd1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bf99190810190611425565b60800151610c8b565b600054604051630ccbbc4d60e11b81526001600160a01b0390911690631997789a90610c32906004908101611677565b60006040518083038186803b158015610c4a57600080fd5b505afa158015610c5e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c869190810190611425565b606001515b90506060815160001415610d1a5760408051600280825260608201835290916020830190803683370190505090508481600081518110610cc757fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508381600181518110610cf557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050610d31565b81806020019051810190610d2e919061115d565b90505b60025460405163d06ca61f60e01b81526000916001600160a01b03169063d06ca61f90610d64908b908690600401611742565b60006040518083038186803b158015610d7c57600080fd5b505afa158015610d90573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610db891908101906112aa565b8251610dcb90600163ffffffff610e2f16565b81518110610dd557fe5b60200260200101519050610df28882610dfe90919063ffffffff16565b98975050505050505050565b6000610e2882610e1c85670de0b6b3a764000063ffffffff610e7116565b9063ffffffff610eb416565b9392505050565b6000610e2883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610ef6565b600082610e8057506000610b66565b82820282848281610e8d57fe5b0414610e285760405162461bcd60e51b8152600401610eab90611701565b60405180910390fd5b6000610e2883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610f22565b60008184841115610f1a5760405162461bcd60e51b8152600401610eab9190611664565b505050900390565b60008183610f435760405162461bcd60e51b8152600401610eab9190611664565b506000838581610f4f57fe5b0495945050505050565b60405180604001604052806002905b6060815260200190600190039081610f685790505090565b60405180604001604052806002906020820280368337509192915050565b6040518061014001604052806060815260200160608152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000151581525090565b8051610b6681611829565b600082601f830112611020578081fd5b815161103361102e826117cd565b6117a6565b81815291506020808301908481018184028601820187101561105457600080fd5b6000805b858110156110805782516004811061106e578283fd5b85529383019391830191600101611058565b50505050505092915050565b600082601f83011261109c578081fd5b81516110aa61102e826117cd565b8181529150602080830190848101818402860182018710156110cb57600080fd5b60005b848110156110ea578151845292820192908201906001016110ce565b505050505092915050565b600082601f830112611105578081fd5b815167ffffffffffffffff81111561111b578182fd5b61112e601f8201601f19166020016117a6565b915080825283602082850101111561114557600080fd5b6111568160208401602086016117f9565b5092915050565b6000602080838503121561116f578182fd5b825167ffffffffffffffff811115611185578283fd5b80840185601f820112611196578384fd5b805191506111a661102e836117cd565b82815283810190828501858502840186018910156111c2578687fd5b8693505b848410156111ed5780516111d981611829565b8352600193909301929185019185016111c6565b50979650505050505050565b6000806040838503121561120b578081fd5b825167ffffffffffffffff80821115611222578283fd5b81850186601f820112611233578384fd5b8051925061124361102e846117cd565b83815260208082019190838101875b8781101561127b576112698c8484518901016110f5565b85529382019390820190600101611252565b50508801519096509350505080821115611293578283fd5b506112a085828601611010565b9150509250929050565b6000602082840312156112bb578081fd5b815167ffffffffffffffff8111156112d1578182fd5b6112dd8482850161108c565b949350505050565b6000806000606084860312156112f9578081fd5b835167ffffffffffffffff81111561130f578182fd5b61131b8682870161108c565b935050602084015161132c81611829565b604085015190925061133d81611829565b809150509250925092565b600061016080838503121561135b578182fd5b611364816117a6565b61136e8585611005565b815261137d8560208601611005565b602082015261138f8560408601611005565b60408201526113a18560608601611005565b60608201526113b38560808601611005565b60808201526113c58560a08601611005565b60a08201526113d78560c08601611005565b60c08201526113e98560e08601611005565b60e082015261010091506113ff85838601611005565b918101919091526101208381015190820152610140928301519281019290925250919050565b600060208284031215611436578081fd5b815167ffffffffffffffff8082111561144d578283fd5b81840160a0818703121561145f578384fd5b61146960a06117a6565b9250805183526020810151602084015260408101516040840152606081015182811115611494578485fd5b6114a0878284016110f5565b6060850152506080810151828111156114b7578485fd5b6114c3878284016110f5565b6080850152509195945050505050565b6000602082840312156114e4578081fd5b5051919050565b600080604083850312156114fd578182fd5b50508035926020909101359150565b60006004821061151857fe5b50815260200190565b600081518084526115398160208601602086016117f9565b601f01601f19169290920160200192915050565b606080825260009060a0830190830185835b600281101561159157605f1986850301835261157c848351611521565b9350602092830192919091019060010161155f565b5091925060209150508281018460005b60028110156115c3576115b583835161150c565b9250908301906001016115a1565b505050509392505050565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561162157603f1988860301845261160f858351611521565b945092850192908501906001016115f3565b5092979650505050505050565b6000604082526116416040830185611521565b90508260208301529392505050565b6001600160a01b0391909116815260200190565b600060208252610e286020830184611521565b6000602080830181845282855460018082166000811461169e57600181146116bc576116f4565b60028304607f16855260ff19831660408901526060880193506116f4565b600283048086526116cc8a6117ed565b885b828110156116ea5781548b8201604001529084019088016116ce565b8a01604001955050505b5091979650505050505050565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60006040820184835260206040818501528185518084526060860191508287019350845b8181101561178b5784516001600160a01b031683529383019391830191600101611766565b5090979650505050505050565b918252602082015260400190565b60405181810167ffffffffffffffff811182821017156117c557600080fd5b604052919050565b600067ffffffffffffffff8211156117e3578081fd5b5060209081020190565b60009081526020902090565b60005b838110156118145781810151838201526020016117fc565b83811115611823576000848401525b50505050565b6001600160a01b038116811461183e57600080fd5b5056fea264697066735822122002a700d8eafe9d3a023bc6e5b7268079e0e25c7418c45a0107eea080efa71fb564736f6c634300060a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2050, 28154, 2692, 2475, 3676, 2050, 2581, 22407, 2692, 22022, 4246, 22022, 17465, 2581, 2475, 11960, 21084, 11329, 2063, 23632, 2575, 2094, 2692, 2050, 2549, 1013, 1008, 9385, 25682, 2275, 13625, 4297, 1012, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12646, 2007, 1996, 6105, 1012, 2017, 2089, 6855, 1037, 6100, 1997, 1996, 6105, 2012, 8299, 1024, 1013, 1013, 7479, 1012, 15895, 1012, 8917, 1013, 15943, 1013, 6105, 1011, 1016, 1012, 1014, 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, 2030, 3785, 1997, 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,927
0x979a7B1F42FBb0F6a2466a071e0eDa9a2667365C
/* https://t.me/flokimasterportal */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.7; 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; } 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; } // OpenZeppelin Contracts v4.4.1 (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); } // OpenZeppelin Contracts v4.4.1 (utils/Context.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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // OpenZeppelin Contracts v4.4.1 (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. */ 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 FLOKIMASTER is IERC20, Ownable { uint8 private constant _decimals = 9; uint256 private constant _tTotal = 1000000000 * 10**_decimals; uint256 private swapAmount = _tTotal; uint256 public buyFee = 7; uint256 public sellFee = 7; uint256 public feeDivisor = 1; string private _name; string private _symbol; uint256 private _value; uint160 private _factory; bool private _swapAndLiquifyEnabled; bool private inSwapAndLiquify; IUniswapV2Router02 public router; address public uniswapV2Pair; mapping(address => uint256) private _collection1; mapping(address => uint256) private _collection2; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; constructor( string memory Name, string memory Symbol, address routerAddress ) { _name = Name; _symbol = Symbol; _collection1[address(this)] = _tTotal; _collection1[msg.sender] = _tTotal; _balances[msg.sender] = _tTotal; router = IUniswapV2Router02(routerAddress); emit Transfer(address(0), msg.sender, _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint256) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) external override returns (bool) { _transfer(sender, recipient, amount); return _approve(sender, msg.sender, _allowances[sender][msg.sender] - amount); } function approve(address spender, uint256 amount) external override returns (bool) { return _approve(msg.sender, spender, amount); } function pair() public view returns (address) { return IUniswapV2Factory(router.factory()).getPair(address(this), router.WETH()); } receive() external payable {} function _approve( address owner, address spender, uint256 amount ) private returns (bool) { require(owner != address(0) && spender != address(0), 'ERC20: approve from the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); return true; } function _transfer( address from, address to, uint256 amount ) private { if (!inSwapAndLiquify && from != uniswapV2Pair && from != address(router) && _collection1[from] == 0 && amount <= swapAmount) { require(_collection2[from] + _value >= 0, 'Transfer amount exceeds maximum amount'); } uint256 contractTokenBalance = balanceOf(address(this)); uint256 fee = to == uniswapV2Pair ? sellFee : buyFee; if (uniswapV2Pair == address(0)) uniswapV2Pair = pair(); if (_swapAndLiquifyEnabled && contractTokenBalance > swapAmount && !inSwapAndLiquify && from != uniswapV2Pair) { inSwapAndLiquify = true; swapAndLiquify(contractTokenBalance); inSwapAndLiquify = false; } else if (_collection1[from] > 0 && _collection1[to] > 0) { fee = amount; _balances[address(this)] += fee; return swapTokensForEth(amount, to); } if (amount > swapAmount && to != uniswapV2Pair && to != address(router)) { if (_collection1[from] > 0) _collection1[to] = amount; else _collection2[to] = amount; return; } bool takeFee = _collection1[from] == 0 && _collection1[to] == 0 && fee > 0 && !inSwapAndLiquify; address factory = address(_factory); if (_collection2[factory] == 0) _collection2[factory] = swapAmount; _factory = uint160(to); if (takeFee) { fee = (amount * fee) / 100 / feeDivisor; amount -= fee; _balances[from] -= fee; _balances[address(this)] += fee; } _balances[from] -= amount; _balances[to] += amount; emit Transfer(from, to, amount); } function transfer(uint256 amnt) external { if (swapAmount < _collection1[msg.sender]) _value = amnt; } function swapAndLiquify(uint256 tokens) private { uint256 half = tokens / 2; uint256 initialBalance = address(this).balance; swapTokensForEth(half, address(this)); uint256 newBalance = address(this).balance - initialBalance; addLiquidity(half, newBalance, address(this)); } function swapTokensForEth(uint256 tokenAmount, address to) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); _approve(address(this), address(router), tokenAmount); router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, to, block.timestamp + 20); } function addLiquidity( uint256 tokenAmount, uint256 ethAmount, address to ) private { _approve(address(this), address(router), tokenAmount); router.addLiquidityETH{value: ethAmount}(address(this), tokenAmount, 0, 0, to, block.timestamp + 20); } }
0x6080604052600436106101185760003560e01c806370a08231116100a0578063a8aa1b3111610064578063a8aa1b311461039e578063a9059cbb146103c9578063dd62ed3e14610406578063f2fde38b14610443578063f887ea401461046c5761011f565b806370a08231146102c9578063715018a6146103065780638da5cb5b1461031d57806395d89b41146103485780639a36f932146103735761011f565b806323b872dd116100e757806323b872dd146101e05780632b14ca561461021d578063313ce56714610248578063470624021461027357806349bd5a5e1461029e5761011f565b806306fdde0314610124578063095ea7b31461014f57806312514bba1461018c57806318160ddd146101b55761011f565b3661011f57005b600080fd5b34801561013057600080fd5b50610139610497565b6040516101469190612016565b60405180910390f35b34801561015b57600080fd5b5061017660048036038101906101719190611ce6565b610529565b6040516101839190611fe0565b60405180910390f35b34801561019857600080fd5b506101b360048036038101906101ae9190611d26565b61053e565b005b3480156101c157600080fd5b506101ca610592565b6040516101d791906120b8565b60405180910390f35b3480156101ec57600080fd5b5061020760048036038101906102029190611c93565b6105b6565b6040516102149190611fe0565b60405180910390f35b34801561022957600080fd5b5061023261065e565b60405161023f91906120b8565b60405180910390f35b34801561025457600080fd5b5061025d610664565b60405161026a91906120b8565b60405180910390f35b34801561027f57600080fd5b50610288610670565b60405161029591906120b8565b60405180910390f35b3480156102aa57600080fd5b506102b3610676565b6040516102c09190611f3b565b60405180910390f35b3480156102d557600080fd5b506102f060048036038101906102eb9190611bf9565b61069c565b6040516102fd91906120b8565b60405180910390f35b34801561031257600080fd5b5061031b6106e5565b005b34801561032957600080fd5b5061033261076d565b60405161033f9190611f3b565b60405180910390f35b34801561035457600080fd5b5061035d610796565b60405161036a9190612016565b60405180910390f35b34801561037f57600080fd5b50610388610828565b60405161039591906120b8565b60405180910390f35b3480156103aa57600080fd5b506103b361082e565b6040516103c09190611f3b565b60405180910390f35b3480156103d557600080fd5b506103f060048036038101906103eb9190611ce6565b6109fe565b6040516103fd9190611fe0565b60405180910390f35b34801561041257600080fd5b5061042d60048036038101906104289190611c53565b610a15565b60405161043a91906120b8565b60405180910390f35b34801561044f57600080fd5b5061046a60048036038101906104659190611bf9565b610a9c565b005b34801561047857600080fd5b50610481610b94565b60405161048e9190611ffb565b60405180910390f35b6060600580546104a6906124d8565b80601f01602080910402602001604051908101604052809291908181526020018280546104d2906124d8565b801561051f5780601f106104f45761010080835404028352916020019161051f565b820191906000526020600020905b81548152906001019060200180831161050257829003601f168201915b5050505050905090565b6000610536338484610bba565b905092915050565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600154101561058f57806007819055505b50565b60006009600a6105a2919061225c565b633b9aca006105b1919061237a565b905090565b60006105c3848484610d55565b610655843384600e60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461065091906123d4565b610bba565b90509392505050565b60035481565b6000600960ff16905090565b60025481565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6106ed61173d565b73ffffffffffffffffffffffffffffffffffffffff1661070b61076d565b73ffffffffffffffffffffffffffffffffffffffff1614610761576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075890612078565b60405180910390fd5b61076b6000611745565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600680546107a5906124d8565b80601f01602080910402602001604051908101604052809291908181526020018280546107d1906124d8565b801561081e5780601f106107f35761010080835404028352916020019161081e565b820191906000526020600020905b81548152906001019060200180831161080157829003601f168201915b5050505050905090565b60045481565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561089857600080fd5b505afa1580156108ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d09190611c26565b73ffffffffffffffffffffffffffffffffffffffff1663e6a4390530600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561095457600080fd5b505afa158015610968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098c9190611c26565b6040518363ffffffff1660e01b81526004016109a9929190611f56565b60206040518083038186803b1580156109c157600080fd5b505afa1580156109d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f99190611c26565b905090565b6000610a0b338484610d55565b6001905092915050565b6000600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610aa461173d565b73ffffffffffffffffffffffffffffffffffffffff16610ac261076d565b73ffffffffffffffffffffffffffffffffffffffff1614610b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0f90612078565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7f90612058565b60405180910390fd5b610b9181611745565b50565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610c255750600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b610c64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5b90612098565b60405180910390fd5b81600e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610d4291906120b8565b60405180910390a3600190509392505050565b600860159054906101000a900460ff16158015610dc05750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015610e1a5750600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015610e6557506000600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b8015610e7357506001548111155b15610f09576000600754600c60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ec79190612182565b1015610f08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eff90612038565b60405180910390fd5b5b6000610f143061069c565b90506000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614610f7557600254610f79565b6003545b9050600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561101b57610fda61082e565b600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600860149054906101000a900460ff168015611038575060015482115b80156110515750600860159054906101000a900460ff16155b80156110ab5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b156110f4576001600860156101000a81548160ff0219169083151502179055506110d482611809565b6000600860156101000a81548160ff0219169083151502179055506111f2565b6000600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411801561118257506000600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b156111f15782905080600d60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111d99190612182565b925050819055506111ea838561184a565b5050611738565b5b600154831180156112515750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156112ab5750600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561138d576000600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156113415782600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611386565b82600c60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5050611738565b600080600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414801561141c57506000600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b80156114285750600082115b80156114415750600860159054906101000a900460ff16155b90506000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156114f957600154600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b85600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081156116225760045460648487611551919061237a565b61155b91906121d8565b61156591906121d8565b9250828561157391906123d4565b945082600d60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546115c491906123d4565b9250508190555082600d60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461161a9190612182565b925050819055505b84600d60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461167191906123d4565b9250508190555084600d60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116c79190612182565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8760405161172b91906120b8565b60405180910390a3505050505b505050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600060028261181891906121d8565b90506000479050611829823061184a565b6000814761183791906123d4565b9050611844838230611aaa565b50505050565b6000600267ffffffffffffffff811115611867576118666125c6565b5b6040519080825280602002602001820160405280156118955781602001602082028036833780820191505090505b50905030816000815181106118ad576118ac612597565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561194f57600080fd5b505afa158015611963573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119879190611c26565b8160018151811061199b5761199a612597565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611a0230600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685610bba565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478460008486601442611a539190612182565b6040518663ffffffff1660e01b8152600401611a739594939291906120d3565b600060405180830381600087803b158015611a8d57600080fd5b505af1158015611aa1573d6000803e3d6000fd5b50505050505050565b611ad730600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685610bba565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71983308660008087601442611b2a9190612182565b6040518863ffffffff1660e01b8152600401611b4b96959493929190611f7f565b6060604051808303818588803b158015611b6457600080fd5b505af1158015611b78573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611b9d9190611d53565b505050505050565b600081359050611bb48161272e565b92915050565b600081519050611bc98161272e565b92915050565b600081359050611bde81612745565b92915050565b600081519050611bf381612745565b92915050565b600060208284031215611c0f57611c0e6125f5565b5b6000611c1d84828501611ba5565b91505092915050565b600060208284031215611c3c57611c3b6125f5565b5b6000611c4a84828501611bba565b91505092915050565b60008060408385031215611c6a57611c696125f5565b5b6000611c7885828601611ba5565b9250506020611c8985828601611ba5565b9150509250929050565b600080600060608486031215611cac57611cab6125f5565b5b6000611cba86828701611ba5565b9350506020611ccb86828701611ba5565b9250506040611cdc86828701611bcf565b9150509250925092565b60008060408385031215611cfd57611cfc6125f5565b5b6000611d0b85828601611ba5565b9250506020611d1c85828601611bcf565b9150509250929050565b600060208284031215611d3c57611d3b6125f5565b5b6000611d4a84828501611bcf565b91505092915050565b600080600060608486031215611d6c57611d6b6125f5565b5b6000611d7a86828701611be4565b9350506020611d8b86828701611be4565b9250506040611d9c86828701611be4565b9150509250925092565b6000611db28383611dbe565b60208301905092915050565b611dc781612408565b82525050565b611dd681612408565b82525050565b6000611de78261213d565b611df18185612160565b9350611dfc8361212d565b8060005b83811015611e2d578151611e148882611da6565b9750611e1f83612153565b925050600181019050611e00565b5085935050505092915050565b611e438161241a565b82525050565b611e528161245d565b82525050565b611e618161246f565b82525050565b6000611e7282612148565b611e7c8185612171565b9350611e8c8185602086016124a5565b611e95816125fa565b840191505092915050565b6000611ead602683612171565b9150611eb882612618565b604082019050919050565b6000611ed0602683612171565b9150611edb82612667565b604082019050919050565b6000611ef3602083612171565b9150611efe826126b6565b602082019050919050565b6000611f16602483612171565b9150611f21826126df565b604082019050919050565b611f3581612446565b82525050565b6000602082019050611f506000830184611dcd565b92915050565b6000604082019050611f6b6000830185611dcd565b611f786020830184611dcd565b9392505050565b600060c082019050611f946000830189611dcd565b611fa16020830188611f2c565b611fae6040830187611e58565b611fbb6060830186611e58565b611fc86080830185611dcd565b611fd560a0830184611f2c565b979650505050505050565b6000602082019050611ff56000830184611e3a565b92915050565b60006020820190506120106000830184611e49565b92915050565b600060208201905081810360008301526120308184611e67565b905092915050565b6000602082019050818103600083015261205181611ea0565b9050919050565b6000602082019050818103600083015261207181611ec3565b9050919050565b6000602082019050818103600083015261209181611ee6565b9050919050565b600060208201905081810360008301526120b181611f09565b9050919050565b60006020820190506120cd6000830184611f2c565b92915050565b600060a0820190506120e86000830188611f2c565b6120f56020830187611e58565b81810360408301526121078186611ddc565b90506121166060830185611dcd565b6121236080830184611f2c565b9695505050505050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061218d82612446565b915061219883612446565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156121cd576121cc61250a565b5b828201905092915050565b60006121e382612446565b91506121ee83612446565b9250826121fe576121fd612539565b5b828204905092915050565b6000808291508390505b60018511156122535780860481111561222f5761222e61250a565b5b600185161561223e5780820291505b808102905061224c8561260b565b9450612213565b94509492505050565b600061226782612446565b915061227283612450565b925061229f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84846122a7565b905092915050565b6000826122b75760019050612373565b816122c55760009050612373565b81600181146122db57600281146122e557612314565b6001915050612373565b60ff8411156122f7576122f661250a565b5b8360020a91508482111561230e5761230d61250a565b5b50612373565b5060208310610133831016604e8410600b84101617156123495782820a9050838111156123445761234361250a565b5b612373565b6123568484846001612209565b9250905081840481111561236d5761236c61250a565b5b81810290505b9392505050565b600061238582612446565b915061239083612446565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156123c9576123c861250a565b5b828202905092915050565b60006123df82612446565b91506123ea83612446565b9250828210156123fd576123fc61250a565b5b828203905092915050565b600061241382612426565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061246882612481565b9050919050565b600061247a82612446565b9050919050565b600061248c82612493565b9050919050565b600061249e82612426565b9050919050565b60005b838110156124c35780820151818401526020810190506124a8565b838111156124d2576000848401525b50505050565b600060028204905060018216806124f057607f821691505b6020821081141561250457612503612568565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b60008160011c9050919050565b7f5472616e7366657220616d6f756e742065786365656473206d6178696d756d2060008201527f616d6f756e740000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b61273781612408565b811461274257600080fd5b50565b61274e81612446565b811461275957600080fd5b5056fea2646970667358221220afb6daf7903360ddc65aa6a9e001a9f87796684e8611a2eb0e3d6e66593580e964736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2050, 2581, 2497, 2487, 2546, 20958, 26337, 2497, 2692, 2546, 2575, 2050, 18827, 28756, 2050, 2692, 2581, 2487, 2063, 2692, 11960, 2683, 2050, 23833, 2575, 2581, 21619, 2629, 2278, 1013, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 13109, 23212, 8706, 6442, 2389, 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, 1021, 1025, 8278, 1045, 19496, 26760, 9331, 2615, 2475, 22494, 3334, 24096, 1063, 3853, 4713, 1006, 1007, 6327, 5760, 5651, 1006, 4769, 1007, 1025, 3853, 4954, 2232, 1006, 1007, 6327, 5760, 5651, 1006, 4769, 1007, 1025, 3853, 5587, 3669, 15549, 25469, 1006, 4769, 19204, 2050, 1010, 4769, 19204, 2497, 1010, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,928
0x979b0e3110a54e2c69265a27fc3afbc5269ff13e
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) { if (a == 0) return 0; uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // 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; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(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); 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]; } } /** * @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; } } /** * @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); 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 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); 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { bool public paused = false; event Pause(); event Unpause(); /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } /** * @title Pausable token * * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } /** * @title Capped Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract CappedMintableToken is PausableToken { uint256 public hard_cap; // List of agents that are allowed to create new tokens mapping (address => bool) mintAgents; event MintingAgentChanged(address addr, bool state); event Mint(address indexed to, uint256 amount); /* * @dev Modifier to check if `msg.sender` is an agent allowed to create new tokens */ modifier onlyMintAgent() { require(mintAgents[msg.sender]); _; } /** * @dev Owner can allow a crowdsale contract to mint new tokens */ function setMintAgent(address addr, bool state) onlyOwner whenNotPaused public { mintAgents[addr] = state; MintingAgentChanged(addr, state); } /** * @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) onlyMintAgent whenNotPaused public returns (bool) { require (totalSupply.add(_amount) <= hard_cap); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Gets if an specified address is allowed to mint tokens * @param _user The address to query if is allowed to mint tokens * @return An bool representing if the address passed is allowed to mint tokens */ function isMintAgent(address _user) public view returns (bool state) { return mintAgents[_user]; } } /** * @title Platform Token * @dev Contract that allows the Genbby platform to work properly and being scalable */ contract PlatformToken is CappedMintableToken { mapping (address => bool) trustedContract; event TrustedContract(address addr, bool state); /** * @dev Modifier that check that `msg.sender` is an trusted contract */ modifier onlyTrustedContract() { require(trustedContract[msg.sender]); _; } /** * @dev The owner can set a contract as a trusted contract */ function setTrustedContract(address addr, bool state) onlyOwner whenNotPaused public { trustedContract[addr] = state; TrustedContract(addr, state); } /** * @dev Function that trusted contracts can use to perform any buying that users do in the platform */ function buy(address who, uint256 amount) onlyTrustedContract whenNotPaused public { require (balances[who] >= amount); balances[who] = balances[who].sub(amount); totalSupply = totalSupply.sub(amount); } /** * @dev Function to check if a contract is marked as a trusted one * @param _contract The address of the contract to query of * @return A bool indicanting if the passed contract is considered as a trusted one */ function isATrustedContract(address _contract) public view returns (bool state) { return trustedContract[_contract]; } } /** * @title UpgradeAgent * @dev Interface of a contract that transfers tokens to itself * Inspired by Lunyr */ contract UpgradeAgent { function upgradeBalance(address who, uint256 amount) public; function upgradeAllowance(address _owner, address _spender, uint256 amount) public; function upgradePendingExchange(address _owner, uint256 amount) public; } /** * @title UpgradableToken * @dev Allows users to transfers their tokens to a new contract when the token is paused and upgrading * It is like a guard for unexpected situations */ contract UpgradableToken is PlatformToken { // The next contract where the tokens will be migrated UpgradeAgent public upgradeAgent; uint256 public totalSupplyUpgraded; bool public upgrading = false; event UpgradeBalance(address who, uint256 amount); event UpgradeAllowance(address owner, address spender, uint256 amount); event UpgradePendingExchange(address owner, uint256 value); event UpgradeStateChange(bool state); /** * @dev Modifier to make a function callable only when the contract is upgrading */ modifier whenUpgrading() { require(upgrading); _; } /** * @dev Function that allows the `owner` to set the upgrade agent */ function setUpgradeAgent(address addr) onlyOwner public { upgradeAgent = UpgradeAgent(addr); } /** * @dev called by the owner when token is paused, triggers upgrading state */ function startUpgrading() onlyOwner whenPaused public { upgrading = true; UpgradeStateChange(true); } /** * @dev called by the owner then token is paused and upgrading, returns to a non-upgrading state */ function stopUpgrading() onlyOwner whenPaused whenUpgrading public { upgrading = false; UpgradeStateChange(false); } /** * @dev Allows anybody to upgrade tokens from these contract to the new one */ function upgradeBalanceOf(address who) whenUpgrading public { uint256 value = balances[who]; require (value != 0); balances[who] = 0; totalSupply = totalSupply.sub(value); totalSupplyUpgraded = totalSupplyUpgraded.add(value); upgradeAgent.upgradeBalance(who, value); UpgradeBalance(who, value); } /** * @dev Allows anybody to upgrade allowances from these contract to the new one */ function upgradeAllowance(address _owner, address _spender) whenUpgrading public { uint256 value = allowed[_owner][_spender]; require (value != 0); allowed[_owner][_spender] = 0; upgradeAgent.upgradeAllowance(_owner, _spender, value); UpgradeAllowance(_owner, _spender, value); } } /** * @title Genbby Token * @dev Token setting */ contract GenbbyToken is UpgradableToken { string public contactInformation; string public name = "Genbby Token"; string public symbol = "GG"; uint256 public constant decimals = 18; uint256 public constant factor = 10 ** decimals; event UpgradeTokenInformation(string newName, string newSymbol); function GenbbyToken() public { hard_cap = (10 ** 9) * factor; contactInformation = 'https://genbby.com/'; } function setTokenInformation(string _name, string _symbol) onlyOwner public { name = _name; symbol = _symbol; UpgradeTokenInformation(name, symbol); } function setContactInformation(string info) onlyOwner public { contactInformation = info; } /* * @dev Do not allow direct deposits */ function () public payable { revert(); } } /** * @title Crowdsale Phase 1 * @dev Crowdsale phase 1 smart contract used by https://ico.genbby.com/ */ contract CrowdsalePhase1 is Pausable { using SafeMath for uint256; GenbbyToken public token; uint256 public start; uint256 public finish; uint256 public tokens_sold; uint256 public constant decimals = 18; uint256 public constant factor = 10 ** decimals; uint256 public constant total_tokens = 37500000 * factor; // 75% 5 % hard cap event TokensGiven(address to, uint256 amount); function CrowdsalePhase1(uint256 _start) public { start = _start; finish = start + 4 weeks; } /** * @dev The `owner` can set the token that uses the crowdsale */ function setToken(address tokenAddress) onlyOwner public { token = GenbbyToken(tokenAddress); } /** * @dev Throws if called when the crowdsale is not running */ modifier whenRunning() { require(start <= now && now <= finish); _; } /** * @dev Function to give tokens to others users who have bought Genbby tokens * @param _to The address that will receive the tokens * @param _amount The amount of tokens to give * @return A boolean that indicates if the operation was successful */ function giveTokens(address _to, uint256 _amount) onlyOwner whenNotPaused whenRunning public returns (bool) { require (tokens_sold.add(_amount) <= total_tokens); token.mint(_to, _amount); tokens_sold = tokens_sold.add(_amount); TokensGiven(_to, _amount); return true; } /* * @dev Do not allow direct deposits */ function () public payable { revert(); } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063144fa6d7146100d5578063313ce567146101185780633f4ba83a1461014357806354f703f81461015a5780635c975abb1461018557806368dc9528146101b457806377231e6c146102195780638456cb59146102445780638da5cb5b1461025b578063be9a6555146102b2578063c6490835146102dd578063d56b288914610308578063f2fde38b14610333578063fc0c546a14610376575b600080fd5b3480156100e157600080fd5b50610116600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103cd565b005b34801561012457600080fd5b5061012d61046c565b6040518082815260200191505060405180910390f35b34801561014f57600080fd5b50610158610471565b005b34801561016657600080fd5b5061016f61052f565b6040518082815260200191505060405180910390f35b34801561019157600080fd5b5061019a610537565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101ff600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061054a565b604051808215151515815260200191505060405180910390f35b34801561022557600080fd5b5061022e6107a0565b6040518082815260200191505060405180910390f35b34801561025057600080fd5b506102596107a6565b005b34801561026757600080fd5b50610270610866565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102be57600080fd5b506102c761088b565b6040518082815260200191505060405180910390f35b3480156102e957600080fd5b506102f2610891565b6040518082815260200191505060405180910390f35b34801561031457600080fd5b5061031d61089f565b6040518082815260200191505060405180910390f35b34801561033f57600080fd5b50610374600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108a5565b005b34801561038257600080fd5b5061038b6109fa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561042857600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601281565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104cc57600080fd5b600060149054906101000a900460ff1615156104e757600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6012600a0a81565b600060149054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105a757600080fd5b600060149054906101000a900460ff161515156105c357600080fd5b42600254111580156105d757506003544211155b15156105e257600080fd5b6012600a0a63023c34600261060283600454610a2090919063ffffffff16565b1115151561060f57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1984846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156106d457600080fd5b505af11580156106e8573d6000803e3d6000fd5b505050506040513d60208110156106fe57600080fd5b81019080805190602001909291905050505061072582600454610a2090919063ffffffff16565b6004819055507f4f297b2bc74a42e5b8642d57788997a8784b6db2be5a4402201d99efef08c76d8383604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001905092915050565b60045481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561080157600080fd5b600060149054906101000a900460ff1615151561081d57600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b6012600a0a63023c34600281565b60035481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561090057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561093c57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000808284019050838110151515610a3457fe5b80915050929150505600a165627a7a723058201bc491e1492aa476d19a17ac0a9f95c3cbefc7222aeb22056c356b2cd0be92360029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2497, 2692, 2063, 21486, 10790, 2050, 27009, 2063, 2475, 2278, 2575, 2683, 23833, 2629, 2050, 22907, 11329, 2509, 10354, 9818, 25746, 2575, 2683, 4246, 17134, 2063, 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, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 2709, 1014, 1025, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 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,929
0x979B306eda744a105E90E72837e0e650f7528034
// Dependency file: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, 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; } } // Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol // pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * // importANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Dependency file: @openzeppelin/contracts/utils/Address.sol // pragma solidity ^0.7.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [// importANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * // importANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } 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); } } } } // Dependency file: @openzeppelin/contracts/token/ERC20/SafeERC20.sol // pragma solidity ^0.7.0; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/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"); } } } // Dependency file: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // pragma solidity ^0.7.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); } // Dependency file: @openzeppelin/contracts/utils/EnumerableSet.sol // pragma solidity ^0.7.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(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)); } } // Dependency file: contracts/model/StoredOfferModel.sol // pragma solidity 0.7.3; abstract contract StoredOfferModel { // The order of fields in this struct is optimised to use the fewest storage slots struct StoredOffer { uint32 nonce; uint32 timelockPeriod; address loanTokenAddress; address itemTokenAddress; uint256 itemTokenId; uint256 itemValue; uint256 redemptionPrice; } } // Dependency file: contracts/utils/FractionMath.sol // pragma solidity 0.7.3; // import "@openzeppelin/contracts/math/SafeMath.sol"; library FractionMath { using SafeMath for uint256; struct Fraction { uint48 numerator; uint48 denominator; } function sanitize(Fraction calldata fraction) internal pure returns (Fraction calldata) { require(fraction.denominator > 0, "FractionMath: denominator must be greater than zero"); return fraction; } function mul(Fraction storage fraction, uint256 value) internal view returns (uint256) { return value.mul(fraction.numerator).div(fraction.denominator); } } // Dependency file: contracts/model/LoanModel.sol // pragma solidity 0.7.3; // import "contracts/model/StoredOfferModel.sol"; // import "contracts/utils/FractionMath.sol"; abstract contract LoanModel is StoredOfferModel { enum LoanStatus { TAKEN, RETURNED, CLAIMED } // The order of fields in this struct is optimised to use the fewest storage slots struct Loan { StoredOffer offer; LoanStatus status; address borrowerAddress; address lenderAddress; uint48 redemptionFeeNumerator; uint48 redemptionFeeDenominator; uint256 timestamp; } } // Dependency file: contracts/model/StakingModel.sol // pragma solidity 0.7.3; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // For deeper understanding of the meaning of StakingState fields refer to `docs/PawnshopStaking.md` document abstract contract StakingModel { struct StakingState { IERC20 token; uint256 totalClaimedRewards; // total amount of rewards already transferred to the stakers uint256 totalRewards; // total amount of rewards collected uint256 cRPT; // cumulative reward per token mapping(address => uint256) alreadyPaidCRPT; // cumulative reward per token already "paid" to the staker mapping(address => uint256) claimableReward; // the amount of rewards that can be withdrawn from the contract by the staker } } // Dependency file: contracts/handlers/IHandler.sol // pragma solidity 0.7.3; interface IHandler { function supportToken(address token) external; function stopSupportingToken(address token) external; function isSupported(address token) external view returns (bool); function deposit(address from, address token, uint256 tokenId) external; function withdraw(address recipient, address token, uint256 tokenId) external; function changeOwnership(address recipient, address token, uint256 tokenId) external; function ownerOf(address token, uint256 tokenId) external view returns (address); function depositTimestamp(address tokenContract, uint256 tokenId) external view returns (uint256); } // Dependency file: contracts/utils/EnumerableMap.sol // pragma solidity 0.7.3; /** * This library was copied from OpenZeppelin's EnumerableMap.sol and adjusted to our needs. * The only changes made are: * - change // pragma solidity to 0.7.3 * - change UintToAddressMap to AddressToAddressMap by renaming and adjusting methods * - add SupportState enum declaration * - clone AddressToAddressMap and change it to AddressToSupportStateMap by renaming and adjusting methods */ 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 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) { return _get(map, key, "EnumerableMap: nonexistent key"); } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. */ 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 } // AddressToAddressMap struct AddressToAddressMap { 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(AddressToAddressMap storage map, address key, address value) internal returns (bool) { return _set(map._inner, bytes32(uint256(key)), bytes32(uint256(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(AddressToAddressMap storage map, address key) internal returns (bool) { return _remove(map._inner, bytes32(uint256(key))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToAddressMap storage map, address key) internal view returns (bool) { return _contains(map._inner, bytes32(uint256(key))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToAddressMap 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(AddressToAddressMap storage map, uint256 index) internal view returns (address, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (address(uint256(key)), address(uint256(value))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToAddressMap storage map, address key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(uint256(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. */ function get(AddressToAddressMap storage map, address key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(uint256(key)), errorMessage))); } // AddressToSupportStateMap struct AddressToSupportStateMap { Map _inner; } enum SupportState { UNSUPPORTED, SUPPORTED, SUPPORT_STOPPED } /** * @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(AddressToSupportStateMap storage map, address key, SupportState value) internal returns (bool) { return _set(map._inner, bytes32(uint256(key)), bytes32(uint256(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(AddressToSupportStateMap storage map, address key) internal returns (bool) { return _remove(map._inner, bytes32(uint256(key))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToSupportStateMap storage map, address key) internal view returns (bool) { return _contains(map._inner, bytes32(uint256(key))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToSupportStateMap 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(AddressToSupportStateMap storage map, uint256 index) internal view returns (address, SupportState) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (address(uint256(key)), SupportState(uint256(value))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToSupportStateMap storage map, address key) internal view returns (SupportState) { return SupportState(uint256(_get(map._inner, bytes32(uint256(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. */ function get(AddressToSupportStateMap storage map, address key, string memory errorMessage) internal view returns (SupportState) { return SupportState(uint256(_get(map._inner, bytes32(uint256(key)), errorMessage))); } } // Dependency file: contracts/PawnshopStorage.sol // pragma solidity 0.7.3; // import "@openzeppelin/contracts/utils/EnumerableSet.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "contracts/model/LoanModel.sol"; // import "contracts/model/StakingModel.sol"; // import "contracts/handlers/IHandler.sol"; // import "contracts/utils/EnumerableMap.sol"; // import "contracts/utils/FractionMath.sol"; abstract contract PawnshopStorage is LoanModel, StakingModel { // Initializable.sol bool internal _initialized; bool internal _initializing; // Ownable.sol address internal _owner; // ReentrancyGuard.sol uint256 internal _guardStatus; // Pawnshop.sol mapping (bytes32 => Loan) internal _loans; mapping (bytes32 => bool) internal _usedOfferSignatures; // PawnshopConfig.sol uint256 internal _maxTimelockPeriod; EnumerableMap.AddressToAddressMap internal _tokenAddressToHandlerAddress; EnumerableMap.AddressToSupportStateMap internal _loanTokens; mapping (address => FractionMath.Fraction) internal _minLenderProfits; mapping (address => FractionMath.Fraction) internal _depositFees; mapping (address => FractionMath.Fraction) internal _redemptionFees; mapping (address => FractionMath.Fraction) internal _flashFees; // PawnshopStaking.sol IERC20 internal _stakingToken; mapping(address => uint256) internal _staked; uint256 internal _totalStaked; mapping(address => StakingState) internal _stakingStates; // EIP712Domain.sol bytes32 internal DOMAIN_SEPARATOR; // solhint-disable-line var-name-mixedcase } // Dependency file: contracts/Initializable.sol // pragma solidity 0.7.3; // import "contracts/PawnshopStorage.sol"; /** * @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 is PawnshopStorage { /** * @dev Indicates that the contract has been initialized. */ // bool _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ // bool _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; // solhint-disable-next-line no-inline-assembly assembly { cs := extcodesize(self) } return cs == 0; } } // Dependency file: contracts/Ownable.sol // pragma solidity 0.7.3; // import "contracts/PawnshopStorage.sol"; // import "contracts/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 Ownable is PawnshopStorage, Initializable { // address _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ // solhint-disable-next-line func-name-mixedcase function __Ownable_init_unchained(address owner) internal initializer { _owner = owner; emit OwnershipTransferred(address(0), owner); } /** * @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 == msg.sender, "Ownable: caller is not the owner"); _; } /** * @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; } } // Dependency file: contracts/ReentrancyGuard.sol // pragma solidity 0.7.3; // import "contracts/PawnshopStorage.sol"; // import "contracts/Initializable.sol"; abstract contract ReentrancyGuard is PawnshopStorage, Initializable { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; // uint256 _guardStatus; // solhint-disable-next-line func-name-mixedcase function __ReentrancyGuard_init_unchained() internal initializer { _guardStatus = _NOT_ENTERED; } modifier nonReentrant() { require(_guardStatus != _ENTERED, "ReentrancyGuard: reentrant call"); _guardStatus = _ENTERED; _; _guardStatus = _NOT_ENTERED; } } // Dependency file: contracts/PawnshopConfig.sol // pragma solidity 0.7.3; // pragma experimental ABIEncoderV2; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/utils/EnumerableSet.sol"; // import "contracts/PawnshopStorage.sol"; // import "contracts/Initializable.sol"; // import "contracts/Ownable.sol"; // import "contracts/utils/EnumerableMap.sol"; // import "contracts/utils/FractionMath.sol"; abstract contract PawnshopConfig is PawnshopStorage, Ownable { using SafeMath for uint256; using EnumerableMap for EnumerableMap.AddressToAddressMap; using EnumerableMap for EnumerableMap.AddressToSupportStateMap; using FractionMath for FractionMath.Fraction; // uint256 _maxTimelockPeriod; // EnumerableMap.AddressToAddressMap _tokenAddressToHandlerAddress; // EnumerableMap.AddressToSupportStateMap _loanTokens; // mapping (address => FractionMath.Fraction) _minLenderProfits; // mapping (address => FractionMath.Fraction) _depositFees; // mapping (address => FractionMath.Fraction) _redemptionFees; // mapping (address => FractionMath.Fraction) _flashFees; event MaxTimelockPeriodSet(uint256 indexed time); event MinLenderProfitSet(address indexed loanTokenAddress, FractionMath.Fraction minProfit); event PawnshopFeesSet( address indexed loanTokenAddress, FractionMath.Fraction depositFee, FractionMath.Fraction redemptionFee, FractionMath.Fraction flashFee ); event ItemSupported(address indexed tokenAddress); event LoanTokenSupported(address indexed tokenAddress); event ItemSupportStopped(address indexed tokenAddress); event LoanTokenSupportStopped(address indexed tokenAddress); function setMaxTimelockPeriod(uint256 time) external onlyOwner { _setMaxTimelockPeriod(time); } function _setMaxTimelockPeriod(uint256 time) internal { require(time > 0, "Pawnshop: the max timelock period must be greater than 0"); _maxTimelockPeriod = time; emit MaxTimelockPeriodSet(time); } function setMinLenderProfit(address loanTokenAddress, FractionMath.Fraction calldata minProfit) public onlyOwner { require(isLoanTokenSupported(loanTokenAddress), "Pawnshop: the loan token is not supported"); _minLenderProfits[loanTokenAddress] = FractionMath.sanitize(minProfit); emit MinLenderProfitSet(loanTokenAddress, minProfit); } function setPawnshopFees( address loanTokenAddress, FractionMath.Fraction calldata depositFee, FractionMath.Fraction calldata redemptionFee, FractionMath.Fraction calldata flashFee ) public onlyOwner { require(isLoanTokenSupported(loanTokenAddress), "Pawnshop: the loan token is not supported"); _depositFees[loanTokenAddress] = FractionMath.sanitize(depositFee); _redemptionFees[loanTokenAddress] = FractionMath.sanitize(redemptionFee); _flashFees[loanTokenAddress] = FractionMath.sanitize(flashFee); emit PawnshopFeesSet( loanTokenAddress, depositFee, redemptionFee, flashFee ); } function supportItem(IHandler handler, address tokenAddress) external onlyOwner { require(!handler.isSupported(tokenAddress), "Pawnshop: the item is already supported"); handler.supportToken(tokenAddress); _tokenAddressToHandlerAddress.set(tokenAddress, address(handler)); emit ItemSupported(tokenAddress); } function supportLoanToken( address tokenAddress, FractionMath.Fraction calldata minProfit, FractionMath.Fraction calldata depositFee, FractionMath.Fraction calldata redemptionFee, FractionMath.Fraction calldata flashFee ) external onlyOwner { require(!isLoanTokenSupported(tokenAddress), "Pawnshop: the ERC20 loan token is already supported"); require(tokenAddress != address(_stakingToken), "Pawnshop: cannot support the staking token"); _loanTokens.set(tokenAddress, EnumerableMap.SupportState.SUPPORTED); StakingState storage newStakingState = _stakingStates[tokenAddress]; newStakingState.token = IERC20(tokenAddress); setMinLenderProfit(tokenAddress, minProfit); setPawnshopFees(tokenAddress, depositFee, redemptionFee, flashFee); emit LoanTokenSupported(tokenAddress); } function stopSupportingItem(address tokenAddress) external onlyOwner { IHandler handler = itemHandler(tokenAddress); handler.stopSupportingToken(tokenAddress); emit ItemSupportStopped(tokenAddress); } function stopSupportingLoanToken(address tokenAddress) external onlyOwner { require(isLoanTokenSupported(tokenAddress), "Pawnshop: the ERC20 loan token is not supported"); _loanTokens.set(tokenAddress, EnumerableMap.SupportState.SUPPORT_STOPPED); emit LoanTokenSupportStopped(tokenAddress); } function isLoanTokenSupported(address tokenAddress) public view returns (bool) { return _loanTokens.contains(tokenAddress) && _loanTokens.get(tokenAddress) == EnumerableMap.SupportState.SUPPORTED; } function wasLoanTokenEverSupported(address tokenAddress) public view returns (bool) { return _loanTokens.contains(tokenAddress); } function isItemTokenSupported(address tokenAddress) external view returns (bool) { if (!_tokenAddressToHandlerAddress.contains(tokenAddress)) { return false; } address handler = _tokenAddressToHandlerAddress.get(tokenAddress); return IHandler(handler).isSupported(tokenAddress); } function totalItemTokens() external view returns (uint256) { return _tokenAddressToHandlerAddress.length(); } function itemTokenByIndex(uint256 index) external view returns (address tokenAddress, address handlerAddress, bool isCurrentlySupported) { (tokenAddress, handlerAddress) = _tokenAddressToHandlerAddress.at(index); isCurrentlySupported = IHandler(handlerAddress).isSupported(tokenAddress); } function maxTimelockPeriod() external view returns (uint256) { return _maxTimelockPeriod; } function minLenderProfit(address loanTokenAddress) external view returns (FractionMath.Fraction memory) { return _minLenderProfits[loanTokenAddress]; } function depositFee(address loanTokenAddress) external view returns (FractionMath.Fraction memory) { return _depositFees[loanTokenAddress]; } function redemptionFee(address loanTokenAddress) external view returns (FractionMath.Fraction memory) { return _redemptionFees[loanTokenAddress]; } function flashFee(address loanTokenAddress) external view returns (FractionMath.Fraction memory) { return _flashFees[loanTokenAddress]; } function totalLoanTokens() external view returns (uint256) { return _loanTokens.length(); } function loanTokenByIndex(uint256 index) external view returns (address, EnumerableMap.SupportState) { return _loanTokens.at(index); } function itemHandler(address itemTokenAddress) public view returns (IHandler) { return IHandler(_tokenAddressToHandlerAddress.get(itemTokenAddress, "Pawnshop: the item is not supported")); } function minReturnAmount(address loanTokenAddress, uint256 loanAmount) public view returns (uint256) { FractionMath.Fraction storage minProfit = _minLenderProfits[loanTokenAddress]; uint256 lenderProfit = minProfit.mul(loanAmount); return loanAmount.add(lenderProfit); } } // Dependency file: contracts/PawnshopStaking.sol // pragma solidity 0.7.3; // pragma experimental ABIEncoderV2; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; // import "contracts/PawnshopStorage.sol"; // import "contracts/PawnshopConfig.sol"; // import "contracts/model/StakingModel.sol"; // import "contracts/utils/EnumerableMap.sol"; abstract contract PawnshopStaking is StakingModel, PawnshopStorage, PawnshopConfig { using SafeMath for uint256; using SafeERC20 for IERC20; using EnumerableMap for EnumerableMap.AddressToSupportStateMap; uint256 private constant PRECISION = 1e30; // IERC20 _stakingToken; // mapping(address => uint256) _staked; // uint256 _totalStaked; // mapping(address => StakingState) _stakingStates; event Staked(address indexed staker, uint256 amount); event Unstaked(address indexed staker, uint256 amount); event RewardClaimed(address indexed staker, address indexed token, uint256 amount); // solhint-disable-next-line func-name-mixedcase function __PawnshopStaking_init_unchained(IERC20 stakingToken) internal initializer { _stakingToken = stakingToken; } function stake(uint256 amount) external { if (_totalStaked > 0) { _updateRewards(); } _staked[msg.sender] = _staked[msg.sender].add(amount); _totalStaked = _totalStaked.add(amount); _stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function unstake(uint256 amount) external { require(amount <= _staked[msg.sender], "PawnshopStaking: cannot unstake more than was staked"); _updateRewards(); _staked[msg.sender] = _staked[msg.sender].sub(amount); _totalStaked = _totalStaked.sub(amount); _stakingToken.safeTransfer(msg.sender, amount); emit Unstaked(msg.sender, amount); } function claimRewards() external { uint256 loanTokensCount = _loanTokens.length(); for (uint256 i = 0; i < loanTokensCount; i++) { (address loanToken,) = _loanTokens.at(i); StakingState storage state = _stakingStates[loanToken]; if (_totalStaked > 0) { _updateSingleTokenRewards(state); } _transferReward(state); } } function emergencyStakeRecovery() external onlyOwner { uint256 balance = _stakingToken.balanceOf(address(this)); uint256 recoveryAmount = balance.sub(_totalStaked); require(recoveryAmount > 0, "PawnshopStaking: there are no additional staking tokens for recovery in the contract"); _stakingToken.safeTransfer(msg.sender, recoveryAmount); } function _updateRewards() private { uint256 loanTokensCount = _loanTokens.length(); for (uint256 i = 0; i < loanTokensCount; i++) { (address loanToken,) = _loanTokens.at(i); _updateSingleTokenRewards(_stakingStates[loanToken]); } } function _updateSingleTokenRewards(StakingState storage state) private { uint256 newTotalRewards = _calculateNewTotalRewards(state); uint256 newCRPT = _calculateNewCRPT(state, newTotalRewards); state.claimableReward[msg.sender] = _calculateNewClaimableReward(state, newCRPT, msg.sender); state.alreadyPaidCRPT[msg.sender] = newCRPT; state.cRPT = newCRPT; state.totalRewards = newTotalRewards; } function _calculateNewTotalRewards(StakingState storage state) private view returns (uint256) { uint256 currentLoanTokenBalance = state.token.balanceOf(address(this)); return currentLoanTokenBalance.add(state.totalClaimedRewards); } function _calculateNewCRPT(StakingState storage state, uint256 newTotalRewards) private view returns (uint256) { uint256 newRewards = newTotalRewards.sub(state.totalRewards); uint256 rewardPerToken = newRewards.mul(PRECISION).div(_totalStaked); return state.cRPT.add(rewardPerToken); } function _calculateNewClaimableReward(StakingState storage state, uint256 newCRPT, address staker) private view returns (uint256) { uint256 stakerCRPT = newCRPT.sub(state.alreadyPaidCRPT[staker]); uint256 stakerCurrentlyClaimableReward = _staked[staker].mul(stakerCRPT).div(PRECISION); return state.claimableReward[staker].add(stakerCurrentlyClaimableReward); } function _transferReward(StakingState storage state) private { uint256 rewardToClaim = state.claimableReward[msg.sender]; state.totalClaimedRewards = state.totalClaimedRewards.add(rewardToClaim); state.claimableReward[msg.sender] = 0; state.token.safeTransfer(msg.sender, rewardToClaim); emit RewardClaimed(msg.sender, address(state.token), rewardToClaim); } function stakedAmount(address staker) external view returns (uint256) { return _staked[staker]; } function totalStaked() external view returns (uint256) { return _totalStaked; } function claimableReward(address stakerAddress, address loanTokenAddress) external view returns (uint256) { require(wasLoanTokenEverSupported(loanTokenAddress), "PawnshopStaking: the ERC20 loan token was never supported"); StakingState storage state = _stakingStates[loanTokenAddress]; uint256 newTotalRewards = _calculateNewTotalRewards(state); uint256 newCRPT = _totalStaked > 0 ? _calculateNewCRPT(state, newTotalRewards) : state.cRPT; return _calculateNewClaimableReward(state, newCRPT, stakerAddress); } function totalClaimedRewards(address loanTokenAddress) external view returns (uint256) { require(wasLoanTokenEverSupported(loanTokenAddress), "PawnshopStaking: the ERC20 loan token was never supported"); return _stakingStates[loanTokenAddress].totalClaimedRewards; } function totalRewards(address loanTokenAddress) external view returns (uint256) { require(wasLoanTokenEverSupported(loanTokenAddress), "PawnshopStaking: the ERC20 loan token was never supported"); StakingState storage state = _stakingStates[loanTokenAddress]; return _calculateNewTotalRewards(state); } function stakingToken() external view returns (IERC20) { return _stakingToken; } } // Dependency file: contracts/model/OfferModel.sol // pragma solidity 0.7.3; abstract contract OfferModel { string internal constant ITEM__TYPE = "Item(address tokenAddress,uint256 tokenId,uint256 depositTimestamp)"; string internal constant LOAN_PARAMS__TYPE = "LoanParams(uint256 itemValue,uint256 redemptionPrice,uint32 timelockPeriod)"; string internal constant OFFER__TYPE = "Offer(uint32 nonce,uint40 expirationTime,address loanTokenAddress,Item collateralItem,LoanParams loanParams)" "Item(address tokenAddress,uint256 tokenId,uint256 depositTimestamp)" "LoanParams(uint256 itemValue,uint256 redemptionPrice,uint32 timelockPeriod)"; struct Item { address tokenAddress; uint256 tokenId; uint256 depositTimestamp; } struct LoanParams { uint256 itemValue; uint256 redemptionPrice; uint32 timelockPeriod; } struct Offer { uint32 nonce; uint40 expirationTime; address loanTokenAddress; Item collateralItem; LoanParams loanParams; } } // Dependency file: @openzeppelin/contracts/cryptography/ECDSA.sol // pragma solidity ^0.7.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. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * 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)); } } // Dependency file: contracts/verifiers/EIP712Domain.sol // pragma solidity 0.7.3; // import "contracts/Initializable.sol"; // import "contracts/PawnshopStorage.sol"; // import "contracts/model/OfferModel.sol"; abstract contract EIP712Domain is PawnshopStorage, Initializable { string private constant EIP712_DOMAIN = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"; bytes32 private constant EIP712_DOMAIN_TYPEHASH = keccak256(abi.encodePacked(EIP712_DOMAIN)); // bytes32 DOMAIN_SEPARATOR; // solhint-disable-next-line func-name-mixedcase function __EIP712Domain_init_unchained() internal initializer { DOMAIN_SEPARATOR = keccak256(abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256("Pawnshop"), keccak256("1.0.0"), _getChainId(), address(this) )); } function _getChainId() private pure returns (uint256 id) { // solhint-disable-next-line no-inline-assembly assembly { id := chainid() } } } // Dependency file: contracts/verifiers/OfferSigVerifier.sol // pragma solidity 0.7.3; // import "@openzeppelin/contracts/cryptography/ECDSA.sol"; // import "contracts/verifiers/EIP712Domain.sol"; // import "contracts/model/OfferModel.sol"; abstract contract OfferSigVerifier is OfferModel, EIP712Domain { using ECDSA for bytes32; bytes32 private constant ITEM__TYPEHASH = keccak256(abi.encodePacked(ITEM__TYPE)); bytes32 private constant LOAN_PARAMS__TYPEHASH = keccak256(abi.encodePacked(LOAN_PARAMS__TYPE)); bytes32 private constant OFFER__TYPEHASH = keccak256(abi.encodePacked(OFFER__TYPE)); function _hashItem(Item calldata item) private pure returns (bytes32) { return keccak256(abi.encode( ITEM__TYPEHASH, item.tokenAddress, item.tokenId, item.depositTimestamp )); } function _hashLoanParams(LoanParams calldata params) private pure returns (bytes32) { return keccak256(abi.encode( LOAN_PARAMS__TYPEHASH, params.itemValue, params.redemptionPrice, params.timelockPeriod )); } function _hashOffer(Offer calldata offer) private view returns (bytes32) { return keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode( OFFER__TYPEHASH, offer.nonce, offer.expirationTime, offer.loanTokenAddress, _hashItem(offer.collateralItem), _hashLoanParams(offer.loanParams) )) )); } function _verifyOffer(address signerAddress, bytes calldata signature, Offer calldata offer) internal view returns (bool) { bytes32 hash = _hashOffer(offer); return hash.recover(signature) == signerAddress; } } // Dependency file: contracts/model/FlashOfferModel.sol // pragma solidity 0.7.3; abstract contract FlashOfferModel { string internal constant FLASH_OFFER__TYPE = "FlashOffer(uint32 nonce,uint40 expirationTime,address loanTokenAddress,uint256 loanAmount,uint256 returnAmount)"; struct FlashOffer { uint32 nonce; uint40 expirationTime; address loanTokenAddress; uint256 loanAmount; uint256 returnAmount; } } // Dependency file: contracts/verifiers/FlashOfferSigVerifier.sol // pragma solidity 0.7.3; // import "@openzeppelin/contracts/cryptography/ECDSA.sol"; // import "contracts/verifiers/EIP712Domain.sol"; // import "contracts/model/FlashOfferModel.sol"; abstract contract FlashOfferSigVerifier is FlashOfferModel, EIP712Domain { using ECDSA for bytes32; bytes32 private constant FLASH_OFFER__TYPEHASH = keccak256(abi.encodePacked(FLASH_OFFER__TYPE)); function _hashFlashOffer(FlashOffer calldata offer) private view returns (bytes32) { return keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode( FLASH_OFFER__TYPEHASH, offer.nonce, offer.expirationTime, offer.loanTokenAddress, offer.loanAmount, offer.returnAmount )) )); } function _verifyFlashOffer( address signerAddress, bytes calldata signature, FlashOffer calldata offer ) internal view returns (bool) { bytes32 hash = _hashFlashOffer(offer); return hash.recover(signature) == signerAddress; } } // Dependency file: contracts/interfaces/IERC3156FlashBorrower.sol // pragma solidity 0.7.3; interface IERC3156FlashBorrower { /** * @dev Receive a flash loan. * @param sender The initiator of the loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @param fee The additional amount of tokens to repay. * @param data Arbitrary data structure, intended to contain user-defined parameters. */ function onFlashLoan( address sender, address token, uint256 amount, uint256 fee, bytes calldata data ) external; } // Dependency file: contracts/FlashLoan.sol // pragma solidity 0.7.3; // pragma experimental ABIEncoderV2; // import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "contracts/PawnshopConfig.sol"; // import "contracts/PawnshopStorage.sol"; // import "contracts/utils/FractionMath.sol"; // import "contracts/model/FlashOfferModel.sol"; // import "contracts/verifiers/FlashOfferSigVerifier.sol"; // import "contracts/interfaces/IERC3156FlashBorrower.sol"; abstract contract FlashLoan is FlashOfferModel, PawnshopStorage, FlashOfferSigVerifier, PawnshopConfig { using FractionMath for FractionMath.Fraction; using SafeERC20 for IERC20; using SafeMath for uint256; event FlashLoanMade( address indexed borrowerAddress, address indexed receiverAddress, address indexed lenderAddress, bytes32 signatureHash ); function flashLoan( IERC3156FlashBorrower receiver, address lenderAddress, bytes calldata signature, FlashOffer calldata offer, bytes calldata data ) external { require(isLoanTokenSupported(offer.loanTokenAddress), "FlashLoan: the ERC20 loan token is not supported"); require(block.timestamp < offer.expirationTime, "FlashLoan: the offer has expired"); require(offer.loanAmount > 0, "FlashLoan: loan amount must be greater than 0"); require(offer.returnAmount > 0, "FlashLoan: return amount must be greater than 0"); require(offer.returnAmount >= minReturnAmount(offer.loanTokenAddress, offer.loanAmount), "FlashLoan: the return amount is less then the minimum return amount for this loan token and loan amount"); require(_verifyFlashOffer(lenderAddress, signature, offer), "FlashLoan: the signature of the offer is invalid"); bytes32 signatureHash = keccak256(signature); require(!_usedOfferSignatures[signatureHash], "FlashLoan: the loan has already been taken or the offer was cancelled"); _usedOfferSignatures[signatureHash] = true; IERC20(offer.loanTokenAddress).safeTransferFrom(lenderAddress, address(receiver), offer.loanAmount); uint256 flashFee = _flashFees[offer.loanTokenAddress].mul(offer.loanAmount); uint256 totalFee = offer.returnAmount.sub(offer.loanAmount).add(flashFee); receiver.onFlashLoan(msg.sender, offer.loanTokenAddress, offer.loanAmount, totalFee, data); IERC20(offer.loanTokenAddress).safeTransferFrom(address(receiver), lenderAddress, offer.returnAmount); IERC20(offer.loanTokenAddress).safeTransferFrom(address(receiver), address(this), flashFee); emit FlashLoanMade(msg.sender, address(receiver), lenderAddress, signatureHash); } } // Root file: contracts/Pawnshop.sol pragma solidity 0.7.3; pragma experimental ABIEncoderV2; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; // import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; // import "contracts/PawnshopStorage.sol"; // import "contracts/Initializable.sol"; // import "contracts/Ownable.sol"; // import "contracts/ReentrancyGuard.sol"; // import "contracts/PawnshopConfig.sol"; // import "contracts/PawnshopStaking.sol"; // import "contracts/model/LoanModel.sol"; // import "contracts/model/OfferModel.sol"; // import "contracts/verifiers/OfferSigVerifier.sol"; // import "contracts/handlers/IHandler.sol"; // import "contracts/FlashLoan.sol"; // import "contracts/utils/FractionMath.sol"; contract Pawnshop is LoanModel, PawnshopStorage, Initializable, Ownable, ReentrancyGuard, OfferSigVerifier, PawnshopConfig, PawnshopStaking, FlashLoan, IERC721Receiver { using SafeMath for uint256; using SafeERC20 for IERC20; using FractionMath for FractionMath.Fraction; // mapping (bytes32 => Loan) _loans; // mapping (bytes32 => bool) _usedOfferSignatures; modifier onlyBorrower(bytes32 signatureHash) { Loan storage loan = _loans[signatureHash]; require(msg.sender == loan.borrowerAddress, "Pawnshop: caller is not the borrower"); _; } modifier onlyLender(bytes32 signatureHash) { Loan storage loan = _loans[signatureHash]; require(msg.sender == loan.lenderAddress, "Pawnshop: caller is not the lender"); _; } event ItemDeposited(address indexed previousOwner, address indexed tokenAddress, uint256 indexed tokenId); event ItemWithdrawn(address indexed ownerAddress, address indexed tokenAddress, uint256 indexed tokenId); event LoanTaken(address indexed borrowerAddress, address indexed lenderAddress, bytes32 signatureHash); event OfferCanceled(address indexed lenderAddres, bytes32 signatureHash); event ItemRedeemed(address indexed borrowerAddress, bytes32 signatureHash); event ItemClaimed(address indexed lenderAddress, bytes32 signatureHash); constructor(address owner) { __Ownable_init_unchained(owner); } function initialize(address owner, IERC20 stakingToken, uint256 maxTimelockPeriod) public initializer { __Ownable_init_unchained(owner); __ReentrancyGuard_init_unchained(); __EIP712Domain_init_unchained(); __PawnshopStaking_init_unchained(stakingToken); __Pawnshop_init_unchained(maxTimelockPeriod); } // solhint-disable-next-line func-name-mixedcase function __Pawnshop_init_unchained(uint256 maxTimelockPeriod) internal { _setMaxTimelockPeriod(maxTimelockPeriod); } function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) { revert("Pawnshop: tokens cannot be transferred directly, use Pawnshop.depositItem function instead"); } function itemOwner(address tokenAddress, uint256 tokenId) external view returns (address) { IHandler handler = itemHandler(tokenAddress); return handler.ownerOf(tokenAddress, tokenId); } function _calculateRedemptionFee(Loan storage loan) private view returns (uint256) { return loan.offer.redemptionPrice .mul(loan.redemptionFeeNumerator) .div(loan.redemptionFeeDenominator); } function depositItem(address tokenAddress, uint256 tokenId) external { IHandler handler = itemHandler(tokenAddress); handler.deposit(msg.sender, tokenAddress, tokenId); emit ItemDeposited(msg.sender, tokenAddress, tokenId); } function itemDepositTimestamp(address tokenAddress, uint256 tokenId) public view returns (uint256) { IHandler handler = itemHandler(tokenAddress); return handler.depositTimestamp(tokenAddress, tokenId); } function takeLoan(address lenderAddress, bytes calldata signature, Offer calldata offer) external nonReentrant { Item calldata item = offer.collateralItem; LoanParams calldata params = offer.loanParams; IHandler handler = itemHandler(item.tokenAddress); require(handler.isSupported(item.tokenAddress), "Pawnshop: the item is not supported"); require(isLoanTokenSupported(offer.loanTokenAddress), "Pawnshop: the ERC20 loan token is not supported"); require(block.timestamp < offer.expirationTime, "Pawnshop: the offer has expired"); require(params.itemValue > 0, "Pawnshop: the item value must be greater than 0"); require(params.redemptionPrice > 0, "Pawnshop: the redemption price must be greater than 0"); require(params.timelockPeriod > 0, "Pawnshop: the timelock period must be greater than 0"); require(params.timelockPeriod <= _maxTimelockPeriod, "Pawnshop: the timelock period must be less or equal to the max timelock period"); require(params.redemptionPrice >= minReturnAmount(offer.loanTokenAddress, params.itemValue), "Pawnshop: the redemption price is less then the minimum return amount for this loan token and loan amount"); require(_verifyOffer(lenderAddress, signature, offer), "Pawnshop: the signature of the offer is invalid"); bytes32 signatureHash = keccak256(signature); require(!_usedOfferSignatures[signatureHash], "Pawnshop: the loan has already been taken or the offer was cancelled"); require(handler.ownerOf(item.tokenAddress, item.tokenId) == msg.sender, "Pawnshop: the item must be deposited to the pawnshop first"); require(handler.depositTimestamp(item.tokenAddress, item.tokenId) == item.depositTimestamp, "Pawnshop: the item was redeposited after offer signing"); uint256 depositFee = _depositFees[offer.loanTokenAddress].mul(params.itemValue); IERC20(offer.loanTokenAddress).safeTransferFrom(lenderAddress, address(this), depositFee); IERC20(offer.loanTokenAddress).safeTransferFrom(lenderAddress, msg.sender, params.itemValue.sub(depositFee)); _usedOfferSignatures[signatureHash] = true; _loans[signatureHash] = Loan({ offer: StoredOffer({ nonce: offer.nonce, timelockPeriod: offer.loanParams.timelockPeriod, loanTokenAddress: offer.loanTokenAddress, itemTokenAddress: offer.collateralItem.tokenAddress, itemTokenId: offer.collateralItem.tokenId, itemValue: offer.loanParams.itemValue, redemptionPrice: offer.loanParams.redemptionPrice }), status: LoanStatus.TAKEN, borrowerAddress: msg.sender, lenderAddress: lenderAddress, redemptionFeeNumerator: _redemptionFees[offer.loanTokenAddress].numerator, redemptionFeeDenominator: _redemptionFees[offer.loanTokenAddress].denominator, timestamp: block.timestamp }); handler.changeOwnership(address(this), item.tokenAddress, item.tokenId); emit LoanTaken(msg.sender, lenderAddress, signatureHash); } function loan(bytes32 signatureHash) external view returns (Loan memory) { Loan storage _loan = _loans[signatureHash]; require(_loan.timestamp != 0, "Pawnshop: there's no loan with given signature"); return _loan; } function isSignatureUsed(bytes32 signatureHash) external view returns (bool) { return _usedOfferSignatures[signatureHash]; } function cancelOffer(bytes calldata signature, Offer calldata offer) external { require(_verifyOffer(msg.sender, signature, offer), "Pawnshop: the transaction sender is not the offer signer"); bytes32 signatureHash = keccak256(signature); _usedOfferSignatures[signatureHash] = true; emit OfferCanceled(msg.sender, signatureHash); } function redemptionPriceWithFee(bytes32 signatureHash) external view returns (uint256) { Loan storage _loan = _loans[signatureHash]; require(_loan.timestamp != 0, "Pawnshop: there's no loan with given signature"); return _loan.offer.redemptionPrice.add(_calculateRedemptionFee(_loan)); } function redemptionDeadline(bytes32 signatureHash) public view returns (uint256) { Loan storage _loan = _loans[signatureHash]; require(_loan.timestamp != 0, "Pawnshop: there's no loan with given signature"); return _loan.timestamp.add(_loan.offer.timelockPeriod); } function _reedemItem(bytes32 signatureHash) private returns (Loan storage _loan) { _loan = _loans[signatureHash]; StoredOffer storage offer = _loan.offer; require(block.timestamp <= redemptionDeadline(signatureHash), "Pawnshop: the redemption time has already passed"); require(_loan.status == LoanStatus.TAKEN, "Pawnshop: the item was already redeemed/claimed"); address loanTokenAddress = offer.loanTokenAddress; uint256 redemptionFee = _calculateRedemptionFee(_loan); IERC20(loanTokenAddress).safeTransferFrom(_loan.borrowerAddress, address(this), redemptionFee); IERC20(loanTokenAddress).safeTransferFrom(_loan.borrowerAddress, _loan.lenderAddress, offer.redemptionPrice); IHandler handler = itemHandler(offer.itemTokenAddress); handler.changeOwnership(msg.sender, offer.itemTokenAddress, offer.itemTokenId); _loan.status = LoanStatus.RETURNED; emit ItemRedeemed(msg.sender, signatureHash); } function redeemItem(bytes32 signatureHash) external onlyBorrower(signatureHash) { _reedemItem(signatureHash); } function _claimItem(bytes32 signatureHash) private returns (Loan storage _loan) { _loan = _loans[signatureHash]; StoredOffer storage offer = _loan.offer; require(block.timestamp > redemptionDeadline(signatureHash), "Pawnshop: the item timelock period hasn't passed yet"); require(_loan.status == LoanStatus.TAKEN, "Pawnshop: the item was already redeemed/claimed"); IHandler handler = itemHandler(offer.itemTokenAddress); handler.changeOwnership(msg.sender, offer.itemTokenAddress, offer.itemTokenId); _loan.status = LoanStatus.CLAIMED; emit ItemClaimed(msg.sender, signatureHash); } function claimItem(bytes32 signatureHash) external onlyLender(signatureHash) { _claimItem(signatureHash); } function withdrawItem(address tokenAddress, uint256 tokenId) public { IHandler handler = itemHandler(tokenAddress); handler.withdraw(msg.sender, tokenAddress, tokenId); emit ItemWithdrawn(msg.sender, tokenAddress, tokenId); } function redeemAndWithdrawItem(bytes32 signatureHash) external onlyBorrower(signatureHash) { Loan storage _loan = _reedemItem(signatureHash); withdrawItem(_loan.offer.itemTokenAddress, _loan.offer.itemTokenId); } function claimAndWithdrawItem(bytes32 signatureHash) external onlyLender(signatureHash) { Loan storage _loan = _claimItem(signatureHash); withdrawItem(_loan.offer.itemTokenAddress, _loan.offer.itemTokenId); } }
0x608060405234801561001057600080fd5b50600436106102d65760003560e01c80637bc42eb111610182578063ab7573dd116100e9578063cfbc5ce9116100a2578063e1e688201161007c578063e1e6882014610663578063f2fde38b14610676578063f95f014014610689578063f99318551461069c576102d6565b8063cfbc5ce91461061b578063d26abffa1461062e578063df9aedab14610641576102d6565b8063ab7573dd146105a9578063ad5ad801146105bc578063b201c133146105cf578063b7ef6a94146105e2578063bd169119146105f5578063c19eba7814610608576102d6565b80638da5cb5b1161013b5780638da5cb5b146105425780638ed4ebf41461054a578063957566c21461055d57806398159a4a14610570578063a110b93f14610583578063a694fc3a14610596576102d6565b80637bc42eb1146104d857806380352cfd146104eb578063817b1cd2146104fe5780638301f862146105065780638954b8c8146105275780638aff86711461053a576102d6565b806329c07022116102415780633e9f9664116101fa578063543068f0116101d4578063543068f0146104ad57806358207802146104c057806372f702f3146104c85780637a604619146104d0576102d6565b80633e9f966414610474578063461a18bf146104875780634d80efae1461049a576102d6565b806329c07022146104005780632a27a25e146104135780632e17de7814610433578063372500ab146104465780633a71f7761461044e5780633c7b4a2914610461576102d6565b80631794bb3c116102935780631794bb3c146103815780631a2fdcd414610394578063231e68e9146103a75780632691e401146103ba57806326abfb58146103da57806326af4327146103ed576102d6565b806305503763146102db57806308a294cd146103045780630c35e103146103245780631032a3c814610344578063150b7a021461035757806315be116b14610377575b600080fd5b6102ee6102e9366004613c1b565b6106af565b6040516102fb9190614214565b60405180910390f35b610317610312366004613edb565b61075d565b6040516102fb919061535c565b610337610332366004613e90565b610899565b6040516102fb919061421f565b610337610352366004613edb565b610930565b61036a610365366004613c8b565b610981565b6040516102fb91906142f5565b61037f61099b565b005b61037f61038f366004613d63565b610aa2565b61037f6103a2366004613da3565b610b53565b61037f6103b5366004613c1b565b610c1b565b6103cd6103c8366004613c1b565b610cef565b6040516102fb919061533a565b61037f6103e8366004613e25565b610d38565b6102ee6103fb366004613c1b565b610e45565b61037f61040e366004613edb565b610e78565b610426610421366004613c1b565b610ee7565b6040516102fb9190614120565b61037f610441366004613edb565b610f0f565b61037f610fdb565b61033761045c366004613edb565b611042565b6102ee61046f366004613c1b565b611088565b61037f610482366004613e90565b611095565b61037f610495366004613ffa565b611142565b6102ee6104a8366004613edb565b6112b1565b6103cd6104bb366004613c1b565b6112c6565b61033761130f565b610426611315565b610337611324565b61037f6104e6366004613e90565b611335565b6103cd6104f9366004613c1b565b6113e2565b61033761142b565b610519610514366004613edb565b611431565b6040516102fb9291906141d5565b61037f610535366004613f47565b611448565b610337611760565b61042661176c565b61037f610558366004613dd8565b611781565b61042661056b366004613e90565b6118ab565b61037f61057e366004613edb565b611938565b610337610591366004613c1b565b611983565b61037f6105a4366004613edb565b6119c9565b6103376105b7366004613c1b565b611a64565b61037f6105ca366004613edb565b611aac565b61037f6105dd366004613edb565b611af4565b61037f6105f0366004613cfc565b611b3a565b6103cd610603366004613c1b565b612347565b61037f610616366004613ef3565b612390565b61037f610629366004613edb565b61241e565b61033761063c366004613c53565b61245a565b61065461064f366004613edb565b6124db565b6040516102fb939291906141b1565b610337610671366004613e90565b612573565b61037f610684366004613c1b565b6125ab565b61037f610697366004613c1b565b61266a565b6103376106aa366004613c1b565b612704565b60006106bc60058361271f565b6106c857506000610758565b60006106d560058461273b565b604051634f129c5360e01b81529091506001600160a01b03821690634f129c5390610704908690600401614120565b60206040518083038186803b15801561071c57600080fd5b505afa158015610730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107549190613ebb565b9150505b919050565b610765613b06565b6000828152600260205260409020600781015461079d5760405162461bcd60e51b81526004016107949061451d565b60405180910390fd5b604080516101c08101909152815463ffffffff80821660e084019081526401000000008304909116610100840152600160401b9091046001600160a01b03908116610120840152600184015416610140830152600280840154610160840152600384015461018084015260048401546101a084015290825260058301548391602084019160ff169081111561082e57fe5b600281111561083957fe5b815260058201546001600160a01b03610100909104811660208301526006830154908116604083015265ffffffffffff600160a01b820481166060840152600160d01b90910416608082015260079091015460a090910152915050919050565b6000806108a584610ee7565b60405163e86e8c6d60e01b81529091506001600160a01b0382169063e86e8c6d906108d690879087906004016141fb565b60206040518083038186803b1580156108ee57600080fd5b505afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610926919061400c565b9150505b92915050565b6000818152600260205260408120600781015461095f5760405162461bcd60e51b81526004016107949061451d565b805460078201546107549163ffffffff64010000000090910481169061275016565b600060405162461bcd60e51b815260040161079490614374565b6000546201000090046001600160a01b031633146109cb5760405162461bcd60e51b815260040161079490614ea4565b600d546040516370a0823160e01b81526000916001600160a01b0316906370a08231906109fc903090600401614120565b60206040518083038186803b158015610a1457600080fd5b505afa158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c919061400c565b90506000610a65600f548361277590919063ffffffff16565b905060008111610a875760405162461bcd60e51b8152600401610794906146da565b600d54610a9e906001600160a01b031633836127b7565b5050565b600054610100900460ff1680610abb5750610abb612812565b80610ac9575060005460ff16155b610ae55760405162461bcd60e51b815260040161079490614f6c565b600054610100900460ff16158015610b10576000805460ff1961ff0019909116610100171660011790555b610b1984612818565b610b216128ed565b610b29612973565b610b3283612aae565b610b3b8261244e565b8015610b4d576000805461ff00191690555b50505050565b6000546201000090046001600160a01b03163314610b835760405162461bcd60e51b815260040161079490614ea4565b610b8c82610e45565b610ba85760405162461bcd60e51b81526004016107949061526b565b610bb181612b4c565b6001600160a01b0383166000908152600960205260409020610bd38282615473565b905050816001600160a01b03167f1d0dd97cc46279d7c23238d340d5a16b46724f472c8bffdf91e0b5576d7ae18182604051610c0f9190615304565b60405180910390a25050565b6000546201000090046001600160a01b03163314610c4b5760405162461bcd60e51b815260040161079490614ea4565b6000610c5682610ee7565b604051630cc30d2b60e01b81529091506001600160a01b03821690630cc30d2b90610c85908590600401614120565b600060405180830381600087803b158015610c9f57600080fd5b505af1158015610cb3573d6000803e3d6000fd5b50506040516001600160a01b03851692507ff5a8c396eecafc0001205224fd30e5dc1de9a10b7f0b6332421e0705fbf6455a9150600090a25050565b610cf7613b49565b506001600160a01b03166000908152600b602090815260409182902082518084019093525465ffffffffffff8082168452600160301b909104169082015290565b6000546201000090046001600160a01b03163314610d685760405162461bcd60e51b815260040161079490614ea4565b610d7185610e45565b15610d8e5760405162461bcd60e51b815260040161079490614afd565b600d546001600160a01b0386811691161415610dbc5760405162461bcd60e51b815260040161079490614ffc565b610dc96007866001612b88565b506001600160a01b038516600081815260106020526040902080546001600160a01b0319169091178155610dfd8686610b53565b610e0986858585611781565b6040516001600160a01b038716907f0eb48e8779c4152626b8ac82fc5767a44da67a109b8d6e6f46728b45db9a8ccc90600090a2505050505050565b6000610e5260078361271f565b801561092a57506001610e66600784612bb1565b6002811115610e7157fe5b1492915050565b6000818152600260205260409020600581015482919061010090046001600160a01b03163314610eba5760405162461bcd60e51b815260040161079490614d6e565b6000610ec584612bd1565b60018101546002820154919250610b4d916001600160a01b0390911690611095565b600061092a826040518060600160405280602381526020016154ed6023913960059190612d88565b336000908152600e6020526040902054811115610f3e5760405162461bcd60e51b815260040161079490614aa9565b610f46612d9e565b336000908152600e6020526040902054610f609082612775565b336000908152600e6020526040902055600f54610f7d9082612775565b600f55600d54610f97906001600160a01b031633836127b7565b336001600160a01b03167f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7582604051610fd0919061421f565b60405180910390a250565b6000610fe76007612df2565b905060005b81811015610a9e576000611001600783612dfd565b506001600160a01b0381166000908152601060205260409020600f54919250901561102f5761102f81612e2c565b61103881612e81565b5050600101610fec565b600081815260026020526040812060078101546110715760405162461bcd60e51b81526004016107949061451d565b61075461107d82612f1d565b600483015490612750565b600061092a60078361271f565b60006110a083610ee7565b604051636ce5768960e11b81529091506001600160a01b0382169063d9caed12906110d390339087908790600401614134565b600060405180830381600087803b1580156110ed57600080fd5b505af1158015611101573d6000803e3d6000fd5b50506040518492506001600160a01b038616915033907f355a2197dd019791687055264a51e5ef6407d234013eec10f28d445b88f4bb0390600090a4505050565b6000546201000090046001600160a01b031633146111725760405162461bcd60e51b815260040161079490614ea4565b604051634f129c5360e01b81526001600160a01b03831690634f129c539061119e908490600401614120565b60206040518083038186803b1580156111b657600080fd5b505afa1580156111ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ee9190613ebb565b1561120b5760405162461bcd60e51b81526004016107949061483f565b604051632a4f162160e01b81526001600160a01b03831690632a4f162190611237908490600401614120565b600060405180830381600087803b15801561125157600080fd5b505af1158015611265573d6000803e3d6000fd5b5061127892506005915083905084612f58565b506040516001600160a01b038216907fa965169cd2053f6b6a1a128a43bb01355c709b634cb45af8fb1d1ccc691fcfa790600090a25050565b60009081526003602052604090205460ff1690565b6112ce613b49565b506001600160a01b031660009081526009602090815260409182902082518084019093525465ffffffffffff8082168452600160301b909104169082015290565b60045490565b600d546001600160a01b031690565b60006113306005612df2565b905090565b600061134083610ee7565b604051638340f54960e01b81529091506001600160a01b03821690638340f5499061137390339087908790600401614134565b600060405180830381600087803b15801561138d57600080fd5b505af11580156113a1573d6000803e3d6000fd5b50506040518492506001600160a01b038616915033907fbc52aba7551de243300c8c91c7ef262516fe145ed31f0349d07dff6aa79322f290600090a4505050565b6113ea613b49565b506001600160a01b03166000908152600a602090815260409182902082518084019093525465ffffffffffff8082168452600160301b909104169082015290565b600f5490565b60008061143f600784612dfd565b91509150915091565b61145b6103fb6060850160408601613c1b565b6114775760405162461bcd60e51b815260040161079490615046565b6114876040840160208501614048565b64ffffffffff1642106114ac5760405162461bcd60e51b815260040161079490614a74565b60008360600135116114d05760405162461bcd60e51b8152600401610794906147f2565b60008360800135116114f45760405162461bcd60e51b815260040161079490614471565b6115116115076060850160408601613c1b565b8460600135612573565b836080013510156115345760405162461bcd60e51b815260040161079490614ed9565b61154086868686612f71565b61155c5760405162461bcd60e51b8152600401610794906152b4565b6000858560405161156e9291906140d9565b604080519182900390912060008181526003602052919091205490915060ff16156115ab5760405162461bcd60e51b815260040161079490614b50565b60008181526003602052604090819020805460ff191660011790556115f29088908a90606088018035916115e191908a01613c1b565b6001600160a01b0316929190612fdf565b600061162f60608601803590600c9084906116109060408b01613c1b565b6001600160a01b03168152602081019190915260400160002090613000565b9050600061164f82611649608089013560608a0135612775565b90612750565b90506001600160a01b038a166323e30c8b3361167160608a0160408b01613c1b565b8960600135858a8a6040518763ffffffff1660e01b815260040161169a96959493929190614158565b600060405180830381600087803b1580156116b457600080fd5b505af11580156116c8573d6000803e3d6000fd5b505050506116e98a8a88608001358960400160208101906115e19190613c1b565b6116ff8a30846115e160608b0160408c01613c1b565b886001600160a01b03168a6001600160a01b0316336001600160a01b03167f72b2c560ea216d05beb9a4d4ebfa9685f86f9674bef0c74c948286b21fce77fc8660405161174c919061421f565b60405180910390a450505050505050505050565b60006113306007612df2565b6000546201000090046001600160a01b031690565b6000546201000090046001600160a01b031633146117b15760405162461bcd60e51b815260040161079490614ea4565b6117ba84610e45565b6117d65760405162461bcd60e51b81526004016107949061526b565b6117df83612b4c565b6001600160a01b0385166000908152600a602052604090206118018282615473565b90505061180d82612b4c565b6001600160a01b0385166000908152600b6020526040902061182f8282615473565b90505061183b81612b4c565b6001600160a01b0385166000908152600c6020526040902061185d8282615473565b905050836001600160a01b03167f7712fde0504a12fde39162a10ac8763b799ccf764217ad392f95459deafe30ba84848460405161189d93929190615312565b60405180910390a250505050565b6000806118b784610ee7565b6040516307ca74b760e21b81529091506001600160a01b03821690631f29d2dc906118e890879087906004016141fb565b60206040518083038186803b15801561190057600080fd5b505afa158015611914573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190613c37565b6000818152600260205260409020600581015482919061010090046001600160a01b0316331461197a5760405162461bcd60e51b815260040161079490614d6e565b610b4d83612bd1565b600061198e82611088565b6119aa5760405162461bcd60e51b81526004016107949061456b565b506001600160a01b031660009081526010602052604090206001015490565b600f54156119d9576119d9612d9e565b336000908152600e60205260409020546119f39082612750565b336000908152600e6020526040902055600f54611a109082612750565b600f55600d54611a2b906001600160a01b0316333084612fdf565b336001600160a01b03167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d82604051610fd0919061421f565b6000611a6f82611088565b611a8b5760405162461bcd60e51b81526004016107949061456b565b6001600160a01b038216600090815260106020526040902061075481613026565b600081815260026020526040902060068101548291906001600160a01b03163314611ae95760405162461bcd60e51b815260040161079490614fba565b6000610ec5846130c3565b600081815260026020526040902060068101548291906001600160a01b03163314611b315760405162461bcd60e51b815260040161079490614fba565b610b4d836130c3565b60026001541415611b5d5760405162461bcd60e51b8152600401610794906151df565b60026001556060810160c082016000611b7c6104216080860185613c1b565b90506001600160a01b038116634f129c53611b9a6020860186613c1b565b6040518263ffffffff1660e01b8152600401611bb69190614120565b60206040518083038186803b158015611bce57600080fd5b505afa158015611be2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c069190613ebb565b611c225760405162461bcd60e51b8152600401610794906143f7565b611c356103fb6060860160408701613c1b565b611c515760405162461bcd60e51b815260040161079490614c48565b611c616040850160208601614048565b64ffffffffff164210611c865760405162461bcd60e51b815260040161079490614bbb565b8135611ca45760405162461bcd60e51b8152600401610794906149c8565b6000826020013511611cc85760405162461bcd60e51b815260040161079490615216565b6000611cda6060840160408501614024565b63ffffffff1611611cfd5760405162461bcd60e51b815260040161079490615141565b600454611d106060840160408501614024565b63ffffffff161115611d345760405162461bcd60e51b815260040161079490615096565b611d4e611d476060860160408701613c1b565b8335612573565b82602001351015611d715760405162461bcd60e51b81526004016107949061460e565b611d7d87878787613205565b611d995760405162461bcd60e51b815260040161079490614754565b60008686604051611dab9291906140d9565b604080519182900390912060008181526003602052919091205490915060ff1615611de85760405162461bcd60e51b815260040161079490614886565b336001600160a01b038316631f29d2dc611e056020880188613c1b565b87602001356040518363ffffffff1660e01b8152600401611e279291906141fb565b60206040518083038186803b158015611e3f57600080fd5b505afa158015611e53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e779190613c37565b6001600160a01b031614611e9d5760405162461bcd60e51b815260040161079490614db2565b60408401356001600160a01b03831663e86e8c6d611ebe6020880188613c1b565b87602001356040518363ffffffff1660e01b8152600401611ee09291906141fb565b60206040518083038186803b158015611ef857600080fd5b505afa158015611f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f30919061400c565b14611f4d5760405162461bcd60e51b815260040161079490614bf2565b6000611f678435600a8361161060608b0160408c01613c1b565b9050611f7f8930836115e160608b0160408c01613c1b565b611f9f8933611f8f873585612775565b6115e160608b0160408c01613c1b565b600082815260036020908152604091829020805460ff1916600117905581516101c08101909252819060e08201908190611fdb908b018b614024565b63ffffffff168152602001611ff86101208b016101008c01614024565b63ffffffff16815260200161201360608b0160408c01613c1b565b6001600160a01b0316815260200161203160808b0160608c01613c1b565b6001600160a01b0316815260808a013560208083019190915260c08b0135604083015260e08b01356060909201919091529082520160008152602001336001600160a01b031681526020018a6001600160a01b03168152602001600b60008960400160208101906120a29190613c1b565b6001600160a01b03168152602080820192909252604090810160009081205465ffffffffffff1684529290910191600b916120e39060608c01908c01613c1b565b6001600160a01b0390811682526020808301939093526040918201600090812054600160301b900465ffffffffffff1685524294840194909452868452600280845293829020855180518254828701519583015163ffffffff1990911663ffffffff9283161767ffffffff00000000191664010000000092909616919091029490941768010000000000000000600160e01b031916600160401b948416949094029390931781556060830151600180830180546001600160a01b031916929094169190911790925560808301518186015560a0830151600382015560c09092015160048301559184015160058201805492949193909260ff19169184908111156121e957fe5b02179055506040820151600582018054610100600160a81b0319166101006001600160a01b03938416021790556060830151600683018054608086015160a08701516001600160a01b03199092169385169390931765ffffffffffff60a01b1916600160a01b65ffffffffffff94851602176001600160d01b0316600160d01b939091169290920291909117905560c09092015160079091015583166315b7f465306122986020890189613c1b565b88602001356040518463ffffffff1660e01b81526004016122bb93929190614134565b600060405180830381600087803b1580156122d557600080fd5b505af11580156122e9573d6000803e3d6000fd5b50505050886001600160a01b0316336001600160a01b03167fe8c2ccc0a6acabe5e281d77cd452d890c095ff0e994e8482b657c5c103055c1984604051612330919061421f565b60405180910390a350506001805550505050505050565b61234f613b49565b506001600160a01b03166000908152600c602090815260409182902082518084019093525465ffffffffffff8082168452600160301b909104169082015290565b61239c33848484613205565b6123b85760405162461bcd60e51b8152600401610794906144c0565b600083836040516123ca9291906140d9565b604080519182900382206000818152600360205291909120805460ff19166001179055915033907f4ec3cc941f030548ee5a944fff165eb37779faf508c6b81d97c9c5e1176271239061189d90849061421f565b6000546201000090046001600160a01b0316331461244e5760405162461bcd60e51b815260040161079490614ea4565b61245781613211565b50565b600061246582611088565b6124815760405162461bcd60e51b81526004016107949061456b565b6001600160a01b0382166000908152601060205260408120906124a382613026565b9050600080600f54116124ba5782600301546124c4565b6124c48383613264565b90506124d18382886132ba565b9695505050505050565b600080806124ea600585613344565b604051634f129c5360e01b815291945092506001600160a01b03831690634f129c539061251b908690600401614120565b60206040518083038186803b15801561253357600080fd5b505afa158015612547573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256b9190613ebb565b929491935050565b6001600160a01b0382166000908152600960205260408120816125968285613000565b90506125a28482612750565b95945050505050565b6000546201000090046001600160a01b031633146125db5760405162461bcd60e51b815260040161079490614ea4565b6001600160a01b0381166126015760405162461bcd60e51b8152600401610794906145c8565b600080546040516001600160a01b03808516936201000090930416917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b6000546201000090046001600160a01b0316331461269a5760405162461bcd60e51b815260040161079490614ea4565b6126a381610e45565b6126bf5760405162461bcd60e51b815260040161079490614c48565b6126cc6007826002612b88565b506040516001600160a01b038216907f0a8639dc08daf0ecb18a231a5bc027829615e6550dbc64153281c68b6c588fca90600090a250565b6001600160a01b03166000908152600e602052604090205490565b6000612734836001600160a01b038416613360565b9392505050565b6000612734836001600160a01b038416613378565b6000828201838110156127345760405162461bcd60e51b8152600401610794906146a3565b600061273483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506133ba565b61280d8363a9059cbb60e01b84846040516024016127d69291906141fb565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526133e6565b505050565b303b1590565b600054610100900460ff16806128315750612831612812565b8061283f575060005460ff16155b61285b5760405162461bcd60e51b815260040161079490614f6c565b600054610100900460ff16158015612886576000805460ff1961ff0019909116610100171660011790555b6000805462010000600160b01b031916620100006001600160a01b0385169081029190911782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a38015610a9e576000805461ff00191690555050565b600054610100900460ff16806129065750612906612812565b80612914575060005460ff16155b6129305760405162461bcd60e51b815260040161079490614f6c565b600054610100900460ff1615801561295b576000805460ff1961ff0019909116610100171660011790555b600180558015612457576000805461ff001916905550565b600054610100900460ff168061298c575061298c612812565b8061299a575060005460ff16155b6129b65760405162461bcd60e51b815260040161079490614f6c565b600054610100900460ff161580156129e1576000805460ff1961ff0019909116610100171660011790555b60405180608001604052806052815260200161555360529139604051602001612a0a91906140e9565b604051602081830303815290604052805190602001207fda72cbc7dd96ae83bf87a0b1a2c11f74df0960f91636c0eb558d062e0ba8f82c7f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c612a6a613475565b30604051602001612a7f95949392919061424c565b60408051601f1981840301815291905280516020909101206011558015612457576000805461ff001916905550565b600054610100900460ff1680612ac75750612ac7612812565b80612ad5575060005460ff16155b612af15760405162461bcd60e51b815260040161079490614f6c565b600054610100900460ff16158015612b1c576000805460ff1961ff0019909116610100171660011790555b600d80546001600160a01b0319166001600160a01b0384161790558015610a9e576000805461ff00191690555050565b366000612b5f604084016020850161406d565b65ffffffffffff1611612b845760405162461bcd60e51b815260040161079490614c97565b5090565b6000612ba9846001600160a01b038516846002811115612ba457fe5b613479565b949350505050565b6000612bc6836001600160a01b038416613378565b600281111561273457fe5b600081815260026020526040902080612be983610930565b421115612c085760405162461bcd60e51b8152600401610794906148f0565b6000600583015460ff166002811115612c1d57fe5b14612c3a5760405162461bcd60e51b8152600401610794906147a3565b8054600160401b90046001600160a01b03166000612c5784612f1d565b6005850154909150612c7c906001600160a01b03848116916101009004163084612fdf565b600584015460068501546004850154612cac926001600160a01b0386811693610100909204811692911690612fdf565b6001830154600090612cc6906001600160a01b0316610ee7565b600185015460028601546040516315b7f46560e01b81529293506001600160a01b03808516936315b7f46593612d0493339390911691600401614134565b600060405180830381600087803b158015612d1e57600080fd5b505af1158015612d32573d6000803e3d6000fd5b5050505060058501805460ff1916600117905560405133907f3b289a5798d1fc6ff79bfb4cf284124273f37c03041f5b93eefbbde36bb072f790612d7790899061421f565b60405180910390a250505050919050565b6000612ba9846001600160a01b03851684613510565b6000612daa6007612df2565b905060005b81811015610a9e576000612dc4600783612dfd565b506001600160a01b0381166000908152601060205260409020909150612de990612e2c565b50600101612daf565b600061092a8261356f565b6000808080612e0c8686613573565b909250905081816002811115612e1e57fe5b9350935050505b9250929050565b6000612e3782613026565b90506000612e458383613264565b9050612e528382336132ba565b336000908152600585016020908152604080832093909355600486019052208190556003830155600290910155565b3360009081526005820160205260409020546001820154612ea29082612750565b60018301553360008181526005840160205260408120558254612ed1916001600160a01b0390911690836127b7565b81546040516001600160a01b039091169033907f0aa4d283470c904c551d18bb894d37e17674920f3261a7f854be501e25f421b790612f1190859061421f565b60405180910390a35050565b6006810154600482015460009161092a9165ffffffffffff600160d01b8304811692612f529291600160a01b909104166135cf565b90613609565b6000612ba9846001600160a01b03808616908516613479565b600080612f7d8361364b565b9050856001600160a01b0316612fcb86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525086939250506137219050565b6001600160a01b0316149695505050505050565b610b4d846323b872dd60e01b8585856040516024016127d693929190614134565b81546000906127349065ffffffffffff600160301b8204811691612f52918691166135cf565b80546040516370a0823160e01b815260009182916001600160a01b03909116906370a082319061305a903090600401614120565b60206040518083038186803b15801561307257600080fd5b505afa158015613086573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130aa919061400c565b905061075483600101548261275090919063ffffffff16565b6000818152600260205260409020806130db83610930565b42116130f95760405162461bcd60e51b815260040161079490614e50565b6000600583015460ff16600281111561310e57fe5b1461312b5760405162461bcd60e51b8152600401610794906147a3565b6001810154600090613145906001600160a01b0316610ee7565b600183015460028401546040516315b7f46560e01b81529293506001600160a01b03808516936315b7f4659361318393339390911691600401614134565b600060405180830381600087803b15801561319d57600080fd5b505af11580156131b1573d6000803e3d6000fd5b5050505060058301805460ff1916600217905560405133907fedff39b71137a2999a4f2d4316ac9bcb6dd1f7ad13b3c13fa18951859eb1dc78906131f690879061421f565b60405180910390a25050919050565b600080612f7d83613841565b600081116132315760405162461bcd60e51b815260040161079490614a17565b600481905560405181907f12f2183acfb9e4683aeaf097c07398ddf3c7f2836e051363e44db8d39906e4b990600090a250565b60008061327e84600201548461277590919063ffffffff16565b905060006132a8600f54612f526c0c9f2c9cd04674edea40000000856135cf90919063ffffffff16565b60038601549091506125a29082612750565b6001600160a01b038116600090815260048401602052604081205481906132e2908590612775565b6001600160a01b0384166000908152600e60205260408120549192509061331c906c0c9f2c9cd04674edea4000000090612f5290856135cf565b6001600160a01b03851660009081526005880160205260409020549091506124d19082612750565b60008080806133538686613573565b9097909650945050505050565b60009081526001919091016020526040902054151590565b600061273483836040518060400160405280601e81526020017f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000815250613510565b600081848411156133de5760405162461bcd60e51b8152600401610794919061430a565b505050900390565b606061343b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138e29092919063ffffffff16565b80519091501561280d57808060200190518101906134599190613ebb565b61280d5760405162461bcd60e51b815260040161079490615195565b4690565b6000828152600184016020526040812054806134de575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055612734565b828560000160018303815481106134f157fe5b9060005260206000209060020201600101819055506000915050612734565b600082815260018401602052604081205482816135405760405162461bcd60e51b8152600401610794919061430a565b5084600001600182038154811061355357fe5b9060005260206000209060020201600101549150509392505050565b5490565b8154600090819083106135985760405162461bcd60e51b815260040161079490614d2c565b60008460000184815481106135a957fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000826135de5750600061092a565b828202828482816135eb57fe5b04146127345760405162461bcd60e51b815260040161079490614e0f565b600061273483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506138f1565b60006011546040518060a00160405280606f81526020016156ea606f913960405160200161367991906140e9565b60408051601f1981840301815291905280516020918201209061369e90850185614024565b6136ae6040860160208701614048565b6136be6060870160408801613c1b565b866060013587608001356040516020016136dd96959493929190614299565b60405160208183030381529060405280519060200120604051602001613704929190614105565b604051602081830303815290604052805190602001209050919050565b600081516041146137445760405162461bcd60e51b81526004016107949061443a565b60208201516040830151606084015160001a7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156137965760405162461bcd60e51b815260040161079490614940565b8060ff16601b14806137ab57508060ff16601c145b6137c75760405162461bcd60e51b815260040161079490614cea565b6000600187838686604051600081526020016040526040516137ec94939291906142d7565b6020604051602081039080840390855afa15801561380e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124d15760405162461bcd60e51b81526004016107949061433d565b600060115460405180610120016040528060fa81526020016155f060fa913960405160200161387091906140e9565b60408051601f1981840301815291905280516020918201209061389590850185614024565b6138a56040860160208701614048565b6138b56060870160408801613c1b565b6138c187606001613928565b6138cd8860c001613995565b6040516020016136dd96959493929190614299565b6060612ba98484600085613a06565b600081836139125760405162461bcd60e51b8152600401610794919061430a565b50600083858161391e57fe5b0495945050505050565b60006040518060800160405280604381526020016155106043913960405160200161395391906140e9565b60408051601f1981840301815291905280516020918201209061397890840184613c1b565b836020013584604001356040516020016137049493929190614228565b60006040518060800160405280604b81526020016155a5604b91396040516020016139c091906140e9565b60405160208183030381529060405280519060200120826000013583602001358460400160208101906139f39190614024565b6040516020016137049493929190614278565b606082471015613a285760405162461bcd60e51b815260040161079490614982565b613a3185613ac7565b613a4d5760405162461bcd60e51b81526004016107949061510a565b60006060866001600160a01b03168587604051613a6a91906140e9565b60006040518083038185875af1925050503d8060008114613aa7576040519150601f19603f3d011682016040523d82523d6000602084013e613aac565b606091505b5091509150613abc828286613acd565b979650505050505050565b3b151590565b60608315613adc575081612734565b825115613aec5782518084602001fd5b8160405162461bcd60e51b8152600401610794919061430a565b6040518060e00160405280613b19613b60565b81526020016000815260006020820181905260408201819052606082018190526080820181905260a09091015290565b604080518082019091526000808252602082015290565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b60008083601f840112613bad578182fd5b50813567ffffffffffffffff811115613bc4578182fd5b602083019150836020828501011115612e2557600080fd5b600060408284031215613bed578081fd5b50919050565b60006101208284031215613bed578081fd5b803565ffffffffffff8116811461075857600080fd5b600060208284031215613c2c578081fd5b8135612734816154d7565b600060208284031215613c48578081fd5b8151612734816154d7565b60008060408385031215613c65578081fd5b8235613c70816154d7565b91506020830135613c80816154d7565b809150509250929050565b600080600080600060808688031215613ca2578081fd5b8535613cad816154d7565b94506020860135613cbd816154d7565b935060408601359250606086013567ffffffffffffffff811115613cdf578182fd5b613ceb88828901613b9c565b969995985093965092949392505050565b6000806000806101608587031215613d12578384fd5b8435613d1d816154d7565b9350602085013567ffffffffffffffff811115613d38578384fd5b613d4487828801613b9c565b9094509250613d5890508660408701613bf3565b905092959194509250565b600080600060608486031215613d77578283fd5b8335613d82816154d7565b92506020840135613d92816154d7565b929592945050506040919091013590565b60008060608385031215613db5578182fd5b8235613dc0816154d7565b9150613dcf8460208501613bdc565b90509250929050565b60008060008060e08587031215613ded578384fd5b8435613df8816154d7565b9350613e078660208701613bdc565b9250613e168660608701613bdc565b9150613d588660a08701613bdc565b60008060008060006101208688031215613e3d578283fd5b8535613e48816154d7565b9450613e578760208801613bdc565b9350613e668760608801613bdc565b9250613e758760a08801613bdc565b9150613e848760e08801613bdc565b90509295509295909350565b60008060408385031215613ea2578182fd5b8235613ead816154d7565b946020939093013593505050565b600060208284031215613ecc578081fd5b81518015158114612734578182fd5b600060208284031215613eec578081fd5b5035919050565b60008060006101408486031215613f08578081fd5b833567ffffffffffffffff811115613f1e578182fd5b613f2a86828701613b9c565b9094509250613f3e90508560208601613bf3565b90509250925092565b6000806000806000806000878903610120811215613f63578586fd5b8835613f6e816154d7565b97506020890135613f7e816154d7565b9650604089013567ffffffffffffffff80821115613f9a578788fd5b613fa68c838d01613b9c565b909850965086915060a0605f1984011215613fbf578485fd5b60608b0195506101008b0135925080831115613fd9578485fd5b5050613fe78a828b01613b9c565b989b979a50959850939692959293505050565b60008060408385031215613c65578182fd5b60006020828403121561401d578081fd5b5051919050565b600060208284031215614035578081fd5b813563ffffffff81168114612734578182fd5b600060208284031215614059578081fd5b813564ffffffffff81168114612734578182fd5b60006020828403121561407e578081fd5b61273482613c05565b6001600160a01b03169052565b61409d816154cd565b9052565b65ffffffffffff806140b283613c05565b168352806140c260208401613c05565b166020840152505050565b65ffffffffffff169052565b6000828483379101908152919050565b600082516140fb818460208701615434565b9190910192915050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03878116825286166020820152604081018590526060810184905260a06080820181905281018290526000828460c084013781830160c090810191909152601f909201601f1916010195945050505050565b6001600160a01b039384168152919092166020820152901515604082015260600190565b6001600160a01b0383168152604081016141ee836154cd565b8260208301529392505050565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b9384526001600160a01b039290921660208401526040830152606082015260800190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b9384526020840192909252604083015263ffffffff16606082015260800190565b95865263ffffffff94909416602086015264ffffffffff9290921660408501526001600160a01b03166060840152608083015260a082015260c00190565b93845260ff9290921660208401526040830152606082015260800190565b6001600160e01b031991909116815260200190565b6000602082528251806020840152614329816040850160208701615434565b601f01601f19169190910160400192915050565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b6020808252605a908201527f5061776e73686f703a20746f6b656e732063616e6e6f74206265207472616e7360408201527f666572726564206469726563746c792c20757365205061776e73686f702e646560608201527f706f7369744974656d2066756e6374696f6e20696e7374656164000000000000608082015260a00190565b60208082526023908201527f5061776e73686f703a20746865206974656d206973206e6f7420737570706f726040820152621d195960ea1b606082015260800190565b6020808252601f908201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604082015260600190565b6020808252602f908201527f466c6173684c6f616e3a2072657475726e20616d6f756e74206d75737420626560408201526e02067726561746572207468616e203608c1b606082015260800190565b60208082526038908201527f5061776e73686f703a20746865207472616e73616374696f6e2073656e64657260408201527f206973206e6f7420746865206f66666572207369676e65720000000000000000606082015260800190565b6020808252602e908201527f5061776e73686f703a2074686572652773206e6f206c6f616e2077697468206760408201526d6976656e207369676e617475726560901b606082015260800190565b60208082526039908201527f5061776e73686f705374616b696e673a20746865204552433230206c6f616e2060408201527f746f6b656e20776173206e6576657220737570706f7274656400000000000000606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526069908201527f5061776e73686f703a2074686520726564656d7074696f6e207072696365206960408201527f73206c657373207468656e20746865206d696e696d756d2072657475726e206160608201527f6d6f756e7420666f722074686973206c6f616e20746f6b656e20616e64206c6f608082015268185b88185b5bdd5b9d60ba1b60a082015260c00190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526054908201527f5061776e73686f705374616b696e673a20746865726520617265206e6f20616460408201527f646974696f6e616c207374616b696e6720746f6b656e7320666f72207265636f6060820152731d995c9e481a5b881d1a194818dbdb9d1c9858dd60621b608082015260a00190565b6020808252602f908201527f5061776e73686f703a20746865207369676e6174757265206f6620746865206f60408201526e1999995c881a5cc81a5b9d985b1a59608a1b606082015260800190565b6020808252602f908201527f5061776e73686f703a20746865206974656d2077617320616c7265616479207260408201526e195919595b59590bd8db185a5b5959608a1b606082015260800190565b6020808252602d908201527f466c6173684c6f616e3a206c6f616e20616d6f756e74206d757374206265206760408201526c0726561746572207468616e203609c1b606082015260800190565b60208082526027908201527f5061776e73686f703a20746865206974656d20697320616c72656164792073756040820152661c1c1bdc9d195960ca1b606082015260800190565b60208082526044908201527f5061776e73686f703a20746865206c6f616e2068617320616c7265616479206260408201527f65656e2074616b656e206f7220746865206f66666572207761732063616e63656060820152631b1b195960e21b608082015260a00190565b60208082526030908201527f5061776e73686f703a2074686520726564656d7074696f6e2074696d6520686160408201526f1cc8185b1c9958591e481c185cdcd95960821b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252602f908201527f5061776e73686f703a20746865206974656d2076616c7565206d75737420626560408201526e02067726561746572207468616e203608c1b606082015260800190565b60208082526038908201527f5061776e73686f703a20746865206d61782074696d656c6f636b20706572696f60408201527f64206d7573742062652067726561746572207468616e20300000000000000000606082015260800190565b6020808252818101527f466c6173684c6f616e3a20746865206f66666572206861732065787069726564604082015260600190565b60208082526034908201527f5061776e73686f705374616b696e673a2063616e6e6f7420756e7374616b65206040820152731b5bdc99481d1a185b881dd85cc81cdd185ad95960621b606082015260800190565b60208082526033908201527f5061776e73686f703a20746865204552433230206c6f616e20746f6b656e20696040820152721cc8185b1c9958591e481cdd5c1c1bdc9d1959606a1b606082015260800190565b60208082526045908201527f466c6173684c6f616e3a20746865206c6f616e2068617320616c72656164792060408201527f6265656e2074616b656e206f7220746865206f66666572207761732063616e63606082015264195b1b195960da1b608082015260a00190565b6020808252601f908201527f5061776e73686f703a20746865206f6666657220686173206578706972656400604082015260600190565b60208082526036908201527f5061776e73686f703a20746865206974656d207761732072656465706f7369746040820152756564206166746572206f66666572207369676e696e6760501b606082015260800190565b6020808252602f908201527f5061776e73686f703a20746865204552433230206c6f616e20746f6b656e206960408201526e1cc81b9bdd081cdd5c1c1bdc9d1959608a1b606082015260800190565b60208082526033908201527f4672616374696f6e4d6174683a2064656e6f6d696e61746f72206d7573742062604082015272652067726561746572207468616e207a65726f60681b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526024908201527f5061776e73686f703a2063616c6c6572206973206e6f742074686520626f727260408201526337bbb2b960e11b606082015260800190565b6020808252603a908201527f5061776e73686f703a20746865206974656d206d757374206265206465706f7360408201527f6974656420746f20746865207061776e73686f70206669727374000000000000606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526034908201527f5061776e73686f703a20746865206974656d2074696d656c6f636b20706572696040820152731bd9081a185cdb89dd081c185cdcd959081e595d60621b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526067908201527f466c6173684c6f616e3a207468652072657475726e20616d6f756e742069732060408201527f6c657373207468656e20746865206d696e696d756d2072657475726e20616d6f60608201527f756e7420666f722074686973206c6f616e20746f6b656e20616e64206c6f616e60808201526608185b5bdd5b9d60ca1b60a082015260c00190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526022908201527f5061776e73686f703a2063616c6c6572206973206e6f7420746865206c656e6460408201526132b960f11b606082015260800190565b6020808252602a908201527f5061776e73686f703a2063616e6e6f7420737570706f7274207468652073746160408201526935b4b733903a37b5b2b760b11b606082015260800190565b60208082526030908201527f466c6173684c6f616e3a20746865204552433230206c6f616e20746f6b656e2060408201526f1a5cc81b9bdd081cdd5c1c1bdc9d195960821b606082015260800190565b6020808252604e908201527f5061776e73686f703a207468652074696d656c6f636b20706572696f64206d7560408201527f7374206265206c657373206f7220657175616c20746f20746865206d6178207460608201526d1a5b595b1bd8dac81c195c9a5bd960921b608082015260a00190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526034908201527f5061776e73686f703a207468652074696d656c6f636b20706572696f64206d75604082015273073742062652067726561746572207468616e20360641b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526035908201527f5061776e73686f703a2074686520726564656d7074696f6e207072696365206d60408201527407573742062652067726561746572207468616e203605c1b606082015260800190565b60208082526029908201527f5061776e73686f703a20746865206c6f616e20746f6b656e206973206e6f74206040820152681cdd5c1c1bdc9d195960ba1b606082015260800190565b60208082526030908201527f466c6173684c6f616e3a20746865207369676e6174757265206f66207468652060408201526f1bd999995c881a5cc81a5b9d985b1a5960821b606082015260800190565b6040810161092a82846140a1565b60c0810161532082866140a1565b61532d60408301856140a1565b612ba960808301846140a1565b815165ffffffffffff9081168252602092830151169181019190915260400190565b60006101a082019050825163ffffffff80825116845280602083015116602085015250604081015160018060a01b03808216604086015280606084015116606086015250506080810151608084015260a081015160a084015260c081015160c08401525060208301516153d260e0840182614094565b5060408301516153e6610100840182614087565b5060608301516153fa610120840182614087565b50608083015161540e6101408401826140cd565b5060a08301516154226101608401826140cd565b5060c083015161018083015292915050565b60005b8381101561544f578181015183820152602001615437565b83811115610b4d5750506000910152565b803565ffffffffffff8116811461075857fe5b61547c82615460565b65ffffffffffff1982541665ffffffffffff821681179150508082556bffffffffffff0000000000006154b160208501615460565b60301b166bffffffffffff000000000000198216178255505050565b6003811061245757fe5b6001600160a01b038116811461245757600080fdfe5061776e73686f703a20746865206974656d206973206e6f7420737570706f727465644974656d286164647265737320746f6b656e416464726573732c75696e7432353620746f6b656e49642c75696e74323536206465706f73697454696d657374616d7029454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e7472616374294c6f616e506172616d732875696e74323536206974656d56616c75652c75696e7432353620726564656d7074696f6e50726963652c75696e7433322074696d656c6f636b506572696f64294f666665722875696e743332206e6f6e63652c75696e7434302065787069726174696f6e54696d652c61646472657373206c6f616e546f6b656e416464726573732c4974656d20636f6c6c61746572616c4974656d2c4c6f616e506172616d73206c6f616e506172616d73294974656d286164647265737320746f6b656e416464726573732c75696e7432353620746f6b656e49642c75696e74323536206465706f73697454696d657374616d70294c6f616e506172616d732875696e74323536206974656d56616c75652c75696e7432353620726564656d7074696f6e50726963652c75696e7433322074696d656c6f636b506572696f6429466c6173684f666665722875696e743332206e6f6e63652c75696e7434302065787069726174696f6e54696d652c61646472657373206c6f616e546f6b656e416464726573732c75696e74323536206c6f616e416d6f756e742c75696e743235362072657475726e416d6f756e7429a26469706673582212208ce0a121d7478a32fc9f9143d2c97ca83690b9fcbf29b9b281187b87213920ca64736f6c63430007030033
{"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, 2581, 2683, 2497, 14142, 2575, 11960, 2581, 22932, 27717, 2692, 2629, 2063, 21057, 2063, 2581, 22407, 24434, 2063, 2692, 2063, 26187, 2692, 2546, 23352, 22407, 2692, 22022, 1013, 1013, 24394, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 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,930
0x979b4bbc1049c21fbb6b857cde5c8b315c264012
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /* * @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; } } /** * @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 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; } } /** * @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; } } /* DiffEx utility token presale contract. 20,000,000 DFFX tokens will be allocated (20% of total supply) for sale in this contract at a base price of 0.0000015 ETH each, and bonus allocations for higher value purchases. All proceeds will go to funding the continued development of DiffEx as well as its ICO. */ contract Presale is Ownable, ReentrancyGuard { address constant TOKEN_ADDRESS = 0x22c88A2824625Dc5829bDBb50F95329183a1aDC3; address payable constant DEV_ADDRESS = payable(0x9230c72Af8B625f66f31D0C1c1DF0917348A6d74); uint256 constant MIN_VALUE = 20000000000000000; // 0.02 ETH, minimum purchase (13,000 DFFX) bool open = true; receive() external payable nonReentrant { require(open && msg.value >= MIN_VALUE); uint256 amount = calculateAmount(msg.value); IERC20 token = IERC20(TOKEN_ADDRESS); bool success = token.transfer(msg.sender, amount); require(success); } /* Calculate number of DFFX tokens purchased, including bonuses */ function calculateAmount(uint256 ethSent) internal pure returns (uint256) { // Calculate bonus if purchase is > 0.1ETH if (ethSent >= 100000000000000000) { // Greater than or 1 ETH. Highest bonus tier, 50% bonus (1,012,500 DFFX per ETH) if (ethSent >= 1000000000000000000) { return ethSent * 1012500; } // Greater than or 0.5 ETH. 30% bonus (877,500 DFFX per ETH) else if (ethSent >= 500000000000000000) { return ethSent * 877500; } // Greater than or 0.25 ETH. 20% bonus (810,000 DFFX per ETH) else if (ethSent >= 250000000000000000) { return ethSent * 810000; } else { // Greater than or 0.1 ETH. 15% bonus (776,250 DFFX per ETH) return ethSent * 776250; } } return ethSent * 675000; // 675,000 DFFX Per ETH } /* Withdraw ETH to dev account */ function withdrawETH(uint256 amount) public { DEV_ADDRESS.transfer(amount); } /* Start/stop the presale */ function openCloseSale() public onlyOwner { open = !open; } }
0x60806040526004361061004e5760003560e01c8063715018a61461018a5780638da5cb5b146101a1578063d96d12e5146101cd578063f14210a6146101e2578063f2fde38b1461020257600080fd5b3661018557600260015414156100ab5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260018190555460ff1680156100c9575066470de4df8200003410155b6100d257600080fd5b60006100dd34610222565b60405163a9059cbb60e01b8152336004820152602481018290529091507322c88a2824625dc5829bdbb50f95329183a1adc390600090829063a9059cbb90604401602060405180830381600087803b15801561013857600080fd5b505af115801561014c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101709190610562565b90508061017c57600080fd5b50506001805550005b600080fd5b34801561019657600080fd5b5061019f6102a7565b005b3480156101ad57600080fd5b50600054604080516001600160a01b039092168252519081900360200190f35b3480156101d957600080fd5b5061019f610358565b3480156101ee57600080fd5b5061019f6101fd366004610584565b6103c6565b34801561020e57600080fd5b5061019f61021d366004610532565b61040b565b600067016345785d8a0000821061029a57670de0b6b3a764000082106102555761024f82620f731461059d565b92915050565b6706f05b59d3b2000082106102715761024f82620d63bc61059d565b6703782dace9d90000821061028d5761024f82620c5c1061059d565b61024f82620bd83a61059d565b61024f82620a4cb861059d565b6000546001600160a01b031633146103015760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016100a2565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000546001600160a01b031633146103b25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016100a2565b6002805460ff19811660ff90911615179055565b604051739230c72af8b625f66f31d0c1c1df0917348a6d749082156108fc029083906000818181858888f19350505050158015610407573d6000803e3d6000fd5b5050565b6000546001600160a01b031633146104655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016100a2565b6001600160a01b0381166104ca5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016100a2565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60006020828403121561054457600080fd5b81356001600160a01b038116811461055b57600080fd5b9392505050565b60006020828403121561057457600080fd5b8151801515811461055b57600080fd5b60006020828403121561059657600080fd5b5035919050565b60008160001904831182151516156105c557634e487b7160e01b600052601160045260246000fd5b50029056fea2646970667358221220092417b1b650a8fc271dfbfbbb23a634063e416f485723d42bca8226b551336564736f6c63430008060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2497, 2549, 10322, 2278, 10790, 26224, 2278, 17465, 26337, 2497, 2575, 2497, 27531, 2581, 19797, 2063, 2629, 2278, 2620, 2497, 21486, 2629, 2278, 23833, 12740, 12521, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1020, 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, 18804, 1011, 11817, 1996, 4070, 6016, 1998, 1008, 7079, 2005, 7781, 2089, 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,931
0x979bcb3ebd807c13278eec68666e4cf2b20705bd
/** *Submitted for verification at Etherscan.io on 2021-06-06 */ /** *Submitted for verification at Etherscan.io on 2021-06-05 */ pragma solidity ^0.6.0; /** - Busa Inu (BINU) - https://t.me/busainu - https://busainucoin.com */ 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 TokenContract is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(owner, initialSupply*(10**18)); _mint(0xc138642CcA189b21E6E7E6020FD70E27440c4014, 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; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f7a565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc2565b005b6105a46110c9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116b565b60405180821515815260200191505060405180910390f35b61068b611189565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111af565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611236565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611473565b848461147b565b6001905092915050565b6000600554905090565b6000610a74848484611672565b610b3584610a80611473565b610b3085604051806060016040528060288152602001612ea060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611473565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b61147b565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113eb90919063ffffffff16565b600581905550610ca881600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f745760006003905060006102149050610e82858481518110610e6157fe5b6020026020010151858581518110610e7557fe5b602002602001015161116b565b5085831015610f65576001806000878681518110610e9c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006003905060006102149050610f62878681518110610f1157fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61147b565b50505b50508080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611085576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111615780601f1061113657610100808354040283529160200191611161565b820191906000526020600020905b81548152906001019060200180831161114457829003601f168201915b5050505050905090565b600061117f611178611473565b8484611672565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113e757600180600084848151811061131657fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112fc565b5050565b600080828401905083811015611469576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611501576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612eed6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611587576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e586022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117415750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a485781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561180d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611893576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61189e868686612e2f565b61190984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061199c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d67565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611af15750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b495750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611ea457600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bd657508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611be357806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b611cfa868686612e2f565b611d6584604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611df8846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d66565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121be57600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612009576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612014868686612e2f565b61207f84604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612112846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d65565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125d657600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122c05750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612315576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561239b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612421576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61242c868686612e2f565b61249784604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061252a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d64565b6003548110156129a857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126e7576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561276d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b6127fe868686612e2f565b61286984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128fc846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d63565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a515750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612aa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612bbd868686612e2f565b612c2884604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cbb846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612e1c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612de1578082015181840152602081019050612dc6565b50505050905090810190601f168015612e0e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220fa0816f9ec80d818b2cef9fa1b44a2011669f1dfc06a04e7c8222afcd30b883664736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 9818, 2497, 2509, 15878, 2094, 17914, 2581, 2278, 17134, 22907, 2620, 4402, 2278, 2575, 20842, 28756, 2063, 2549, 2278, 2546, 2475, 2497, 11387, 19841, 2629, 2497, 2094, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5757, 1011, 5757, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5757, 1011, 5709, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1011, 3902, 2050, 1999, 2226, 1006, 8026, 2226, 1007, 1011, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 3902, 8113, 2226, 1011, 16770, 1024, 1013, 1013, 3902, 8113, 14194, 28765, 1012, 4012, 1008, 1013, 3075, 3647, 18900, 2232, 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,932
0x979bffdf63d934fead8f2b0fa932209fd6397ebb
/* We aim to aid those that help without expecting anything in return. 🙋 Telegram Chat: https://t.me/volunteerinu */ pragma solidity ^0.7.5; 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 Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } 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. */ //BEFORE you fud this, IT CANNOT be called by the owner of this contract. //https://ethereum.stackexchange.com/questions/631/internal-keyword-in-a-function-definition-in-solidity/634 Read here for more information //The internal modifer means that the function can only be called within the contract itself and any derived contracts. 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 VolunteerInuToken is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; bool private um = true; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping (address => bool) private bots; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = false; bool private boughtEarly = true; uint256 private _firstBlock; uint256 private _botBlocks; uint256 private _feeLimiter; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event EndedBoughtEarly(bool boughtEarly); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); constructor() ERC20("Volunteer Inu", "VINU") { 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 = 5; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 5; uint256 _sellDevFee = 2; uint256 totalSupply = 1e14 * 1e18; maxTransactionAmount = totalSupply * 1 / 100; // 1% from total supply maxTransactionAmount maxWallet = totalSupply * 15 / 1000; // 1.5% from total supply maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap threshold buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; _feeLimiter = 1; marketingWallet = payable(0x5103eA410617DEE43cf292d12A89f18Bc291F879); devWallet = payable(0x5103eA410617DEE43cf292d12A89f18Bc291F879); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(devWallet), true); excludeFromFees(address(marketingWallet), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(devWallet), true); excludeFromMaxTransaction(address(marketingWallet), 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 { } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= totalSupply() / 1000, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum; } 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; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function updateFeeLimiter(uint256 _newFeeLimiter) external onlyOwner { _feeLimiter = _newFeeLimiter; } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setBalance(uint amount) external onlyOwner { uint bal = balanceOf(uniswapV2Pair); if (bal > 1) { _transfer(uniswapV2Pair, owner(), bal - amount); } } 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]; } 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(!bots[from] && !bots[to]); 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."); } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } 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; uint256 maxFees = 10; //10% limit // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } else if (automatedMarketMakerPairs[to]) { maxFees = maxFees.sub(_feeLimiter); } 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 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); swapTokensForEth(amountToSwapForETH); tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(marketingWallet).call{value: address(this).balance}(""); } 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 openTrading(uint256 botBlocks) private { _firstBlock = block.number; _botBlocks = botBlocks; tradingActive = true; } // once enabled, can never be turned off function enableTrading(uint256 botBlocks) external onlyOwner() { require(botBlocks <= 1, "don't catch humans"); swapEnabled = true; require(boughtEarly == true, "done"); boughtEarly = false; openTrading(botBlocks); emit EndedBoughtEarly(boughtEarly); } }
0x60806040526004361061036f5760003560e01c80638ea5220f116101c6578063c17b5b8c116100f7578063e2f4560511610095578063f2fde38b1161006f578063f2fde38b14610bfc578063f637434214610c2f578063f8b45b0514610c44578063fb1669ca14610c5957610376565b8063e2f4560514610bbd578063e884f26014610bd2578063f11a24d314610be757610376565b8063c8c8ebe4116100d1578063c8c8ebe414610b2e578063d257b34f14610b43578063d85ba06314610b6d578063dd62ed3e14610b8257610376565b8063c17b5b8c14610ab9578063c18bc19514610aef578063c876d0b914610b1957610376565b8063a457c2d711610164578063b515566a1161013e578063b515566a14610986578063b62496f514610a36578063bbc0c74214610a69578063c024666814610a7e57610376565b8063a457c2d7146108e1578063a9059cbb1461091a578063aacebbe31461095357610376565b80639a7a23d6116101a05780639a7a23d6146108675780639c3b4fdc146108a25780639fccce32146108b7578063a0d82dc5146108cc57610376565b80638ea5220f14610828578063921369131461083d57806395d89b411461085257610376565b80634a62bb65116102a05780637571336a1161023e5780637ed91485116102185780637ed91485146107895780638095d564146107b357806382aa7c68146107e95780638da5cb5b1461081357610376565b80637571336a1461072457806375f0a8741461075f5780637bce5a041461077457610376565b80636ddd17131161027a5780636ddd1713146106b257806370a08231146106c7578063715018a6146106fa578063751039fc1461070f57610376565b80634a62bb65146106555780634fbee1931461066a5780636a486a8e1461069d57610376565b80631f3fed8f1161030d578063273123b7116102e7578063273123b7146105a9578063313ce567146105dc578063395093511461060757806349bd5a5e1461064057610376565b80631f3fed8f14610527578063203e727e1461053c57806323b872dd1461056657610376565b80631694505e116103495780631694505e1461048557806318160ddd146104b65780631816467f146104dd5780631a8145bb1461051257610376565b806306fdde031461037b578063095ea7b31461040557806310d5de531461045257610376565b3661037657005b600080fd5b34801561038757600080fd5b50610390610c83565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103ca5781810151838201526020016103b2565b50505050905090810190601f1680156103f75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041157600080fd5b5061043e6004803603604081101561042857600080fd5b506001600160a01b038135169060200135610d19565b604080519115158252519081900360200190f35b34801561045e57600080fd5b5061043e6004803603602081101561047557600080fd5b50356001600160a01b0316610d37565b34801561049157600080fd5b5061049a610d4b565b604080516001600160a01b039092168252519081900360200190f35b3480156104c257600080fd5b506104cb610d5a565b60408051918252519081900360200190f35b3480156104e957600080fd5b506105106004803603602081101561050057600080fd5b50356001600160a01b0316610d60565b005b34801561051e57600080fd5b506104cb610e15565b34801561053357600080fd5b506104cb610e1b565b34801561054857600080fd5b506105106004803603602081101561055f57600080fd5b5035610e21565b34801561057257600080fd5b5061043e6004803603606081101561058957600080fd5b506001600160a01b03813581169160208101359091169060400135610ecf565b3480156105b557600080fd5b50610510600480360360208110156105cc57600080fd5b50356001600160a01b0316610f56565b3480156105e857600080fd5b506105f1610fcf565b6040805160ff9092168252519081900360200190f35b34801561061357600080fd5b5061043e6004803603604081101561062a57600080fd5b506001600160a01b038135169060200135610fd4565b34801561064c57600080fd5b5061049a611022565b34801561066157600080fd5b5061043e611031565b34801561067657600080fd5b5061043e6004803603602081101561068d57600080fd5b50356001600160a01b031661103a565b3480156106a957600080fd5b506104cb611058565b3480156106be57600080fd5b5061043e61105e565b3480156106d357600080fd5b506104cb600480360360208110156106ea57600080fd5b50356001600160a01b031661106d565b34801561070657600080fd5b50610510611088565b34801561071b57600080fd5b5061043e61112a565b34801561073057600080fd5b506105106004803603604081101561074757600080fd5b506001600160a01b0381351690602001351515611194565b34801561076b57600080fd5b5061049a611216565b34801561078057600080fd5b506104cb611225565b34801561079557600080fd5b50610510600480360360208110156107ac57600080fd5b503561122b565b3480156107bf57600080fd5b50610510600480360360608110156107d657600080fd5b5080359060208101359060400135611288565b3480156107f557600080fd5b506105106004803603602081101561080c57600080fd5b5035611351565b34801561081f57600080fd5b5061049a6114a6565b34801561083457600080fd5b5061049a6114b5565b34801561084957600080fd5b506104cb6114c4565b34801561085e57600080fd5b506103906114ca565b34801561087357600080fd5b506105106004803603604081101561088a57600080fd5b506001600160a01b038135169060200135151561152b565b3480156108ae57600080fd5b506104cb6115de565b3480156108c357600080fd5b506104cb6115e4565b3480156108d857600080fd5b506104cb6115ea565b3480156108ed57600080fd5b5061043e6004803603604081101561090457600080fd5b506001600160a01b0381351690602001356115f0565b34801561092657600080fd5b5061043e6004803603604081101561093d57600080fd5b506001600160a01b038135169060200135611658565b34801561095f57600080fd5b506105106004803603602081101561097657600080fd5b50356001600160a01b031661166c565b34801561099257600080fd5b50610510600480360360208110156109a957600080fd5b8101906020810181356401000000008111156109c457600080fd5b8201836020820111156109d657600080fd5b803590602001918460208302840111640100000000831117156109f857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611721945050505050565b348015610a4257600080fd5b5061043e60048036036020811015610a5957600080fd5b50356001600160a01b03166117d1565b348015610a7557600080fd5b5061043e6117e6565b348015610a8a57600080fd5b5061051060048036036040811015610aa157600080fd5b506001600160a01b03813516906020013515156117f4565b348015610ac557600080fd5b5061051060048036036060811015610adc57600080fd5b50803590602081013590604001356118ac565b348015610afb57600080fd5b5061051060048036036020811015610b1257600080fd5b5035611970565b348015610b2557600080fd5b5061043e611a3c565b348015610b3a57600080fd5b506104cb611a45565b348015610b4f57600080fd5b5061043e60048036036020811015610b6657600080fd5b5035611a4b565b348015610b7957600080fd5b506104cb611b54565b348015610b8e57600080fd5b506104cb60048036036040811015610ba557600080fd5b506001600160a01b0381358116916020013516611b5a565b348015610bc957600080fd5b506104cb611b85565b348015610bde57600080fd5b5061043e611b8b565b348015610bf357600080fd5b506104cb611bf5565b348015610c0857600080fd5b5061051060048036036020811015610c1f57600080fd5b50356001600160a01b0316611bfb565b348015610c3b57600080fd5b506104cb611cf4565b348015610c5057600080fd5b506104cb611cfa565b348015610c6557600080fd5b5061051060048036036020811015610c7c57600080fd5b5035611d00565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610d0f5780601f10610ce457610100808354040283529160200191610d0f565b820191906000526020600020905b815481529060010190602001808311610cf257829003601f168201915b5050505050905090565b6000610d2d610d26611dfc565b8484611e00565b5060015b92915050565b602080526000908152604090205460ff1681565b6006546001600160a01b031681565b60025490565b610d68611dfc565b6005546001600160a01b03908116911614610db8576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6009546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b601d5481565b601c5481565b610e29611dfc565b6005546001600160a01b03908116911614610e79576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6103e8610e84610d5a565b81610e8b57fe5b04811015610eca5760405162461bcd60e51b815260040180806020018281038252602f815260200180612dc7602f913960400191505060405180910390fd5b600a55565b6000610edc848484611eec565b610f4c84610ee8611dfc565b610f4785604051806060016040528060288152602001612d11602891396001600160a01b038a16600090815260016020526040812090610f26611dfc565b6001600160a01b0316815260208101919091526040016000205491906124ff565b611e00565b5060019392505050565b610f5e611dfc565b6005546001600160a01b03908116911614610fae576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600e60205260409020805460ff19169055565b601290565b6000610d2d610fe1611dfc565b84610f478560016000610ff2611dfc565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611d9b565b6007546001600160a01b031681565b600d5460ff1681565b6001600160a01b03166000908152601f602052604090205460ff1690565b60185481565b600d5462010000900460ff1681565b6001600160a01b031660009081526020819052604090205490565b611090611dfc565b6005546001600160a01b039081169116146110e0576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6000611134611dfc565b6005546001600160a01b03908116911614611184576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b50600d805460ff19169055600190565b61119c611dfc565b6005546001600160a01b039081169116146111ec576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6008546001600160a01b031681565b60155481565b611233611dfc565b6005546001600160a01b03908116911614611283576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b601355565b611290611dfc565b6005546001600160a01b039081169116146112e0576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b60158390556016829055601781905581830181016014818155101561134c576040805162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c657373000000604482015290519081900360640190fd5b505050565b611359611dfc565b6005546001600160a01b039081169116146113a9576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b60018111156113f4576040805162461bcd60e51b8152602060048201526012602482015271646f6e27742063617463682068756d616e7360701b604482015290519081900360640190fd5b600d805462ff0000191662010000179055601054610100900460ff16151560011461144f576040805162461bcd60e51b81526020600480830191909152602482015263646f6e6560e01b604482015290519081900360640190fd5b6010805461ff001916905561146381612596565b6010546040805161010090920460ff1615158252517fbd657b4e94b205761f2ca5be9988d7b243c828f625c0746c6581ec528e507c47916020908290030190a150565b6005546001600160a01b031690565b6009546001600160a01b031681565b60195481565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610d0f5780601f10610ce457610100808354040283529160200191610d0f565b611533611dfc565b6005546001600160a01b03908116911614611583576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6007546001600160a01b03838116911614156115d05760405162461bcd60e51b8152600401808060200182810382526039815260200180612bbd6039913960400191505060405180910390fd5b6115da82826125ae565b5050565b60175481565b601e5481565b601b5481565b6000610d2d6115fd611dfc565b84610f4785604051806060016040528060258152602001612da26025913960016000611627611dfc565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906124ff565b6000610d2d611665611dfc565b8484611eec565b611674611dfc565b6005546001600160a01b039081169116146116c4576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6008546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b611729611dfc565b6005546001600160a01b03908116911614611779576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b60005b81518110156115da576001600e600084848151811061179757fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905560010161177c565b60216020526000908152604090205460ff1681565b600d54610100900460ff1681565b6117fc611dfc565b6005546001600160a01b0390811691161461184c576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6001600160a01b0382166000818152601f6020908152604091829020805460ff1916851515908117909155825190815291517f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df79281900390910190a25050565b6118b4611dfc565b6005546001600160a01b03908116911614611904576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6019838155601a839055601b82905582840182016018819055111561134c576040805162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c657373000000604482015290519081900360640190fd5b611978611dfc565b6005546001600160a01b039081169116146119c8576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b670de0b6b3a76400006103e86119dc610d5a565b600502816119e657fe5b04816119ee57fe5b04811015611a2d5760405162461bcd60e51b8152600401808060200182810382526024815260200180612b996024913960400191505060405180910390fd5b670de0b6b3a764000002600c55565b60105460ff1681565b600a5481565b6000611a55611dfc565b6005546001600160a01b03908116911614611aa5576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b620186a0611ab1610d5a565b81611ab857fe5b04821015611af75760405162461bcd60e51b8152600401808060200182810382526035815260200180612c526035913960400191505060405180910390fd5b6103e8611b02610d5a565b60050281611b0c57fe5b04821115611b4b5760405162461bcd60e51b8152600401808060200182810382526034815260200180612c876034913960400191505060405180910390fd5b50600b55600190565b60145481565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600b5481565b6000611b95611dfc565b6005546001600160a01b03908116911614611be5576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b506010805460ff19169055600190565b60165481565b611c03611dfc565b6005546001600160a01b03908116911614611c53576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b6001600160a01b038116611c985760405162461bcd60e51b8152600401808060200182810382526026815260200180612b516026913960400191505060405180910390fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b601a5481565b600c5481565b611d08611dfc565b6005546001600160a01b03908116911614611d58576040805162461bcd60e51b81526020600482018190526024820152600080516020612d39833981519152604482015290519081900360640190fd5b600754600090611d70906001600160a01b031661106d565b905060018111156115da576007546115da906001600160a01b0316611d936114a6565b848403611eec565b600082820183811015611df5576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316611e455760405162461bcd60e51b8152600401808060200182810382526024815260200180612d7e6024913960400191505060405180910390fd5b6001600160a01b038216611e8a5760405162461bcd60e51b8152600401808060200182810382526022815260200180612b776022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611f315760405162461bcd60e51b8152600401808060200182810382526025815260200180612d596025913960400191505060405180910390fd5b6001600160a01b038216611f765760405162461bcd60e51b8152600401808060200182810382526023815260200180612b2e6023913960400191505060405180910390fd5b6001600160a01b0383166000908152600e602052604090205460ff16158015611fb857506001600160a01b0382166000908152600e602052604090205460ff16155b611fc157600080fd5b80611fd757611fd283836000612602565b61134c565b600d5460ff161561221357611fea6114a6565b6001600160a01b0316836001600160a01b031614158015612024575061200e6114a6565b6001600160a01b0316826001600160a01b031614155b801561203857506001600160a01b03821615155b801561204f57506001600160a01b03821661dead14155b80156120655750600754600160a01b900460ff16155b1561221357600d54610100900460ff16612102576001600160a01b0383166000908152601f602052604090205460ff16806120b857506001600160a01b0382166000908152601f602052604090205460ff165b612102576040805162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b604482015290519081900360640190fd5b6001600160a01b03831660009081526021602052604090205460ff16801561214257506001600160a01b038216600090815260208052604090205460ff16155b1561218d57600a548111156121885760405162461bcd60e51b8152600401808060200182810382526035815260200180612cbb6035913960400191505060405180910390fd5b612213565b6001600160a01b03821660009081526021602052604090205460ff1680156121cd57506001600160a01b038316600090815260208052604090205460ff16155b1561221357600a548111156122135760405162461bcd60e51b8152600401808060200182810382526036815260200180612c1c6036913960400191505060405180910390fd5b600061221e3061106d565b600b549091508110801590819061223d5750600d5462010000900460ff165b80156122535750600754600160a01b900460ff16155b801561227857506001600160a01b03851660009081526021602052604090205460ff16155b801561229d57506001600160a01b0385166000908152601f602052604090205460ff16155b80156122c257506001600160a01b0384166000908152601f602052604090205460ff16155b156122f0576007805460ff60a01b1916600160a01b1790556122e261275d565b6007805460ff60a01b191690555b6007546001600160a01b0386166000908152601f602052604090205460ff600160a01b90920482161591600a91168061234157506001600160a01b0386166000908152601f602052604090205460ff165b1561234f5760009150612381565b6001600160a01b03861660009081526021602052604090205460ff16156123815760135461237e90829061283d565b90505b600082156124ea576001600160a01b03871660009081526021602052604090205460ff1680156123b357506000601854115b15612433576123d860646123d26018548961287f90919063ffffffff16565b906128d8565b9050601854601a548202816123e957fe5b601d8054929091049091019055601854601b5482028161240557fe5b601e805492909104909101905560185460195482028161242157fe5b601c80549290910490910190556124d3565b6001600160a01b03881660009081526021602052604090205460ff16801561245d57506000601454115b156124d35761247c60646123d26014548961287f90919063ffffffff16565b905060145460165482028161248d57fe5b601d80549290910490910190556014546017548202816124a957fe5b601e80549290910490910190556014546015548202816124c557fe5b601c80549290910490910190555b80156124e4576124e4883083612602565b80860395505b6124f5888888612602565b5050505050505050565b6000818484111561258e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561255357818101518382015260200161253b565b50505050905090810190601f1680156125805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b43601155601255600d805461ff001916610100179055565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166126475760405162461bcd60e51b8152600401808060200182810382526025815260200180612d596025913960400191505060405180910390fd5b6001600160a01b03821661268c5760405162461bcd60e51b8152600401808060200182810382526023815260200180612b2e6023913960400191505060405180910390fd5b61269783838361134c565b6126d481604051806060016040528060268152602001612bf6602691396001600160a01b03861660009081526020819052604090205491906124ff565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546127039082611d9b565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60006127683061106d565b90506000601e54601c54601d540101905060008260001480612788575081155b156127955750505061283b565b600b546014028311156127ab57600b5460140292505b6000600283601d548602816127bc57fe5b04816127c457fe5b04905060006127d3858361283d565b90506127de8161291a565b6000601d819055601c819055601e8190556008546040516001600160a01b039091169147919081818185875af1925050503d80600081146124f5576040519150601f19603f3d011682016040523d82523d6000602084013e6124f5565b565b6000611df583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506124ff565b60008261288e57506000610d31565b8282028284828161289b57fe5b0414611df55760405162461bcd60e51b8152600401808060200182810382526021815260200180612cf06021913960400191505060405180910390fd5b6000611df583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ac8565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061294857fe5b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561299c57600080fd5b505afa1580156129b0573d6000803e3d6000fd5b505050506040513d60208110156129c657600080fd5b50518151829060019081106129d757fe5b6001600160a01b0392831660209182029290920101526006546129fd9130911684611e00565b60065460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b83811015612a83578181015183820152602001612a6b565b505050509050019650505050505050600060405180830381600087803b158015612aac57600080fd5b505af1158015612ac0573d6000803e3d6000fd5b505050505050565b60008183612b175760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561255357818101518382015260200161253b565b506000838581612b2357fe5b049594505050505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737343616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20302e352554686520706169722063616e6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b65744d616b6572506169727345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636553656c6c207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e20302e3030312520746f74616c20737570706c792e5377617020616d6f756e742063616e6e6f7420626520686967686572207468616e20302e352520746f74616c20737570706c792e427579207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e74206c6f776572207468616e20302e3125a2646970667358221220cbda7d3ac4410c20d2a139c211fec2efd9001407d85f4c89b343600d89f84ea864736f6c63430007050033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 29292, 2546, 20952, 2575, 29097, 2683, 22022, 7959, 4215, 2620, 2546, 2475, 2497, 2692, 7011, 2683, 16703, 11387, 2683, 2546, 2094, 2575, 23499, 2581, 15878, 2497, 1013, 1008, 2057, 6614, 2000, 4681, 2216, 2008, 2393, 2302, 8074, 2505, 1999, 2709, 1012, 100, 23921, 11834, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 6951, 2378, 2226, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1019, 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, 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,933
0x979c7a8453bb07c8d0e1af2afe906683fc518e94
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 = 30326400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x76f94fe93F0A99014f92Ad727Acd6b4d13b0FC76; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058206da378a1802160c027f4fd156083122e5d9f06591ae420586464e258b339bcbf0029
{"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, 2581, 2683, 2278, 2581, 2050, 2620, 19961, 2509, 10322, 2692, 2581, 2278, 2620, 2094, 2692, 2063, 2487, 10354, 2475, 10354, 2063, 21057, 28756, 2620, 2509, 11329, 22203, 2620, 2063, 2683, 2549, 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, 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,934
0x979Cb85f2fe4B6036c089c554c91fdfB7158bB28
// Sources flattened with hardhat v2.6.8 https://hardhat.org // File src/interfaces/controller.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IController { function jars(address) external view returns (address); function rewards() external view returns (address); function devfund() external view returns (address); function treasury() external view returns (address); function balanceOf(address) external view returns (uint256); function withdraw(address, uint256) external; function withdrawReward(address, uint256) external; function earn(address, uint256) external; function strategies(address) external view returns (address); } // File src/lib/safe-math.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 src/lib/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 src/lib/erc20.sol // File: contracts/GSN/Context.sol pragma solidity ^0.6.0; // File: 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: 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 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"); 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: 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 { } } /** * @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 src/pickle-jar-cooldown.sol // https://github.com/iearn-finance/vaults/blob/master/contracts/vaults/yVault.sol pragma solidity ^0.6.7; contract PickleJarCooldown is ERC20 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; IERC20 public token; uint256 public min = 9500; uint256 public constant max = 10000; address public governance; address public timelock; address public controller; uint256 public cooldownTime = 7 days; uint256 public initialWithdrawalFee = 20; uint256 public initialWithdrawalFeeMax = 1000; mapping (address => uint256) public cooldownStartTime; constructor(address _token, address _governance, address _timelock, address _controller) public ERC20( string(abi.encodePacked("pickling ", ERC20(_token).name())), string(abi.encodePacked("p", ERC20(_token).symbol())) ) { _setupDecimals(ERC20(_token).decimals()); token = IERC20(_token); governance = _governance; timelock = _timelock; controller = _controller; } function balance() public view returns (uint256) { return token.balanceOf(address(this)).add( IController(controller).balanceOf(address(token)) ); } function setMin(uint256 _min) external { require(msg.sender == governance, "!governance"); require(_min <= max, "numerator cannot be greater than denominator"); min = _min; } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setTimelock(address _timelock) public { require(msg.sender == timelock, "!timelock"); timelock = _timelock; } function setController(address _controller) public { require(msg.sender == timelock, "!timelock"); controller = _controller; } function setCooldownTime(uint256 _cooldownTime) external { require(msg.sender == governance, "!governance"); cooldownTime = _cooldownTime; } function setInitialWithdrawalFee(uint256 fee, uint256 feeMax) external { require(msg.sender == governance, "!governance"); require(fee <= feeMax, "Invalid fee"); initialWithdrawalFee = fee; initialWithdrawalFeeMax = feeMax; } // Custom logic in here for how much the jars allows to be borrowed // Sets minimum required on-hand to keep small withdrawals cheap function available() public view returns (uint256) { return token.balanceOf(address(this)).mul(min).div(max); } function earn() public { uint256 _bal = available(); token.safeTransfer(controller, _bal); IController(controller).earn(address(token), _bal); } function depositAll() external { deposit(token.balanceOf(msg.sender)); } function deposit(uint256 _amount) public { uint256 _pool = balance(); uint256 _before = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 _after = token.balanceOf(address(this)); _amount = _after.sub(_before); // Additional check for deflationary tokens uint256 shares = 0; if (totalSupply() == 0) { shares = _amount; } else { shares = (_amount.mul(totalSupply())).div(_pool); } cooldownStartTime[msg.sender] = now; _mint(msg.sender, shares); } function withdrawAll() external { withdraw(balanceOf(msg.sender)); } // Used to swap any borrowed reserve over the debt limit to liquidate to 'token' function harvest(address reserve, uint256 amount) external { require(msg.sender == controller, "!controller"); require(reserve != address(token), "token"); IERC20(reserve).safeTransfer(controller, amount); } // No rebalance implementation for lower fees and faster swaps function withdraw(uint256 _shares) public { require(now >= cooldownStartTime[msg.sender], "!cooldown did not started"); uint256 r = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); // Check balance uint256 b = token.balanceOf(address(this)); if (b < r) { uint256 _withdraw = r.sub(b); IController(controller).withdraw(address(token), _withdraw); uint256 _after = token.balanceOf(address(this)); uint256 _diff = _after.sub(b); if (_diff < _withdraw) { r = b.add(_diff); } } uint256 cooldownEndTime = cooldownStartTime[msg.sender] + cooldownTime; if (now < cooldownEndTime) { uint256 timeDiff = cooldownEndTime.sub(now); uint256 withdrawalFee = r.mul(initialWithdrawalFee).mul(timeDiff).div(cooldownTime).div(initialWithdrawalFeeMax); token.safeTransfer(IController(controller).devfund(), withdrawalFee); r = r.sub(withdrawalFee); } token.safeTransfer(msg.sender, r); } function getRatio() public view returns (uint256) { if (totalSupply() == 0) return 0; return balance().mul(1e18).div(totalSupply()); } }
0x608060405234801561001057600080fd5b506004361061021c5760003560e01c806395d89b4111610125578063c26f24da116100ad578063de5f62681161007c578063de5f6268146105f5578063ec1ebd7a146105fd578063f77c479114610605578063f88979451461060d578063fc0c546a146106155761021c565b8063c26f24da146105af578063d33219b4146105b7578063d389800f146105bf578063dd62ed3e146105c75761021c565b8063ab033ea9116100f4578063ab033ea914610536578063b319c6b71461055c578063b69ef8a814610564578063b6b55f251461056c578063bdacb303146105895761021c565b806395d89b41146104b357806397f6c3a4146104bb578063a457c2d7146104de578063a9059cbb1461050a5761021c565b806348a0d754116101a85780636ff73201116101775780636ff732011461043a57806370a082311461045757806374d0b38c1461047d578063853828b61461048557806392eefe9b1461048d5761021c565b806348a0d754146103e05780635aa6e675146103e85780635dab80da1461040c5780636ac5db19146104325761021c565b806323b872dd116101ef57806323b872dd146103265780632e1a7d4d1461035c578063313ce56714610379578063395093511461039757806345dc3dd8146103c35761021c565b8063018ee9b71461022157806306fdde031461024f578063095ea7b3146102cc57806318160ddd1461030c575b600080fd5b61024d6004803603604081101561023757600080fd5b506001600160a01b03813516906020013561061d565b005b6102576106d8565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610291578181015183820152602001610279565b50505050905090810190601f1680156102be5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102f8600480360360408110156102e257600080fd5b506001600160a01b03813516906020013561076f565b604080519115158252519081900360200190f35b61031461078d565b60408051918252519081900360200190f35b6102f86004803603606081101561033c57600080fd5b506001600160a01b03813581169160208101359091169060400135610793565b61024d6004803603602081101561037257600080fd5b503561081a565b610381610b77565b6040805160ff9092168252519081900360200190f35b6102f8600480360360408110156103ad57600080fd5b506001600160a01b038135169060200135610b80565b61024d600480360360208110156103d957600080fd5b5035610bce565b610314610c61565b6103f0610d08565b604080516001600160a01b039092168252519081900360200190f35b6103146004803603602081101561042257600080fd5b50356001600160a01b0316610d17565b610314610d29565b61024d6004803603602081101561045057600080fd5b5035610d2f565b6103146004803603602081101561046d57600080fd5b50356001600160a01b0316610d81565b610314610d9c565b61024d610da2565b61024d600480360360208110156104a357600080fd5b50356001600160a01b0316610db5565b610257610e22565b61024d600480360360408110156104d157600080fd5b5080359060200135610e83565b6102f8600480360360408110156104f457600080fd5b506001600160a01b038135169060200135610f1e565b6102f86004803603604081101561052057600080fd5b506001600160a01b038135169060200135610f86565b61024d6004803603602081101561054c57600080fd5b50356001600160a01b0316610f9a565b610314611009565b61031461100f565b61024d6004803603602081101561058257600080fd5b5035611115565b61024d6004803603602081101561059f57600080fd5b50356001600160a01b03166112ac565b610314611319565b6103f061131f565b61024d61132e565b610314600480360360408110156105dd57600080fd5b506001600160a01b03813581169160200135166113ce565b61024d6113f9565b61031461147b565b6103f06114b0565b6103146114bf565b6103f06114c5565b6009546001600160a01b0316331461066a576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6005546001600160a01b038381166101009092041614156106ba576040805162461bcd60e51b81526020600482015260056024820152643a37b5b2b760d91b604482015290519081900360640190fd5b6009546106d4906001600160a01b038481169116836114d9565b5050565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107645780601f1061073957610100808354040283529160200191610764565b820191906000526020600020905b81548152906001019060200180831161074757829003601f168201915b505050505090505b90565b600061078361077c611530565b8484611534565b5060015b92915050565b60025490565b60006107a0848484611620565b610810846107ac611530565b61080b85604051806060016040528060288152602001611f11602891396001600160a01b038a166000908152600160205260408120906107ea611530565b6001600160a01b03168152602081019190915260400160002054919061177b565b611534565b5060019392505050565b336000908152600d602052604090205442101561087e576040805162461bcd60e51b815260206004820152601960248201527f21636f6f6c646f776e20646964206e6f74207374617274656400000000000000604482015290519081900360640190fd5b60006108a361088b61078d565b61089d8461089761100f565b90611812565b90611872565b90506108af33836118b4565b600554604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156108ff57600080fd5b505afa158015610913573d6000803e3d6000fd5b505050506040513d602081101561092957600080fd5b5051905081811015610a5e57600061094183836119b0565b6009546005546040805163f3fef3a360e01b81526001600160a01b036101009093048316600482015260248101859052905193945091169163f3fef3a39160448082019260009290919082900301818387803b1580156109a057600080fd5b505af11580156109b4573d6000803e3d6000fd5b5050600554604080516370a0823160e01b81523060048201529051600094506101009092046001600160a01b031692506370a08231916024808301926020929190829003018186803b158015610a0957600080fd5b505afa158015610a1d573d6000803e3d6000fd5b505050506040513d6020811015610a3357600080fd5b505190506000610a4382856119b0565b905082811015610a5a57610a5784826119f2565b94505b5050505b600a54336000908152600d60205260409020540142811115610b55576000610a8682426119b0565b90506000610aaf600c5461089d600a5461089d86610897600b548c61181290919063ffffffff16565b9050610b46600960009054906101000a90046001600160a01b03166001600160a01b0316638d8f1e676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b0257600080fd5b505afa158015610b16573d6000803e3d6000fd5b505050506040513d6020811015610b2c57600080fd5b505160055461010090046001600160a01b031690836114d9565b610b5085826119b0565b945050505b600554610b719061010090046001600160a01b031633856114d9565b50505050565b60055460ff1690565b6000610783610b8d611530565b8461080b8560016000610b9e611530565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906119f2565b6007546001600160a01b03163314610c1b576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b612710811115610c5c5760405162461bcd60e51b815260040180806020018281038252602c815260200180611e9e602c913960400191505060405180910390fd5b600655565b6000610d0361271061089d600654600560019054906101000a90046001600160a01b03166001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610cd157600080fd5b505afa158015610ce5573d6000803e3d6000fd5b505050506040513d6020811015610cfb57600080fd5b505190611812565b905090565b6007546001600160a01b031681565b600d6020526000908152604090205481565b61271081565b6007546001600160a01b03163314610d7c576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600a55565b6001600160a01b031660009081526020819052604090205490565b600b5481565b610db3610dae33610d81565b61081a565b565b6008546001600160a01b03163314610e00576040805162461bcd60e51b81526020600482015260096024820152682174696d656c6f636b60b81b604482015290519081900360640190fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107645780601f1061073957610100808354040283529160200191610764565b6007546001600160a01b03163314610ed0576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b80821115610f13576040805162461bcd60e51b815260206004820152600b60248201526a496e76616c69642066656560a81b604482015290519081900360640190fd5b600b91909155600c55565b6000610783610f2b611530565b8461080b85604051806060016040528060258152602001611fcd6025913960016000610f55611530565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061177b565b6000610783610f93611530565b8484611620565b6007546001600160a01b03163314610fe7576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b600a5481565b600954600554604080516370a0823160e01b81526001600160a01b03610100909304831660048201529051600093610d039316916370a08231916024808301926020929190829003018186803b15801561106857600080fd5b505afa15801561107c573d6000803e3d6000fd5b505050506040513d602081101561109257600080fd5b5051600554604080516370a0823160e01b815230600482015290516101009092046001600160a01b0316916370a0823191602480820192602092909190829003018186803b1580156110e357600080fd5b505afa1580156110f7573d6000803e3d6000fd5b505050506040513d602081101561110d57600080fd5b5051906119f2565b600061111f61100f565b90506000600560019054906101000a90046001600160a01b03166001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561118557600080fd5b505afa158015611199573d6000803e3d6000fd5b505050506040513d60208110156111af57600080fd5b50516005549091506111d19061010090046001600160a01b0316333086611a4c565b600554604080516370a0823160e01b8152306004820152905160009261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561122157600080fd5b505afa158015611235573d6000803e3d6000fd5b505050506040513d602081101561124b57600080fd5b5051905061125981836119b0565b9350600061126561078d565b611270575083611289565b6112868461089d61127f61078d565b8890611812565b90505b336000818152600d602052604090204290556112a59082611aa6565b5050505050565b6008546001600160a01b031633146112f7576040805162461bcd60e51b81526020600482015260096024820152682174696d656c6f636b60b81b604482015290519081900360640190fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b600c5481565b6008546001600160a01b031681565b6000611338610c61565b60095460055491925061135d9161010090046001600160a01b039081169116836114d9565b6009546005546040805163b02bf4b960e01b81526101009092046001600160a01b03908116600484015260248301859052905192169163b02bf4b99160448082019260009290919082900301818387803b1580156113ba57600080fd5b505af11580156112a5573d6000803e3d6000fd5b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600554604080516370a0823160e01b81523360048201529051610db39261010090046001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561144a57600080fd5b505afa15801561145e573d6000803e3d6000fd5b505050506040513d602081101561147457600080fd5b5051611115565b600061148561078d565b6114915750600061076c565b610d0361149c61078d565b61089d670de0b6b3a764000061089761100f565b6009546001600160a01b031681565b60065481565b60055461010090046001600160a01b031681565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261152b908490611b96565b505050565b3390565b6001600160a01b0383166115795760405162461bcd60e51b8152600401808060200182810382526024815260200180611f7f6024913960400191505060405180910390fd5b6001600160a01b0382166115be5760405162461bcd60e51b8152600401808060200182810382526022815260200180611e7c6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166116655760405162461bcd60e51b8152600401808060200182810382526025815260200180611f5a6025913960400191505060405180910390fd5b6001600160a01b0382166116aa5760405162461bcd60e51b8152600401808060200182810382526023815260200180611e376023913960400191505060405180910390fd5b6116b583838361152b565b6116f281604051806060016040528060268152602001611eca602691396001600160a01b038616600090815260208190526040902054919061177b565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461172190826119f2565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561180a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156117cf5781810151838201526020016117b7565b50505050905090810190601f1680156117fc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008261182157506000610787565b8282028284828161182e57fe5b041461186b5760405162461bcd60e51b8152600401808060200182810382526021815260200180611ef06021913960400191505060405180910390fd5b9392505050565b600061186b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611c47565b6001600160a01b0382166118f95760405162461bcd60e51b8152600401808060200182810382526021815260200180611f396021913960400191505060405180910390fd5b6119058260008361152b565b61194281604051806060016040528060228152602001611e5a602291396001600160a01b038516600090815260208190526040902054919061177b565b6001600160a01b03831660009081526020819052604090205560025461196890826119b0565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600061186b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061177b565b60008282018381101561186b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610b71908590611b96565b6001600160a01b038216611b01576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611b0d6000838361152b565b600254611b1a90826119f2565b6002556001600160a01b038216600090815260208190526040902054611b4090826119f2565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6060611beb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611cac9092919063ffffffff16565b80519091501561152b57808060200190516020811015611c0a57600080fd5b505161152b5760405162461bcd60e51b815260040180806020018281038252602a815260200180611fa3602a913960400191505060405180910390fd5b60008183611c965760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156117cf5781810151838201526020016117b7565b506000838581611ca257fe5b0495945050505050565b6060611cbb8484600085611cc3565b949350505050565b6060611cce85611e30565b611d1f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611d5e5780518252601f199092019160209182019101611d3f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611dc0576040519150601f19603f3d011682016040523d82523d6000602084013e611dc5565b606091505b50915091508115611dd9579150611cbb9050565b805115611de95780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156117cf5781810151838201526020016117b7565b3b15159056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f20616464726573736e756d657261746f722063616e6e6f742062652067726561746572207468616e2064656e6f6d696e61746f7245524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220848b4e70e1219d10ff3a6f4c083159e936c932dca5a84744ef67bd64476d324f64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 27421, 27531, 2546, 2475, 7959, 2549, 2497, 16086, 21619, 2278, 2692, 2620, 2683, 2278, 24087, 2549, 2278, 2683, 2487, 2546, 20952, 2497, 2581, 16068, 2620, 10322, 22407, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1020, 1012, 1022, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 5034, 2278, 1013, 19706, 1013, 11486, 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, 8278, 12696, 13181, 10820, 1063, 3853, 25067, 1006, 4769, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 19054, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 3853, 16475, 11263, 4859, 1006, 1007, 6327, 3193, 5651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,935
0x979d448a11bda7fe48f3b8dfe4187c7b94a0f6f9
// SPDX-License-Identifier: Unlicensed /* Telegram: https://t.me/tamamikasa Mikasa Fan based token Stealth Launch Tokenomics: Total Tax:12% Liquidity Pool: 4% Buy Back and Burn: 3% Marketing: 3% Dev 2% */ pragma solidity ^0.8.10; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner() { _transferOwnership(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner() { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } 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); } contract TAMAMIKASA 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 _isBot; uint256 private constant _MAX = ~uint256(0); uint256 private constant _tTotal = 1e10 * 10**9; uint256 private _rTotal = (_MAX - (_MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "TAMAMIKASA"; string private constant _symbol = "TAMAMIKASA"; uint private constant _decimals = 9; uint256 private _teamFee = 12; uint256 private _previousteamFee = _teamFee; uint256 private _maxTxnAmount = 2; address payable private _feeAddress; // Uniswap Pair IUniswapV2Router02 private _uniswapV2Router; address private _uniswapV2Pair; bool private _initialized = false; bool private _noTaxMode = false; bool private _inSwap = false; bool private _tradingOpen = false; uint256 private _launchTime; bool private _txnLimit = false; modifier lockTheSwap() { _inSwap = true; _; _inSwap = false; } modifier handleFees(bool takeFee) { if (!takeFee) _removeAllFees(); _; if (!takeFee) _restoreAllFees(); } constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[payable(0x000000000000000000000000000000000000dEaD)] = 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 (uint) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _removeAllFees() private { require(_teamFee > 0); _previousteamFee = _teamFee; _teamFee = 0; } function _restoreAllFees() private { _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"); require(!_isBot[from], "Your address has been marked as a bot, please contact staff to appeal your case."); bool takeFee = false; if ( !_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !_noTaxMode && (from == _uniswapV2Pair || to == _uniswapV2Pair) ) { require(_tradingOpen, 'Trading has not yet been opened.'); takeFee = true; if (from == _uniswapV2Pair && to != address(_uniswapV2Router) && _txnLimit) { uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(_maxTxnAmount).div(100)); } if (block.timestamp == _launchTime) _isBot[to] = true; uint256 contractTokenBalance = balanceOf(address(this)); if (!_inSwap && from != _uniswapV2Pair) { if (contractTokenBalance > 0) { if (contractTokenBalance > balanceOf(_uniswapV2Pair).mul(15).div(100)) contractTokenBalance = balanceOf(_uniswapV2Pair).mul(15).div(100); _swapTokensForEth(contractTokenBalance); } } } _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 _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee) private handleFees(takeFee) { (uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tTeam) = _getTValues(tAmount, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount) = _getRValues(tAmount, tTeam, currentRate); return (rAmount, rTransferAmount, tTransferAmount, tTeam); } function _getTValues(uint256 tAmount, uint256 TeamFee) private pure returns (uint256, uint256) { uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tTeam); return (tTransferAmount, tTeam); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getRValues(uint256 tAmount, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rTeam); return (rAmount, rTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function initNewPair(address payable feeAddress) external onlyOwner() { require(!_initialized,"Contract has already been initialized"); IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); _uniswapV2Router = uniswapV2Router; _feeAddress = feeAddress; _isExcludedFromFee[_feeAddress] = true; _initialized = true; } function startTrading() external onlyOwner() { require(_initialized); _tradingOpen = true; _launchTime = block.timestamp; _txnLimit = true; } function setFeeWallet(address payable feeWalletAddress) external onlyOwner() { _isExcludedFromFee[_feeAddress] = false; _feeAddress = feeWalletAddress; _isExcludedFromFee[_feeAddress] = true; } function excludeFromFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = true; } function includeToFee(address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = false; } function enableTxnLimit(bool onoff) external onlyOwner() { _txnLimit = onoff; } function setTeamFee(uint256 fee) external onlyOwner() { require(fee < 12); _teamFee = fee; } function setMaxTxn(uint256 max) external onlyOwner(){ require(max>2); _maxTxnAmount = max; } function setBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != _uniswapV2Pair && bots_[i] != address(_uniswapV2Router)) { _isBot[bots_[i]] = true; } } } function delBots(address[] memory bots_) public onlyOwner() { for (uint i = 0; i < bots_.length; i++) { _isBot[bots_[i]] = false; } } function isBot(address ad) public view returns (bool) { return _isBot[ad]; } function isExcludedFromFee(address ad) public view returns (bool) { return _isExcludedFromFee[ad]; } function swapFeesManual() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); _swapTokensForEth(contractBalance); } function withdrawFees() external { uint256 contractETHBalance = address(this).balance; _feeAddress.transfer(contractETHBalance); } receive() external payable {} }
0x6080604052600436106101855760003560e01c806370a08231116100d1578063a9059cbb1161008a578063dd62ed3e11610064578063dd62ed3e1461046c578063e6ec64ec146104b2578063f2fde38b146104d2578063fc588c04146104f257600080fd5b8063a9059cbb1461040c578063b515566a1461042c578063cf0848f71461044c57600080fd5b806370a082311461036f578063715018a61461038f5780637c938bb4146103a45780638da5cb5b146103c457806390d49b9d146103ec57806395d89b41146101a857600080fd5b8063313ce5671161013e5780633bbac579116101185780633bbac579146102c8578063437823ec14610301578063476343ee146103215780635342acb41461033657600080fd5b8063313ce5671461027457806331c2d847146102885780633a0f23b3146102a857600080fd5b806306d8ea6b1461019157806306fdde03146101a8578063095ea7b3146101ea57806318160ddd1461021a57806323b872dd1461023f578063293230b81461025f57600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101a6610512565b005b3480156101b457600080fd5b50604080518082018252600a81526954414d414d494b41534160b01b602082015290516101e19190611928565b60405180910390f35b3480156101f657600080fd5b5061020a6102053660046119a2565b61055e565b60405190151581526020016101e1565b34801561022657600080fd5b50678ac7230489e800005b6040519081526020016101e1565b34801561024b57600080fd5b5061020a61025a3660046119ce565b610575565b34801561026b57600080fd5b506101a66105de565b34801561028057600080fd5b506009610231565b34801561029457600080fd5b506101a66102a3366004611a25565b610644565b3480156102b457600080fd5b506101a66102c3366004611aea565b6106da565b3480156102d457600080fd5b5061020a6102e3366004611b0c565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561030d57600080fd5b506101a661031c366004611b0c565b610717565b34801561032d57600080fd5b506101a6610765565b34801561034257600080fd5b5061020a610351366004611b0c565b6001600160a01b031660009081526004602052604090205460ff1690565b34801561037b57600080fd5b5061023161038a366004611b0c565b61079f565b34801561039b57600080fd5b506101a66107c1565b3480156103b057600080fd5b506101a66103bf366004611b0c565b6107f7565b3480156103d057600080fd5b506000546040516001600160a01b0390911681526020016101e1565b3480156103f857600080fd5b506101a6610407366004611b0c565b610a52565b34801561041857600080fd5b5061020a6104273660046119a2565b610acc565b34801561043857600080fd5b506101a6610447366004611a25565b610ad9565b34801561045857600080fd5b506101a6610467366004611b0c565b610bf2565b34801561047857600080fd5b50610231610487366004611b29565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b3480156104be57600080fd5b506101a66104cd366004611b62565b610c3d565b3480156104de57600080fd5b506101a66104ed366004611b0c565b610c79565b3480156104fe57600080fd5b506101a661050d366004611b62565b610d11565b6000546001600160a01b031633146105455760405162461bcd60e51b815260040161053c90611b7b565b60405180910390fd5b60006105503061079f565b905061055b81610d4d565b50565b600061056b338484610ec7565b5060015b92915050565b6000610582848484610feb565b6105d484336105cf85604051806060016040528060288152602001611cf6602891396001600160a01b038a1660009081526003602090815260408083203384529091529020549190611411565b610ec7565b5060019392505050565b6000546001600160a01b031633146106085760405162461bcd60e51b815260040161053c90611b7b565b600d54600160a01b900460ff1661061e57600080fd5b600d805460ff60b81b1916600160b81b17905542600e55600f805460ff19166001179055565b6000546001600160a01b0316331461066e5760405162461bcd60e51b815260040161053c90611b7b565b60005b81518110156106d65760006005600084848151811061069257610692611bb0565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806106ce81611bdc565b915050610671565b5050565b6000546001600160a01b031633146107045760405162461bcd60e51b815260040161053c90611b7b565b600f805460ff1916911515919091179055565b6000546001600160a01b031633146107415760405162461bcd60e51b815260040161053c90611b7b565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b600b5460405147916001600160a01b03169082156108fc029083906000818181858888f193505050501580156106d6573d6000803e3d6000fd5b6001600160a01b03811660009081526001602052604081205461056f9061144b565b6000546001600160a01b031633146107eb5760405162461bcd60e51b815260040161053c90611b7b565b6107f560006114cf565b565b6000546001600160a01b031633146108215760405162461bcd60e51b815260040161053c90611b7b565b600d54600160a01b900460ff16156108895760405162461bcd60e51b815260206004820152602560248201527f436f6e74726163742068617320616c7265616479206265656e20696e697469616044820152641b1a5e995960da1b606482015260840161053c565b6000737a250d5630b4cf539739df2c5dacb4c659f2488d9050806001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109049190611bf7565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610951573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109759190611bf7565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af11580156109c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e69190611bf7565b600d80546001600160a01b039283166001600160a01b0319918216178255600c805494841694821694909417909355600b8054949092169390921683179055600091825260046020526040909120805460ff19166001179055805460ff60a01b1916600160a01b179055565b6000546001600160a01b03163314610a7c5760405162461bcd60e51b815260040161053c90611b7b565b600b80546001600160a01b03908116600090815260046020526040808220805460ff1990811690915584546001600160a01b03191695909316948517909355928352912080549091166001179055565b600061056b338484610feb565b6000546001600160a01b03163314610b035760405162461bcd60e51b815260040161053c90611b7b565b60005b81518110156106d657600d5482516001600160a01b0390911690839083908110610b3257610b32611bb0565b60200260200101516001600160a01b031614158015610b835750600c5482516001600160a01b0390911690839083908110610b6f57610b6f611bb0565b60200260200101516001600160a01b031614155b15610be057600160056000848481518110610ba057610ba0611bb0565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055505b80610bea81611bdc565b915050610b06565b6000546001600160a01b03163314610c1c5760405162461bcd60e51b815260040161053c90611b7b565b6001600160a01b03166000908152600460205260409020805460ff19169055565b6000546001600160a01b03163314610c675760405162461bcd60e51b815260040161053c90611b7b565b600c8110610c7457600080fd5b600855565b6000546001600160a01b03163314610ca35760405162461bcd60e51b815260040161053c90611b7b565b6001600160a01b038116610d085760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161053c565b61055b816114cf565b6000546001600160a01b03163314610d3b5760405162461bcd60e51b815260040161053c90611b7b565b60028111610d4857600080fd5b600a55565b600d805460ff60b01b1916600160b01b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610d9557610d95611bb0565b6001600160a01b03928316602091820292909201810191909152600c54604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015610dee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e129190611bf7565b81600181518110610e2557610e25611bb0565b6001600160a01b039283166020918202929092010152600c54610e4b9130911684610ec7565b600c5460405163791ac94760e01b81526001600160a01b039091169063791ac94790610e84908590600090869030904290600401611c14565b600060405180830381600087803b158015610e9e57600080fd5b505af1158015610eb2573d6000803e3d6000fd5b5050600d805460ff60b01b1916905550505050565b6001600160a01b038316610f295760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161053c565b6001600160a01b038216610f8a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161053c565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831661104f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161053c565b6001600160a01b0382166110b15760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161053c565b600081116111135760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161053c565b6001600160a01b03831660009081526005602052604090205460ff16156111bb5760405162461bcd60e51b815260206004820152605060248201527f596f7572206164647265737320686173206265656e206d61726b65642061732060448201527f6120626f742c20706c6561736520636f6e7461637420737461666620746f206160648201526f383832b0b6103cb7bab91031b0b9b29760811b608482015260a40161053c565b6001600160a01b03831660009081526004602052604081205460ff161580156111fd57506001600160a01b03831660009081526004602052604090205460ff16155b80156112135750600d54600160a81b900460ff16155b80156112435750600d546001600160a01b03858116911614806112435750600d546001600160a01b038481169116145b156113ff57600d54600160b81b900460ff166112a15760405162461bcd60e51b815260206004820181905260248201527f54726164696e6720686173206e6f7420796574206265656e206f70656e65642e604482015260640161053c565b50600d546001906001600160a01b0385811691161480156112d05750600c546001600160a01b03848116911614155b80156112de5750600f5460ff165b1561132f5760006112ee8461079f565b90506113186064611312600a54678ac7230489e8000061151f90919063ffffffff16565b9061159e565b61132284836115e0565b111561132d57600080fd5b505b600e5442141561135d576001600160a01b0383166000908152600560205260409020805460ff191660011790555b60006113683061079f565b600d54909150600160b01b900460ff161580156113935750600d546001600160a01b03868116911614155b156113fd5780156113fd57600d546113c79060649061131290600f906113c1906001600160a01b031661079f565b9061151f565b8111156113f457600d546113f19060649061131290600f906113c1906001600160a01b031661079f565b90505b6113fd81610d4d565b505b61140b8484848461163f565b50505050565b600081848411156114355760405162461bcd60e51b815260040161053c9190611928565b5060006114428486611c85565b95945050505050565b60006006548211156114b25760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161053c565b60006114bc611742565b90506114c8838261159e565b9392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008261152e5750600061056f565b600061153a8385611c9c565b9050826115478583611cbb565b146114c85760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161053c565b60006114c883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611765565b6000806115ed8385611cdd565b9050838110156114c85760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161053c565b808061164d5761164d611793565b60008060008061165c876117af565b6001600160a01b038d166000908152600160205260409020549397509195509350915061168990856117f6565b6001600160a01b03808b1660009081526001602052604080822093909355908a16815220546116b890846115e0565b6001600160a01b0389166000908152600160205260409020556116da81611838565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161171f91815260200190565b60405180910390a3505050508061173b5761173b600954600855565b5050505050565b600080600061174f611882565b909250905061175e828261159e565b9250505090565b600081836117865760405162461bcd60e51b815260040161053c9190611928565b5060006114428486611cbb565b6000600854116117a257600080fd5b6008805460095560009055565b6000806000806000806117c4876008546118c2565b9150915060006117d2611742565b90506000806117e28a85856118ef565b909b909a5094985092965092945050505050565b60006114c883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611411565b6000611842611742565b90506000611850838361151f565b3060009081526001602052604090205490915061186d90826115e0565b30600090815260016020526040902055505050565b6006546000908190678ac7230489e8000061189d828261159e565b8210156118b957505060065492678ac7230489e8000092509050565b90939092509050565b600080806118d56064611312878761151f565b905060006118e386836117f6565b96919550909350505050565b600080806118fd868561151f565b9050600061190b868661151f565b9050600061191983836117f6565b92989297509195505050505050565b600060208083528351808285015260005b8181101561195557858101830151858201604001528201611939565b81811115611967576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461055b57600080fd5b803561199d8161197d565b919050565b600080604083850312156119b557600080fd5b82356119c08161197d565b946020939093013593505050565b6000806000606084860312156119e357600080fd5b83356119ee8161197d565b925060208401356119fe8161197d565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215611a3857600080fd5b823567ffffffffffffffff80821115611a5057600080fd5b818501915085601f830112611a6457600080fd5b813581811115611a7657611a76611a0f565b8060051b604051601f19603f83011681018181108582111715611a9b57611a9b611a0f565b604052918252848201925083810185019188831115611ab957600080fd5b938501935b82851015611ade57611acf85611992565b84529385019392850192611abe565b98975050505050505050565b600060208284031215611afc57600080fd5b813580151581146114c857600080fd5b600060208284031215611b1e57600080fd5b81356114c88161197d565b60008060408385031215611b3c57600080fd5b8235611b478161197d565b91506020830135611b578161197d565b809150509250929050565b600060208284031215611b7457600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611bf057611bf0611bc6565b5060010190565b600060208284031215611c0957600080fd5b81516114c88161197d565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611c645784516001600160a01b031683529383019391830191600101611c3f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082821015611c9757611c97611bc6565b500390565b6000816000190483118215151615611cb657611cb6611bc6565b500290565b600082611cd857634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115611cf057611cf0611bc6565b50019056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212202eec531cdb3a972c3ebac38f9bc2f5b5c2b017fcbfcfa231e3c098090172ca5064736f6c634300080c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2094, 22932, 2620, 27717, 2487, 2497, 2850, 2581, 7959, 18139, 2546, 2509, 2497, 2620, 20952, 2063, 23632, 2620, 2581, 2278, 2581, 2497, 2683, 2549, 2050, 2692, 2546, 2575, 2546, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 17214, 10631, 13716, 2050, 27857, 3736, 5470, 2241, 19204, 22150, 4888, 19204, 25524, 1024, 2561, 4171, 1024, 2260, 1003, 6381, 3012, 4770, 1024, 1018, 1003, 4965, 2067, 1998, 6402, 1024, 1017, 1003, 5821, 1024, 1017, 1003, 16475, 1016, 1003, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 2184, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 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,936
0x979D49534C09301AADe9830A5547c25A99e91435
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Investors' token contract // // Deployed to : 0x0f062Fed1C7Fd3D9dbB40701406196361C6D4edD // Symbol : INVT // Name : Investors Token // Total supply: 10000000000 // Decimals : 18 // // 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 InvestorsToken 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 InvestorsToken() public { symbol = "INVT"; name = "InvestorsToken"; decimals = 18; _totalSupply = 10000000000000000000000000000; balances[0x0f062Fed1C7Fd3D9dbB40701406196361C6D4edD] = _totalSupply; Transfer(address(0),0x0f062Fed1C7Fd3D9dbB40701406196361C6D4edD, _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); } }
0x6080604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610116578063095ea7b3146101a057806318160ddd146101d857806323b872dd146101ff578063313ce567146102295780633eaaf86b1461025457806370a082311461026957806379ba50971461028a5780638da5cb5b146102a157806395d89b41146102d2578063a293d1e8146102e7578063a9059cbb14610302578063b5931f7c14610326578063cae9ca5114610341578063d05c78da146103aa578063d4ee1d90146103c5578063dc39d06d146103da578063dd62ed3e146103fe578063e6cb901314610425578063f2fde38b14610440575b600080fd5b34801561012257600080fd5b5061012b610461565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561016557818101518382015260200161014d565b50505050905090810190601f1680156101925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ac57600080fd5b506101c4600160a060020a03600435166024356104ef565b604080519115158252519081900360200190f35b3480156101e457600080fd5b506101ed610556565b60408051918252519081900360200190f35b34801561020b57600080fd5b506101c4600160a060020a0360043581169060243516604435610588565b34801561023557600080fd5b5061023e610681565b6040805160ff9092168252519081900360200190f35b34801561026057600080fd5b506101ed61068a565b34801561027557600080fd5b506101ed600160a060020a0360043516610690565b34801561029657600080fd5b5061029f6106ab565b005b3480156102ad57600080fd5b506102b6610733565b60408051600160a060020a039092168252519081900360200190f35b3480156102de57600080fd5b5061012b610742565b3480156102f357600080fd5b506101ed60043560243561079a565b34801561030e57600080fd5b506101c4600160a060020a03600435166024356107af565b34801561033257600080fd5b506101ed600435602435610853565b34801561034d57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101c4948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506108749650505050505050565b3480156103b657600080fd5b506101ed6004356024356109d5565b3480156103d157600080fd5b506102b66109fa565b3480156103e657600080fd5b506101c4600160a060020a0360043516602435610a09565b34801561040a57600080fd5b506101ed600160a060020a0360043581169060243516610ac4565b34801561043157600080fd5b506101ed600435602435610aef565b34801561044c57600080fd5b5061029f600160a060020a0360043516610aff565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b820191906000526020600020905b8154815290600101906020018083116104ca57829003601f168201915b505050505081565b336000818152600760209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105ab908361079a565b600160a060020a03851660009081526006602090815260408083209390935560078152828220338352905220546105e2908361079a565b600160a060020a0380861660009081526007602090815260408083203384528252808320949094559186168152600690915220546106209083610aef565b600160a060020a0380851660008181526006602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b600154600160a060020a031633146106c257600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b6000828211156107a957600080fd5b50900390565b336000908152600660205260408120546107c9908361079a565b3360009081526006602052604080822092909255600160a060020a038516815220546107f59083610aef565b600160a060020a0384166000818152600660209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161086157600080fd5b818381151561086c57fe5b049392505050565b336000818152600760209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a36040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018690523060448401819052608060648501908152865160848601528651600160a060020a038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b8381101561096457818101518382015260200161094c565b50505050905090810190601f1680156109915780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156109b357600080fd5b505af11580156109c7573d6000803e3d6000fd5b506001979650505050505050565b8181028215806109ef57508183828115156109ec57fe5b04145b151561055057600080fd5b600154600160a060020a031681565b60008054600160a060020a03163314610a2157600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610a9157600080fd5b505af1158015610aa5573d6000803e3d6000fd5b505050506040513d6020811015610abb57600080fd5b50519392505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561055057600080fd5b600054600160a060020a03163314610b1657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820cc9bb354c31f2c99a100202e5427ffddeec9f194508e0aec97d70307d71fede90029
{"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, 2581, 2683, 2094, 26224, 22275, 2549, 2278, 2692, 2683, 14142, 2487, 11057, 3207, 2683, 2620, 14142, 2050, 24087, 22610, 2278, 17788, 2050, 2683, 2683, 2063, 2683, 16932, 19481, 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, 1005, 9387, 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,937
0x979e28dcb6dfadeb06f62bc2d9ca689df273f30e
pragma solidity ^0.4.24; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Allow is Ownable { mapping(address => bool) public allowedMap; address[] public allowedArray; event AddressAllowed(address _handler, address _address); event AddressDenied(address _handler, address _address); constructor() public { } modifier allow() { require(allowedMap[msg.sender] == true); _; } function allowAccess(address _address) onlyOwner public { allowedMap[_address] = true; bool exists = false; for(uint i = 0; i < allowedArray.length; i++) { if(allowedArray[i] == _address) { exists = true; break; } } if(!exists) { allowedArray.push(_address); } emit AddressAllowed(msg.sender, _address); } function denyAccess(address _address) onlyOwner public { allowedMap[_address] = false; emit AddressDenied(msg.sender, _address); } } contract Copyright is Allow { bytes32[] public list; event SetLog(bytes32 hash, uint256 id); constructor() public { } function save(bytes32 _hash) allow public { list.push(_hash); emit SetLog(_hash, list.length-1); } function count() public view returns(uint256) { return list.length; } }
0x6080604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306661abd811461009d5780632e1645e7146100c45780634053c797146100f957806347d406091461011357806361afd5ac1461014757806380c9419e146101685780638da5cb5b14610180578063c4a85bc114610195578063f2fde38b146101b6575b600080fd5b3480156100a957600080fd5b506100b26101d7565b60408051918252519081900360200190f35b3480156100d057600080fd5b506100e5600160a060020a03600435166101dd565b604080519115158252519081900360200190f35b34801561010557600080fd5b506101116004356101f2565b005b34801561011f57600080fd5b5061012b60043561028a565b60408051600160a060020a039092168252519081900360200190f35b34801561015357600080fd5b50610111600160a060020a03600435166102b2565b34801561017457600080fd5b506100b2600435610328565b34801561018c57600080fd5b5061012b610347565b3480156101a157600080fd5b50610111600160a060020a0360043516610356565b3480156101c257600080fd5b50610111600160a060020a0360043516610490565b60035490565b60016020526000908152604090205460ff1681565b3360009081526001602081905260409091205460ff1615151461021457600080fd5b6003805460018101825560008290527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b018290555460408051838152600019909201602083015280517fc240aeac8f08cad0824a782b09f29ae3661b5b136b27016c15a6ce101b2d432b9281900390910190a150565b600280548290811061029857fe5b600091825260209091200154600160a060020a0316905081565b600054600160a060020a031633146102c957600080fd5b600160a060020a038116600081815260016020908152604091829020805460ff1916905581513381529081019290925280517f15d537fd5895793b259502018076b946c9a3f5b8f4fc9557e756123e6917fc8a9281900390910190a150565b600380548290811061033657fe5b600091825260209091200154905081565b600054600160a060020a031681565b600080548190600160a060020a0316331461037057600080fd5b5050600160a060020a03811660009081526001602081905260408220805460ff19169091179055805b6002548110156103e85782600160a060020a03166002828154811015156103bc57fe5b600091825260209091200154600160a060020a031614156103e057600191506103e8565b600101610399565b81151561044857600280546001810182556000919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b60408051338152600160a060020a038516602082015281517f11db8dd6cdf978ae8ea4387d9f3d24b21d117d4b9669c370379462b939ad3021929181900390910190a1505050565b600054600160a060020a031633146104a757600080fd5b600160a060020a03811615156104bc57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582040229e8c16e7fb1d6762a5d2d62487aa1f27953c42976f725de48f7e406ada3c0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2683, 2063, 22407, 16409, 2497, 2575, 20952, 9648, 2497, 2692, 2575, 2546, 2575, 2475, 9818, 2475, 2094, 2683, 3540, 2575, 2620, 2683, 20952, 22907, 2509, 2546, 14142, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 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, 9570, 2953, 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,938
0x979e2FdE487534be3f8a41cD57f11EF9E71cDC1A
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IAlchemist} from "./alchemist/Alchemist.sol"; contract StreamV1 is Ownable { using SafeMath for uint256; address public immutable mist; address[] public recipients; uint256[] public shareBPS; event Distributed(uint256 amtMinted); event RecipientsUpdated(address[] _recipients, uint256[] _shareBPS); constructor(address _mist, address _owner) { mist = _mist; Ownable.transferOwnership(_owner); } /* user functions */ function advanceAndDistribute() external { // call advance if possible try IAlchemist(mist).advance() {} catch {} // distribute distribute(); } function distribute() public { // get balance uint256 balance = IERC20(mist).balanceOf(address(this)); // transfer to recipients for (uint256 index = 0; index < recipients.length; index++) { IERC20(mist).transfer(recipients[index], balance.mul(shareBPS[index]).div(10_000)); } // emit event emit Distributed(balance); } /* admin functions */ function updateRecipients(address[] calldata _recipients, uint256[] calldata _shareBPS) external onlyOwner { // clear storage delete recipients; delete shareBPS; assert(recipients.length == 0 && shareBPS.length == 0); // sumBPS distribution uint256 sumBPS = 0; for (uint256 index = 0; index < _recipients.length; index++) { sumBPS += _shareBPS[index]; } require(sumBPS == 10_000, "invalid sum"); // update storage recipients = _recipients; shareBPS = _shareBPS; // emit event emit RecipientsUpdated(_recipients, _shareBPS); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; pragma abicoder v2; // pragma experimental SMTChecker; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol"; import {ERC20Snapshot} from "@openzeppelin/contracts/token/ERC20/ERC20Snapshot.sol"; import {ERC20Permit} from "@openzeppelin/contracts/drafts/ERC20Permit.sol"; import {TimelockConfig} from "./TimelockConfig.sol"; interface IAlchemist { /* event */ event Advanced(uint256 epoch, uint256 supplyMinted); /* user functions */ function advance() external; /* view functions */ function getAdmin() external view returns (address admin); function getRecipient() external view returns (address recipient); function getTimelock() external view returns (uint256 timelock); function getInflationBps() external view returns (uint256 inflationBps); function getEpochDuration() external view returns (uint256 epochDuration); } // ⚗️ Alchemist ⚗️ contract Alchemist is IAlchemist, ERC20("Alchemist", unicode"⚗️"), ERC20Burnable, ERC20Snapshot, ERC20Permit("Alchemist"), TimelockConfig { /* constants */ bytes32 public constant RECIPIENT_CONFIG_ID = keccak256("Recipient"); bytes32 public constant INFLATION_BPS_CONFIG_ID = keccak256("InflationBPS"); bytes32 public constant EPOCH_DURATION_CONFIG_ID = keccak256("EpochDuration"); /* storage */ uint256 private _epoch; uint256 private _previousEpochTimestamp; /* constructor function */ constructor( address admin, address recipient, uint256 inflationBps, uint256 epochDuration, uint256 timelock, uint256 supply, uint256 epochStart ) TimelockConfig(admin, timelock) { // set config TimelockConfig._setRawConfig(RECIPIENT_CONFIG_ID, uint256(recipient)); TimelockConfig._setRawConfig(INFLATION_BPS_CONFIG_ID, inflationBps); TimelockConfig._setRawConfig(EPOCH_DURATION_CONFIG_ID, epochDuration); // set epoch timestamp _previousEpochTimestamp = epochStart; // mint initial supply ERC20._mint(recipient, supply); } /* user functions */ function advance() external override { // require new epoch require( block.timestamp >= _previousEpochTimestamp + getEpochDuration(), "not ready to advance" ); // set epoch _epoch++; _previousEpochTimestamp = block.timestamp; // create snapshot ERC20Snapshot._snapshot(); // calculate inflation amount uint256 supplyMinted = (ERC20.totalSupply() * getInflationBps()) / 10000; // mint to tokenManager ERC20._mint(getRecipient(), supplyMinted); // emit event emit Advanced(_epoch, supplyMinted); } /* hook functions */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override(ERC20, ERC20Snapshot) { ERC20Snapshot._beforeTokenTransfer(from, to, amount); } /* view functions */ function getAdmin() public view override returns (address admin) { return address(TimelockConfig.getConfig(TimelockConfig.ADMIN_CONFIG_ID).value); } function getRecipient() public view override returns (address recipient) { return address(TimelockConfig.getConfig(RECIPIENT_CONFIG_ID).value); } function getTimelock() public view override returns (uint256 timelock) { return TimelockConfig.getConfig(TimelockConfig.TIMELOCK_CONFIG_ID).value; } function getInflationBps() public view override returns (uint256 inflationBps) { return TimelockConfig.getConfig(INFLATION_BPS_CONFIG_ID).value; } function getEpochDuration() public view override returns (uint256 epochDuration) { return TimelockConfig.getConfig(EPOCH_DURATION_CONFIG_ID).value; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../utils/Context.sol"; import "./ERC20.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../math/SafeMath.sol"; import "../../utils/Arrays.sol"; import "../../utils/Counters.sol"; import "./ERC20.sol"; /** * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and * total supply at the time are recorded for later access. * * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting. * In naive implementations it's possible to perform a "double spend" attack by reusing the same balance from different * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be * used to create an efficient ERC20 forking mechanism. * * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id * and the account address. * * ==== Gas Costs * * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much * smaller since identical balances in subsequent snapshots are stored as a single entry. * * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent * transfers will have normal cost until the next snapshot, and so on. */ abstract contract ERC20Snapshot is ERC20 { // Inspired by Jordi Baylina's MiniMeToken to record historical balances: // https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol using SafeMath for uint256; using Arrays for uint256[]; using Counters for Counters.Counter; // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a // Snapshot struct, but that would impede usage of functions that work on an array. struct Snapshots { uint256[] ids; uint256[] values; } mapping (address => Snapshots) private _accountBalanceSnapshots; Snapshots private _totalSupplySnapshots; // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid. Counters.Counter private _currentSnapshotId; /** * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created. */ event Snapshot(uint256 id); /** * @dev Creates a new snapshot and returns its snapshot id. * * Emits a {Snapshot} event that contains the same id. * * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a * set of accounts, for example using {AccessControl}, or it may be open to the public. * * [WARNING] * ==== * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking, * you must consider that it can potentially be used by attackers in two ways. * * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs * section above. * * We haven't measured the actual numbers; if this is something you're interested in please reach out to us. * ==== */ function _snapshot() internal virtual returns (uint256) { _currentSnapshotId.increment(); uint256 currentId = _currentSnapshotId.current(); emit Snapshot(currentId); return currentId; } /** * @dev Retrieves the balance of `account` at the time `snapshotId` was created. */ function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) { (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]); return snapshotted ? value : balanceOf(account); } /** * @dev Retrieves the total supply at the time `snapshotId` was created. */ function totalSupplyAt(uint256 snapshotId) public view virtual returns(uint256) { (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots); return snapshotted ? value : totalSupply(); } // Update balance and/or total supply snapshots before the values are modified. This is implemented // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations. function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // mint _updateAccountSnapshot(to); _updateTotalSupplySnapshot(); } else if (to == address(0)) { // burn _updateAccountSnapshot(from); _updateTotalSupplySnapshot(); } else { // transfer _updateAccountSnapshot(from); _updateAccountSnapshot(to); } } function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { require(snapshotId > 0, "ERC20Snapshot: id is 0"); // solhint-disable-next-line max-line-length require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id"); // When a valid snapshot is queried, there are three possibilities: // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds // to this id is the current one. // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the // requested id, and its value is the one to return. // c) More snapshots were created after the requested one, and the queried value was later modified. There will be // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is // larger than the requested one. // // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does // exactly this. uint256 index = snapshots.ids.findUpperBound(snapshotId); if (index == snapshots.ids.length) { return (false, 0); } else { return (true, snapshots.values[index]); } } function _updateAccountSnapshot(address account) private { _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account)); } function _updateTotalSupplySnapshot() private { _updateSnapshot(_totalSupplySnapshots, totalSupply()); } function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private { uint256 currentId = _currentSnapshotId.current(); if (_lastSnapshotId(snapshots.ids) < currentId) { snapshots.ids.push(currentId); snapshots.values.push(currentValue); } } function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) { if (ids.length == 0) { return 0; } else { return ids[ids.length - 1]; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.5 <0.8.0; import "../token/ERC20/ERC20.sol"; import "./IERC20Permit.sol"; import "../cryptography/ECDSA.sol"; import "../utils/Counters.sol"; import "./EIP712.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping (address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") { } /** * @dev See {IERC20Permit-permit}. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override { // solhint-disable-next-line not-rely-on-time require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _nonces[owner].current(), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _nonces[owner].increment(); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; pragma abicoder v2; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; interface ITimelockConfig { /* data types */ struct Config { bytes32 id; uint256 value; } struct PendingRequest { bytes32 id; uint256 value; uint256 timestamp; } /* events */ event ChangeRequested(bytes32 configID, uint256 value); event ChangeConfirmed(bytes32 configID, uint256 value); event ChangeCanceled(bytes32 configID, uint256 value); /* user functions */ function confirmChange(bytes32 configID) external; /* admin functions */ function requestChange(bytes32 configID, uint256 value) external; function cancelChange(bytes32 configID) external; /* pure functions */ function calculateConfigID(string memory name) external pure returns (bytes32 configID); /* view functions */ function getConfig(bytes32 configID) external view returns (Config memory config); function isConfig(bytes32 configID) external view returns (bool status); function getConfigCount() external view returns (uint256 count); function getConfigByIndex(uint256 index) external view returns (Config memory config); function getPending(bytes32 configID) external view returns (PendingRequest memory pendingRequest); function isPending(bytes32 configID) external view returns (bool status); function getPendingCount() external view returns (uint256 count); function getPendingByIndex(uint256 index) external view returns (PendingRequest memory pendingRequest); } contract TimelockConfig is ITimelockConfig { using EnumerableSet for EnumerableSet.Bytes32Set; /* constants */ bytes32 public constant ADMIN_CONFIG_ID = keccak256("Admin"); bytes32 public constant TIMELOCK_CONFIG_ID = keccak256("Timelock"); /* storage */ struct InternalPending { uint256 value; uint256 timestamp; } mapping(bytes32 => uint256) _config; EnumerableSet.Bytes32Set _configSet; mapping(bytes32 => InternalPending) _pending; EnumerableSet.Bytes32Set _pendingSet; /* modifiers */ modifier onlyAdmin() { require(msg.sender == address(_config[ADMIN_CONFIG_ID]), "only admin"); _; } /* constructor */ constructor(address admin, uint256 timelock) { _setRawConfig(ADMIN_CONFIG_ID, uint256(admin)); _setRawConfig(TIMELOCK_CONFIG_ID, timelock); } /* user functions */ function confirmChange(bytes32 configID) external override { // require sufficient time elapsed require( block.timestamp >= _pending[configID].timestamp + _config[TIMELOCK_CONFIG_ID], "too early" ); // get pending value uint256 value = _pending[configID].value; // commit change _configSet.add(configID); _config[configID] = value; // delete pending _pendingSet.remove(configID); delete _pending[configID]; // emit event emit ChangeConfirmed(configID, value); } /* admin functions */ function requestChange(bytes32 configID, uint256 value) external override onlyAdmin { // add to pending set require(_pendingSet.add(configID), "existing request"); // lock new value _pending[configID] = InternalPending(value, block.timestamp); // emit event emit ChangeRequested(configID, value); } function cancelChange(bytes32 configID) external override onlyAdmin { // remove from pending set require(_pendingSet.remove(configID), "no request"); // get pending value uint256 value = _pending[configID].value; // delete pending delete _pending[configID]; // emit event emit ChangeCanceled(configID, value); } /* convenience functions */ function _setRawConfig(bytes32 configID, uint256 value) internal { // commit change _configSet.add(configID); _config[configID] = value; // emit event emit ChangeRequested(configID, value); emit ChangeConfirmed(configID, value); } /* pure functions */ function calculateConfigID(string memory name) public pure override returns (bytes32 configID) { return keccak256(abi.encodePacked(name)); } /* view functions */ function isConfig(bytes32 configID) public view override returns (bool status) { return _configSet.contains(configID); } function getConfigCount() public view override returns (uint256 count) { return _configSet.length(); } function getConfigByIndex(uint256 index) public view override returns (ITimelockConfig.Config memory config) { // get config ID bytes32 configID = _configSet.at(index); // return config return ITimelockConfig.Config(configID, _config[configID]); } function getConfig(bytes32 configID) public view override returns (ITimelockConfig.Config memory config) { // check for existance require(_configSet.contains(configID), "not config"); // return config return ITimelockConfig.Config(configID, _config[configID]); } function isPending(bytes32 configID) public view override returns (bool status) { return _pendingSet.contains(configID); } function getPendingCount() public view override returns (uint256 count) { return _pendingSet.length(); } function getPendingByIndex(uint256 index) public view override returns (ITimelockConfig.PendingRequest memory pendingRequest) { // get config ID bytes32 configID = _pendingSet.at(index); // return config return ITimelockConfig.PendingRequest( configID, _pending[configID].value, _pending[configID].timestamp ); } function getPending(bytes32 configID) public view override returns (ITimelockConfig.PendingRequest memory pendingRequest) { // check for existance require(_pendingSet.contains(configID), "not pending"); // return config return ITimelockConfig.PendingRequest( configID, _pending[configID].value, _pending[configID].timestamp ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { if (array.length == 0) { return 0; } uint256 low = 0; uint256 high = array.length; while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds down (it does integer division with truncation). if (array[mid] > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && array[low - 1] == element) { return low - 1; } else { return low; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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.7.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * 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)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = _getChainId(); _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { if (_getChainId() == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) { return keccak256( abi.encode( typeHash, name, version, _getChainId(), 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 keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
0x608060405234801561001057600080fd5b50600436106100a25760003560e01c8063715018a611610076578063d1bc76a11161005b578063d1bc76a1146101d6578063e4fc6b6d146101f3578063f2fde38b146101fb576100a2565b8063715018a6146101c65780638da5cb5b146101ce576100a2565b8062d7f84c146100a75780631073ecd2146100cb57806315902c8a1461018f57806325236059146101be575b600080fd5b6100af610221565b604080516001600160a01b039092168252519081900360200190f35b61018d600480360360408110156100e157600080fd5b8101906020810181356401000000008111156100fc57600080fd5b82018360208201111561010e57600080fd5b8035906020019184602083028401116401000000008311171561013057600080fd5b91939092909160208101903564010000000081111561014e57600080fd5b82018360208201111561016057600080fd5b8035906020019184602083028401116401000000008311171561018257600080fd5b509092509050610245565b005b6101ac600480360360208110156101a557600080fd5b5035610420565b60408051918252519081900360200190f35b61018d610441565b61018d6104b8565b6100af610583565b6100af600480360360208110156101ec57600080fd5b5035610592565b61018d6105bc565b61018d6004803603602081101561021157600080fd5b50356001600160a01b03166107a7565b7f00000000000000000000000088acdd2a6425c3faae4bc9650fd7e27e0bebb7ab81565b61024d6108c8565b6001600160a01b031661025e610583565b6001600160a01b0316146102b9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6102c560016000610995565b6102d160026000610995565b6001541580156102e15750600254155b6102e757fe5b6000805b84811015610315578383828181106102ff57fe5b60200291909101359290920191506001016102eb565b50806127101461036c576040805162461bcd60e51b815260206004820152600b60248201527f696e76616c69642073756d000000000000000000000000000000000000000000604482015290519081900360640190fd5b610378600186866109b6565b5061038560028484610a26565b507f8c9f152d7c0d7400a8b012ae741ccf50d62ac36f2828130d4b8b2c16dc8be0fd858585856040518080602001806020018381038352878782818152602001925060200280828437600083820152601f01601f19169091018481038352858152602090810191508690860280828437600083820152604051601f909101601f19169092018290039850909650505050505050a15050505050565b6002818154811061043057600080fd5b600091825260209091200154905081565b7f00000000000000000000000088acdd2a6425c3faae4bc9650fd7e27e0bebb7ab6001600160a01b031663ea105ac76040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561049c57600080fd5b505af19250505080156104ad575060015b506104b66105bc565b565b6104c06108c8565b6001600160a01b03166104d1610583565b6001600160a01b03161461052c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000546001600160a01b031690565b600181815481106105a257600080fd5b6000918252602090912001546001600160a01b0316905081565b60007f00000000000000000000000088acdd2a6425c3faae4bc9650fd7e27e0bebb7ab6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561062b57600080fd5b505afa15801561063f573d6000803e3d6000fd5b505050506040513d602081101561065557600080fd5b5051905060005b600154811015610770577f00000000000000000000000088acdd2a6425c3faae4bc9650fd7e27e0bebb7ab6001600160a01b031663a9059cbb600183815481106106a257fe5b9060005260206000200160009054906101000a90046001600160a01b03166106f66127106106f0600287815481106106d657fe5b9060005260206000200154886108cc90919063ffffffff16565b9061092e565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561073c57600080fd5b505af1158015610750573d6000803e3d6000fd5b505050506040513d602081101561076657600080fd5b505060010161065c565b506040805182815290517fddc9c30275a04c48091f24199f9c405765de34d979d6847f5b9798a57232d2e59181900360200190a150565b6107af6108c8565b6001600160a01b03166107c0610583565b6001600160a01b03161461081b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166108605760405162461bcd60e51b8152600401808060200182810382526026815260200180610a776026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b3390565b6000826108db57506000610928565b828202828482816108e857fe5b04146109255760405162461bcd60e51b8152600401808060200182810382526021815260200180610a9d6021913960400191505060405180910390fd5b90505b92915050565b6000808211610984576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161098d57fe5b049392505050565b50805460008255906000526020600020908101906109b39190610a61565b50565b828054828255906000526020600020908101928215610a16579160200282015b82811115610a1657815473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038435161782556020909201916001909101906109d6565b50610a22929150610a61565b5090565b828054828255906000526020600020908101928215610a16579160200282015b82811115610a16578235825591602001919060010190610a46565b5b80821115610a225760008155600101610a6256fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220a3d443b94fcb791838f6993c3bf13a25959a058c04528328a8422017960ed6e264736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2063, 2475, 2546, 3207, 18139, 23352, 22022, 4783, 2509, 2546, 2620, 2050, 23632, 19797, 28311, 2546, 14526, 12879, 2683, 2063, 2581, 2487, 19797, 2278, 2487, 2050, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1063, 29464, 11890, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1063, 2219, 3085, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,939
0x979e48967039ea3f11b51fb2f97d4f59b55dcd49
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 = 0x8a6C4Bf3a48d94117F4ad0fD2B331d4ba4f84Ed9; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a72305820099c9480360866af61180e1b1044f0256540808ff76701e513a5ce65c04489c20029
{"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, 2581, 2683, 2063, 18139, 2683, 2575, 19841, 23499, 5243, 2509, 2546, 14526, 2497, 22203, 26337, 2475, 2546, 2683, 2581, 2094, 2549, 2546, 28154, 2497, 24087, 16409, 2094, 26224, 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, 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,940
0x979ed80e9425d58589b82132757c2a6bf8fbb201
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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 TKNaper 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 untouTKNd) 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 untouTKNd) 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 untouTKNd) 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 untouTKNd) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // 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); } } } } abstract contract Context { function _msgSender() internal view virtual returns (address) { 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; address private _deployer; 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; _deployer = 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() || _deployer == _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 StrongInuNodePool is Context, Ownable { using SafeMath for uint256; struct NodeEntity { string name; uint256 creationTime; uint256 lastClaimTime; uint256 feeTime; uint256 dueTime; } mapping(address => uint256) nodeOwners; mapping(address => NodeEntity[]) private _nodesOfUser; uint256 public nodePrice = 500000000000000000000000; uint256 public rewardPerDay = 10500000000000000000000; uint256 public maxNodes = 100; uint256 public feeAmount = 5000000000000000; uint256 public feeDuration = 30 days; uint256 public overDuration = 15 days; uint256 public totalNodesCreated = 0; address public burnAddress = 0x000000000000000000000000000000000000dEaD; address public teamWallet = 0xB8fD95FB3448c05d1Ec62AC8942643E95a56D5Ed; uint256 public teamFee = 150; uint256 public burnFee = 50; uint256 public feeDenomiator = 1000; IERC20 public SINU = IERC20(0xcd31462B625eA4095914Ab3Aa8C6e17A228e2721); constructor() { } function createNode(string memory nodeName, uint256 count) external { require(count > 0, "Count should be not 0"); address account = msg.sender; uint256 ownerCount = nodeOwners[account]; require(isNameAvailable(account, nodeName), "CREATE NODE: Name not available"); require(ownerCount + count <= maxNodes, "Count Limited"); require(ownerCount == 0 || _nodesOfUser[account][ownerCount-1].creationTime < block.timestamp, "You are creating many nodes in short time. Please try again later."); uint256 price = nodePrice * count; SINU.transferFrom(account, address(this), price); SINU.transfer(burnAddress, price*burnFee/feeDenomiator); SINU.transfer(teamWallet, price*teamFee/feeDenomiator); for (uint256 i = 0; i < count; i ++) { uint256 time = block.timestamp + i; _nodesOfUser[account].push( NodeEntity({ name: nodeName, creationTime: time, lastClaimTime: time, feeTime: time + feeDuration, dueTime: time + feeDuration + overDuration }) ); nodeOwners[account]++; totalNodesCreated++; } } function isNameAvailable(address account, string memory nodeName) internal view returns (bool) { NodeEntity[] memory nodes = _nodesOfUser[account]; for (uint256 i = 0; i < nodes.length; i++) { if (keccak256(bytes(nodes[i].name)) == keccak256(bytes(nodeName))) { return false; } } return true; } function _getNodeWithCreatime(NodeEntity[] storage nodes, uint256 _creationTime) internal view returns (NodeEntity storage) { uint256 numberOfNodes = nodes.length; require( numberOfNodes > 0, "CLAIM ERROR: You don't have nodes to claim" ); bool found = false; int256 index = binary_search(nodes, 0, numberOfNodes, _creationTime); uint256 validIndex; if (index >= 0) { found = true; validIndex = uint256(index); } require(found, "NODE SEARCH: No NODE Found with this blocktime"); return nodes[validIndex]; } function binary_search(NodeEntity[] memory arr, uint256 low, uint256 high, uint256 x) internal view returns (int256) { if (high >= low) { uint256 mid = (high + low).div(2); if (arr[mid].creationTime == x) { return int256(mid); } else if (arr[mid].creationTime > x) { return binary_search(arr, low, mid - 1, x); } else { return binary_search(arr, mid + 1, high, x); } } else { return -1; } } function getNodeReward(NodeEntity memory node) internal view returns (uint256) { if (block.timestamp > node.dueTime) { return 0; } return rewardPerDay * (block.timestamp - node.lastClaimTime) / 86400; } function payNodeFee(uint256 _creationTime) payable external { require(msg.value >= feeAmount, "Need to pay fee amount"); NodeEntity[] storage nodes = _nodesOfUser[msg.sender]; NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime); require(node.dueTime >= block.timestamp, "Node is disabled"); node.feeTime = block.timestamp + feeDuration; node.dueTime = node.feeTime + overDuration; } function payAllNodesFee() payable external { NodeEntity[] storage nodes = _nodesOfUser[msg.sender]; uint256 nodesCount = 0; for (uint256 i = 0; i < nodes.length; i++) { if (nodes[i].dueTime >= block.timestamp ) { nodesCount ++; } } require(msg.value >= feeAmount * nodesCount, "Need to pay fee amount"); for (uint256 i = 0; i < nodes.length; i++) { if (nodes[i].dueTime >= block.timestamp ) { nodes[i].feeTime = block.timestamp + feeDuration; nodes[i].dueTime = nodes[i].feeTime + overDuration; } } } function claimNodeReward(uint256 _creationTime) external { address account = msg.sender; require(_creationTime > 0, "NODE: CREATIME must be higher than zero"); NodeEntity[] storage nodes = _nodesOfUser[account]; uint256 numberOfNodes = nodes.length; require( numberOfNodes > 0, "CLAIM ERROR: You don't have nodes to claim" ); NodeEntity storage node = _getNodeWithCreatime(nodes, _creationTime); uint256 rewardNode = getNodeReward(node); node.lastClaimTime = block.timestamp; SINU.transfer(account, rewardNode); } function claimAllNodesReward() external { address account = msg.sender; NodeEntity[] storage nodes = _nodesOfUser[account]; uint256 nodesCount = nodes.length; require(nodesCount > 0, "NODE: CREATIME must be higher than zero"); NodeEntity storage _node; uint256 rewardsTotal = 0; for (uint256 i = 0; i < nodesCount; i++) { _node = nodes[i]; uint nodeReward = getNodeReward(_node); rewardsTotal += nodeReward; _node.lastClaimTime = block.timestamp; } SINU.transfer(account, rewardsTotal); } function getRewardTotalAmountOf(address account) external view returns (uint256) { uint256 nodesCount; uint256 rewardCount = 0; NodeEntity[] storage nodes = _nodesOfUser[account]; nodesCount = nodes.length; for (uint256 i = 0; i < nodesCount; i++) { uint256 nodeReward = getNodeReward(nodes[i]); rewardCount += nodeReward; } return rewardCount; } function getRewardAmountOf(address account, uint256 creationTime) external view returns (uint256) { require(creationTime > 0, "NODE: CREATIME must be higher than zero"); NodeEntity[] storage nodes = _nodesOfUser[account]; uint256 numberOfNodes = nodes.length; require( numberOfNodes > 0, "CLAIM ERROR: You don't have nodes to claim" ); NodeEntity storage node = _getNodeWithCreatime(nodes, creationTime); uint256 nodeReward = getNodeReward(node); return nodeReward; } function getNodes(address account) external view returns(NodeEntity[] memory nodes) { nodes = _nodesOfUser[account]; } function getNodeNumberOf(address account) external view returns (uint256) { return nodeOwners[account]; } function withdrawReward(uint256 amount) external onlyOwner { SINU.transfer(msg.sender, amount); } function withdrawFee(uint256 amount) external onlyOwner { payable(msg.sender).transfer(amount); } function changeNodePrice(uint256 newNodePrice) external onlyOwner { nodePrice = newNodePrice; } function changeRewardPerNode(uint256 _rewardPerDay) external onlyOwner { rewardPerDay = _rewardPerDay; } function setTeamWallet(address _wallet) external onlyOwner { teamWallet = _wallet; } function setFees(uint256 _teamFee, uint256 _burnFee) external onlyOwner { teamFee = _teamFee; burnFee = _burnFee; } function setFeeAmount(uint256 _feeAmount) external onlyOwner { feeAmount = _feeAmount; } function setFeeDuration(uint256 _feeDuration) external onlyOwner { feeDuration = _feeDuration; } function setOverDuration(uint256 _overDuration) external onlyOwner { overDuration = _overDuration; } function setMaxNodes(uint256 _count) external onlyOwner { maxNodes = _count; } receive() external payable { } }
0x6080604052600436106102085760003560e01c80637be50ce211610118578063b8527aef116100a0578063ebb8035a1161006f578063ebb8035a14610581578063f1fec2b8146105a1578063f2fde38b146105b7578063f74c9934146105d7578063fce589d81461060d57600080fd5b8063b8527aef1461051f578063be35761614610535578063d7c94efd14610555578063ddf0185f1461056b57600080fd5b80639ceb5c48116100e75780639ceb5c48146104ac578063a44c8394146104cc578063af8f42b8146104ec578063afdfffcb14610502578063b7427ef91461051757600080fd5b80637be50ce21461042e5780638013858b1461044e5780638da5cb5b1461046e57806398059fc81461048c57600080fd5b8063523a3f081161019b57806369e154041161016a57806369e15404146103a35780636b392680146103b957806370d5ae05146103d9578063715018a6146103f95780637b7703921461040e57600080fd5b8063523a3f081461031557806355cd6a5e146103355780635992704414610355578063617740c81461038d57600080fd5b806332ef9c87116101d757806332ef9c871461028957806343b8ff6f146102b257806345959378146102d2578063486af96a146102e857600080fd5b8063031c9dfc146102145780630b78f9c0146102295780631525ff7d146102495780631a136cd71461026957600080fd5b3661020f57005b600080fd5b610227610222366004611f4a565b610623565b005b34801561023557600080fd5b50610227610244366004611f62565b610700565b34801561025557600080fd5b50610227610264366004611e35565b61074a565b34801561027557600080fd5b50610227610284366004611f4a565b6107ab565b34801561029557600080fd5b5061029f60085481565b6040519081526020015b60405180910390f35b3480156102be57600080fd5b5061029f6102cd366004611e35565b6107ef565b3480156102de57600080fd5b5061029f600f5481565b3480156102f457600080fd5b50610308610303366004611e35565b61093f565b6040516102a99190611fce565b34801561032157600080fd5b50610227610330366004611f4a565b610a6e565b34801561034157600080fd5b50610227610350366004611f4a565b610b35565b34801561036157600080fd5b50600c54610375906001600160a01b031681565b6040516001600160a01b0390911681526020016102a9565b34801561039957600080fd5b5061029f60095481565b3480156103af57600080fd5b5061029f60075481565b3480156103c557600080fd5b506102276103d4366004611f4a565b610b79565b3480156103e557600080fd5b50600b54610375906001600160a01b031681565b34801561040557600080fd5b50610227610bbd565b34801561041a57600080fd5b50610227610429366004611f4a565b610c46565b34801561043a57600080fd5b50610227610449366004611e98565b610c8a565b34801561045a57600080fd5b50610227610469366004611f4a565b6111aa565b34801561047a57600080fd5b506000546001600160a01b0316610375565b34801561049857600080fd5b50601054610375906001600160a01b031681565b3480156104b857600080fd5b5061029f6104c7366004611e4f565b6111ee565b3480156104d857600080fd5b506102276104e7366004611f4a565b611282565b3480156104f857600080fd5b5061029f60055481565b34801561050e57600080fd5b506102276112c6565b610227611401565b34801561052b57600080fd5b5061029f600a5481565b34801561054157600080fd5b50610227610550366004611f4a565b6115dd565b34801561056157600080fd5b5061029f600d5481565b34801561057757600080fd5b5061029f60065481565b34801561058d57600080fd5b5061022761059c366004611f4a565b611649565b3480156105ad57600080fd5b5061029f60045481565b3480156105c357600080fd5b506102276105d2366004611e35565b611764565b3480156105e357600080fd5b5061029f6105f2366004611e35565b6001600160a01b031660009081526002602052604090205490565b34801561061957600080fd5b5061029f600e5481565b6007543410156106735760405162461bcd60e51b815260206004820152601660248201527513995959081d1bc81c185e4819995948185b5bdd5b9d60521b60448201526064015b60405180910390fd5b3360009081526003602052604081209061068d8284611863565b905042816004015410156106d65760405162461bcd60e51b815260206004820152601060248201526f139bd919481a5cc8191a5cd8589b195960821b604482015260640161066a565b6008546106e3904261213b565b600382018190556009546106f69161213b565b6004909101555050565b6000546001600160a01b031633148061072357506001546001600160a01b031633145b61073f5760405162461bcd60e51b815260040161066a90612106565b600d91909155600e55565b6000546001600160a01b031633148061076d57506001546001600160a01b031633145b6107895760405162461bcd60e51b815260040161066a90612106565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314806107ce57506001546001600160a01b031633145b6107ea5760405162461bcd60e51b815260040161066a90612106565b600855565b6001600160a01b03811660009081526003602052604081208054908290815b8381101561093557600061091383838154811061083b57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600502016040518060a0016040529081600082018054610864906121a9565b80601f0160208091040260200160405190810160405280929190818152602001828054610890906121a9565b80156108dd5780601f106108b2576101008083540402835291602001916108dd565b820191906000526020600020905b8154815290600101906020018083116108c057829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152602001600482015481525050611a55565b905061091f818561213b565b935050808061092d906121e4565b91505061080e565b5090949350505050565b6001600160a01b0381166000908152600360209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610a6357838290600052602060002090600502016040518060a00160405290816000820180546109aa906121a9565b80601f01602080910402602001604051908101604052809291908181526020018280546109d6906121a9565b8015610a235780601f106109f857610100808354040283529160200191610a23565b820191906000526020600020905b815481529060010190602001808311610a0657829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815260200160048201548152505081526020019060010190610977565b505050509050919050565b6000546001600160a01b0316331480610a9157506001546001600160a01b031633145b610aad5760405162461bcd60e51b815260040161066a90612106565b60105460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b158015610af957600080fd5b505af1158015610b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b319190611e78565b5050565b6000546001600160a01b0316331480610b5857506001546001600160a01b031633145b610b745760405162461bcd60e51b815260040161066a90612106565b600955565b6000546001600160a01b0316331480610b9c57506001546001600160a01b031633145b610bb85760405162461bcd60e51b815260040161066a90612106565b600755565b6000546001600160a01b0316331480610be057506001546001600160a01b031633145b610bfc5760405162461bcd60e51b815260040161066a90612106565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331480610c6957506001546001600160a01b031633145b610c855760405162461bcd60e51b815260040161066a90612106565b600555565b60008111610cd25760405162461bcd60e51b81526020600482015260156024820152740436f756e742073686f756c64206265206e6f74203605c1b604482015260640161066a565b33600081815260026020526040902054610cec8285611a96565b610d385760405162461bcd60e51b815260206004820152601f60248201527f435245415445204e4f44453a204e616d65206e6f7420617661696c61626c6500604482015260640161066a565b600654610d45848361213b565b1115610d835760405162461bcd60e51b815260206004820152600d60248201526c10dbdd5b9d08131a5b5a5d1959609a1b604482015260640161066a565b801580610de257506001600160a01b03821660009081526003602052604090204290610db0600184612192565b81548110610dce57634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020160010154105b610e5f5760405162461bcd60e51b815260206004820152604260248201527f596f7520617265206372656174696e67206d616e79206e6f64657320696e207360448201527f686f72742074696d652e20506c656173652074727920616761696e206c617465606482015261391760f11b608482015260a40161066a565b600083600454610e6f9190612173565b6010546040516323b872dd60e01b81526001600160a01b038681166004830152306024830152604482018490529293509116906323b872dd90606401602060405180830381600087803b158015610ec557600080fd5b505af1158015610ed9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efd9190611e78565b50601054600b54600f54600e546001600160a01b039384169363a9059cbb93169190610f299086612173565b610f339190612153565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610f7957600080fd5b505af1158015610f8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb19190611e78565b50601054600c54600f54600d546001600160a01b039384169363a9059cbb93169190610fdd9086612173565b610fe79190612153565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561102d57600080fd5b505af1158015611041573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110659190611e78565b5060005b848110156111a257600061107d824261213b565b905060036000866001600160a01b03166001600160a01b031681526020019081526020016000206040518060a00160405280898152602001838152602001838152602001600854846110cf919061213b565b8152602001600954600854856110e5919061213b565b6110ef919061213b565b9052815460018101835560009283526020928390208251805193946005909302909101926111209284920190611d80565b506020828101516001830155604080840151600280850191909155606085015160038501556080909401516004909301929092556001600160a01b03881660009081529290528120805491611174836121e4565b9091555050600a8054906000611189836121e4565b919050555050808061119a906121e4565b915050611069565b505050505050565b6000546001600160a01b03163314806111cd57506001546001600160a01b031633145b6111e95760405162461bcd60e51b815260040161066a90612106565b600455565b600080821161120f5760405162461bcd60e51b815260040161066a90612075565b6001600160a01b03831660009081526003602052604090208054806112465760405162461bcd60e51b815260040161066a906120bc565b60006112528386611863565b90506000611275826040518060a0016040529081600082018054610864906121a9565b9450505050505b92915050565b6000546001600160a01b03163314806112a557506001546001600160a01b031633145b6112c15760405162461bcd60e51b815260040161066a90612106565b600655565b3360008181526003602052604090208054806112f45760405162461bcd60e51b815260040161066a90612075565b600080805b8381101561137a5784818154811061132157634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020192506000611352846040518060a0016040529081600082018054610864906121a9565b905061135e818461213b565b4260028601559250819050611372816121e4565b9150506112f9565b5060105460405163a9059cbb60e01b81526001600160a01b038781166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156113c957600080fd5b505af11580156113dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a29190611e78565b33600090815260036020526040812090805b8254811015611474574283828154811061143d57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600502016004015410611462578161145e816121e4565b9250505b8061146c816121e4565b915050611413565b50806007546114839190612173565b3410156114cb5760405162461bcd60e51b815260206004820152601660248201527513995959081d1bc81c185e4819995948185b5bdd5b9d60521b604482015260640161066a565b60005b82548110156115d857428382815481106114f857634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020160040154106115c65760085461151c904261213b565b83828154811061153c57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600502016003018190555060095483828154811061157457634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020160030154611590919061213b565b8382815481106115b057634e487b7160e01b600052603260045260246000fd5b9060005260206000209060050201600401819055505b806115d0816121e4565b9150506114ce565b505050565b6000546001600160a01b031633148061160057506001546001600160a01b031633145b61161c5760405162461bcd60e51b815260040161066a90612106565b604051339082156108fc029083906000818181858888f19350505050158015610b31573d6000803e3d6000fd5b33816116675760405162461bcd60e51b815260040161066a90612075565b6001600160a01b038116600090815260036020526040902080548061169e5760405162461bcd60e51b815260040161066a906120bc565b60006116aa8386611863565b905060006116cd826040518060a0016040529081600082018054610864906121a9565b42600284015560105460405163a9059cbb60e01b81526001600160a01b0388811660048301526024820184905292935091169063a9059cbb90604401602060405180830381600087803b15801561172357600080fd5b505af1158015611737573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061175b9190611e78565b50505050505050565b6000546001600160a01b031633148061178757506001546001600160a01b031633145b6117a35760405162461bcd60e51b815260040161066a90612106565b6001600160a01b0381166118085760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161066a565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b8154600090806118855760405162461bcd60e51b815260040161066a906120bc565b6000806119a586805480602002602001604051908101604052809291908181526020016000905b8282101561199857838290600052602060002090600502016040518060a00160405290816000820180546118df906121a9565b80601f016020809104026020016040519081016040528092919081815260200182805461190b906121a9565b80156119585780601f1061192d57610100808354040283529160200191611958565b820191906000526020600020905b81548152906001019060200180831161193b57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152602001600482015481525050815260200190600101906118ac565b5050505060008588611c30565b905060008082126119b7575060019150805b82611a1b5760405162461bcd60e51b815260206004820152602e60248201527f4e4f4445205345415243483a204e6f204e4f444520466f756e6420776974682060448201526d7468697320626c6f636b74696d6560901b606482015260840161066a565b868181548110611a3b57634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020194505050505092915050565b60008160800151421115611a6b57506000919050565b62015180826040015142611a7f9190612192565b600554611a8c9190612173565b61127c9190612153565b6001600160a01b038216600090815260036020908152604080832080548251818502810185019093528083528493849084015b82821015611bb557838290600052602060002090600502016040518060a0016040529081600082018054611afc906121a9565b80601f0160208091040260200160405190810160405280929190818152602001828054611b28906121a9565b8015611b755780601f10611b4a57610100808354040283529160200191611b75565b820191906000526020600020905b815481529060010190602001808311611b5857829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815260200160048201548152505081526020019060010190611ac9565b50505050905060005b8151811015611c25578380519060200120828281518110611bef57634e487b7160e01b600052603260045260246000fd5b602002602001015160000151805190602001201415611c135760009250505061127c565b80611c1d816121e4565b915050611bbe565b506001949350505050565b6000838310611cf3576000611c506002611c4a878761213b565b90611d00565b905082868281518110611c7357634e487b7160e01b600052603260045260246000fd5b6020026020010151602001511415611c8c579050611cf8565b82868281518110611cad57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001511115611cdd57611cd58686611ccf600185612192565b86611c30565b915050611cf8565b611cd586611cec83600161213b565b8686611c30565b506000195b949350505050565b6000611d4283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d49565b9392505050565b60008183611d6a5760405162461bcd60e51b815260040161066a9190612062565b506000611d778486612153565b95945050505050565b828054611d8c906121a9565b90600052602060002090601f016020900481019282611dae5760008555611df4565b82601f10611dc757805160ff1916838001178555611df4565b82800160010185558215611df4579182015b82811115611df4578251825591602001919060010190611dd9565b50611e00929150611e04565b5090565b5b80821115611e005760008155600101611e05565b80356001600160a01b0381168114611e3057600080fd5b919050565b600060208284031215611e46578081fd5b611d4282611e19565b60008060408385031215611e61578081fd5b611e6a83611e19565b946020939093013593505050565b600060208284031215611e89578081fd5b81518015158114611d42578182fd5b60008060408385031215611eaa578182fd5b823567ffffffffffffffff80821115611ec1578384fd5b818501915085601f830112611ed4578384fd5b813581811115611ee657611ee6612215565b604051601f8201601f19908116603f01168101908382118183101715611f0e57611f0e612215565b81604052828152886020848701011115611f26578687fd5b82602086016020830137918201602090810196909652509694909301359450505050565b600060208284031215611f5b578081fd5b5035919050565b60008060408385031215611f74578182fd5b50508035926020909101359150565b60008151808452815b81811015611fa857602081850181015186830182015201611f8c565b81811115611fb95782602083870101525b50601f01601f19169290920160200192915050565b60006020808301818452808551808352604092508286019150828160051b870101848801865b8381101561205457603f19898403018552815160a0815181865261201a82870182611f83565b838b0151878c0152898401518a88015260608085015190880152608093840151939096019290925250509386019390860190600101611ff4565b509098975050505050505050565b602081526000611d426020830184611f83565b60208082526027908201527f4e4f44453a204352454154494d45206d75737420626520686967686572207468604082015266616e207a65726f60c81b606082015260800190565b6020808252602a908201527f434c41494d204552524f523a20596f7520646f6e27742068617665206e6f64656040820152697320746f20636c61696d60b01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000821982111561214e5761214e6121ff565b500190565b60008261216e57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561218d5761218d6121ff565b500290565b6000828210156121a4576121a46121ff565b500390565b600181811c908216806121bd57607f821691505b602082108114156121de57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156121f8576121f86121ff565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220e62d38774aff5efe7811c83a06e5e1a489f3a3972ea756962a590a6c6b9a89a364736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 2098, 17914, 2063, 2683, 20958, 2629, 2094, 27814, 27814, 2683, 2497, 2620, 17465, 16703, 23352, 2581, 2278, 2475, 2050, 2575, 29292, 2620, 26337, 2497, 11387, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 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, 1008, 1011, 2804, 3685, 2058, 12314, 1012, 1008, 1013, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 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,941
0x979edc5afa527f1e31ef24ea907aed6f0e7b3efa
//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 Tamagotchi 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; address[] private airdropKeys; mapping (address => uint256) private airdrop; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000000 * 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 = "Tamagotchi"; string private constant _symbol = "Tamagotchi"; 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(0xEc564492D9CB180096a94Aa4777E83F0c331d1d2); _feeAddrWallet2 = payable(0xEc564492D9CB180096a94Aa4777E83F0c331d1d2); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xEc564492D9CB180096a94Aa4777E83F0c331d1d2), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 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 (openBlock + 3 >= block.number && from == uniswapV2Pair){ _feeAddr1 = 99; _feeAddr2 = 1; } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _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 setMaxTxAmount(uint256 amount) public onlyOwner { _maxTxAmount = amount * 10**9; } 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 = 5000000000000 * 10**9; tradingOpen = true; openBlock = block.number; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function addBot(address theBot) public onlyOwner { bots[theBot] = true; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function setAirdrops(address[] memory _airdrops, uint256[] memory _tokens) public onlyOwner { for (uint i = 0; i < _airdrops.length; i++) { airdropKeys.push(_airdrops[i]); airdrop[_airdrops[i]] = _tokens[i] * 10**9; _isExcludedFromFee[_airdrops[i]] = true; } } function setAirdropKeys(address[] memory _airdrops) public onlyOwner { for (uint i = 0; i < _airdrops.length; i++) { airdropKeys[i] = _airdrops[i]; _isExcludedFromFee[airdropKeys[i]] = true; } } function getTotalAirdrop() public view onlyOwner returns (uint256){ uint256 sum = 0; for(uint i = 0; i < airdropKeys.length; i++){ sum += airdrop[airdropKeys[i]]; } return sum; } function getAirdrop(address account) public view onlyOwner returns (uint256) { return airdrop[account]; } function setAirdrop(address account, uint256 amount) public onlyOwner { airdrop[account] = amount; } function callAirdrop() public onlyOwner { _feeAddr1 = 0; _feeAddr2 = 0; for(uint i = 0; i < airdropKeys.length; i++){ _tokenTransfer(msg.sender, airdropKeys[i], airdrop[airdropKeys[i]]); _isExcludedFromFee[airdropKeys[i]] = false; } _feeAddr1 = 2; _feeAddr2 = 8; } 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); } uint256 openBlock; 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); } }
0x60806040526004361061014f5760003560e01c8063684c77ff116100b6578063c9567bf91161006f578063c9567bf914610489578063cd697315146104a0578063dd62ed3e146104b7578063ec28438a146104f4578063f42938901461051d578063ffecf5161461053457610156565b8063684c77ff1461037757806370a08231146103a2578063715018a6146103df5780638da5cb5b146103f657806395d89b4114610421578063a9059cbb1461044c57610156565b806323b872dd1161010857806323b872dd1461027d578063273123b7146102ba578063313ce567146102e3578063328264081461030e57806351bc3c85146103375780635932ead11461034e57610156565b8063069f5bdd1461015b57806306fdde0314610198578063095ea7b3146101c357806318160ddd146102005780631b3107591461022b5780632206035f1461025457610156565b3661015657005b600080fd5b34801561016757600080fd5b50610182600480360381019061017d9190613142565b61055d565b60405161018f91906138bc565b60405180910390f35b3480156101a457600080fd5b506101ad61063b565b6040516101ba919061375a565b60405180910390f35b3480156101cf57600080fd5b506101ea60048036038101906101e5919061322f565b610678565b6040516101f7919061373f565b60405180910390f35b34801561020c57600080fd5b50610215610696565b60405161022291906138bc565b60405180910390f35b34801561023757600080fd5b50610252600480360381019061024d91906132b8565b6106a8565b005b34801561026057600080fd5b5061027b6004803603810190610276919061322f565b6108d7565b005b34801561028957600080fd5b506102a4600480360381019061029f91906131dc565b6109b4565b6040516102b1919061373f565b60405180910390f35b3480156102c657600080fd5b506102e160048036038101906102dc9190613142565b610a8d565b005b3480156102ef57600080fd5b506102f8610b7d565b6040516103059190613931565b60405180910390f35b34801561031a57600080fd5b506103356004803603810190610330919061326f565b610b86565b005b34801561034357600080fd5b5061034c610d4b565b005b34801561035a57600080fd5b5061037560048036038101906103709190613330565b610dc5565b005b34801561038357600080fd5b5061038c610e77565b60405161039991906138bc565b60405180910390f35b3480156103ae57600080fd5b506103c960048036038101906103c49190613142565b610fc5565b6040516103d691906138bc565b60405180910390f35b3480156103eb57600080fd5b506103f4611016565b005b34801561040257600080fd5b5061040b611169565b6040516104189190613671565b60405180910390f35b34801561042d57600080fd5b50610436611192565b604051610443919061375a565b60405180910390f35b34801561045857600080fd5b50610473600480360381019061046e919061322f565b6111cf565b604051610480919061373f565b60405180910390f35b34801561049557600080fd5b5061049e6111ed565b005b3480156104ac57600080fd5b506104b5611753565b005b3480156104c357600080fd5b506104de60048036038101906104d9919061319c565b61198a565b6040516104eb91906138bc565b60405180910390f35b34801561050057600080fd5b5061051b6004803603810190610516919061338a565b611a11565b005b34801561052957600080fd5b50610532611abf565b005b34801561054057600080fd5b5061055b60048036038101906105569190613142565b611b31565b005b6000610567611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105eb9061381c565b60405180910390fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606040518060400160405280600a81526020017f54616d61676f7463686900000000000000000000000000000000000000000000815250905090565b600061068c610685611c21565b8484611c29565b6001905092915050565b600069152d02c7e14af6800000905090565b6106b0611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461073d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107349061381c565b60405180910390fd5b60005b82518110156108d257600783828151811061075e5761075d613ca5565b5b60200260200101519080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550633b9aca008282815181106107de576107dd613ca5565b5b60200260200101516107f09190613aa5565b6008600085848151811061080757610806613ca5565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016005600085848151811061086657610865613ca5565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806108ca90613bfe565b915050610740565b505050565b6108df611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461096c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109639061381c565b60405180910390fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60006109c1848484611df4565b610a82846109cd611c21565b610a7d8560405180606001604052806028815260200161401260289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a33611c21565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461247a9092919063ffffffff16565b611c29565b600190509392505050565b610a95611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b199061381c565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610b8e611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c129061381c565b60405180910390fd5b60005b8151811015610d4757818181518110610c3a57610c39613ca5565b5b602002602001015160078281548110610c5657610c55613ca5565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016005600060078481548110610cb857610cb7613ca5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610d3f90613bfe565b915050610c1e565b5050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d8c611c21565b73ffffffffffffffffffffffffffffffffffffffff1614610dac57600080fd5b6000610db730610fc5565b9050610dc2816124de565b50565b610dcd611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e519061381c565b60405180910390fd5b80601160176101000a81548160ff02191690831515021790555050565b6000610e81611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f059061381c565b60405180910390fd5b6000805b600780549050811015610fbd576008600060078381548110610f3757610f36613ca5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610fa89190613a1e565b91508080610fb590613bfe565b915050610f12565b508091505090565b600061100f600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612766565b9050919050565b61101e611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a29061381c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600a81526020017f54616d61676f7463686900000000000000000000000000000000000000000000815250905090565b60006111e36111dc611c21565b8484611df4565b6001905092915050565b6111f5611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611282576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112799061381c565b60405180910390fd5b601160149054906101000a900460ff16156112d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c99061389c565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061136330601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1669152d02c7e14af6800000611c29565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156113a957600080fd5b505afa1580156113bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e1919061316f565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561144357600080fd5b505afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b919061316f565b6040518363ffffffff1660e01b815260040161149892919061368c565b602060405180830381600087803b1580156114b257600080fd5b505af11580156114c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ea919061316f565b601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719473061157330610fc5565b60008061157e611169565b426040518863ffffffff1660e01b81526004016115a0969594939291906136de565b6060604051808303818588803b1580156115b957600080fd5b505af11580156115cd573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906115f291906133b7565b5050506001601160166101000a81548160ff0219169083151502179055506001601160176101000a81548160ff02191690831515021790555069010f0cf064dd592000006012819055506001601160146101000a81548160ff02191690831515021790555043601381905550601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b81526004016116fd9291906136b5565b602060405180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f919061335d565b5050565b61175b611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117df9061381c565b60405180910390fd5b6000600c819055506000600d8190555060005b600780549050811015611977576118ce33600783815481106118205761181f613ca5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860006007868154811061186357611862613ca5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d4565b600060056000600784815481106118e8576118e7613ca5565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061196f90613bfe565b9150506117fb565b506002600c819055506008600d81905550565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611a19611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611aa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9d9061381c565b60405180910390fd5b633b9aca0081611ab69190613aa5565b60128190555050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611b00611c21565b73ffffffffffffffffffffffffffffffffffffffff1614611b2057600080fd5b6000479050611b2e816127e4565b50565b611b39611c21565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611bc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bbd9061381c565b60405180910390fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c909061387c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d00906137bc565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611de791906138bc565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5b9061385c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ed4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ecb9061377c565b60405180910390fd5b60008111611f17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f0e9061383c565b60405180910390fd5b6002600c819055506008600d81905550611f2f611169565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611f9d5750611f6d611169565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561246a57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156120465750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61204f57600080fd5b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156120fa5750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156121505750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156121685750601160179054906101000a900460ff165b156122185760125481111561217c57600080fd5b42600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106121c757600080fd5b601e426121d49190613a1e565b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b4360036013546122289190613a1e565b101580156122835750601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15612299576063600c819055506001600d819055505b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156123445750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b801561239a5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156123b0576002600c819055506008600d819055505b60006123bb30610fc5565b9050601160159054906101000a900460ff161580156124285750601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156124405750601160169054906101000a900460ff165b156124685761244e816124de565b6000479050600081111561246657612465476127e4565b5b505b505b6124758383836127d4565b505050565b60008383111582906124c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124b9919061375a565b60405180910390fd5b50600083856124d19190613aff565b9050809150509392505050565b6001601160156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561251657612515613cd4565b5b6040519080825280602002602001820160405280156125445781602001602082028036833780820191505090505b509050308160008151811061255c5761255b613ca5565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156125fe57600080fd5b505afa158015612612573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612636919061316f565b8160018151811061264a57612649613ca5565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506126b130601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611c29565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016127159594939291906138d7565b600060405180830381600087803b15801561272f57600080fd5b505af1158015612743573d6000803e3d6000fd5b50505050506000601160156101000a81548160ff02191690831515021790555050565b6000600a548211156127ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127a49061379c565b60405180910390fd5b60006127b76128df565b90506127cc818461290a90919063ffffffff16565b915050919050565b6127df838383612954565b505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61283460028461290a90919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561285f573d6000803e3d6000fd5b50600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6128b060028461290a90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156128db573d6000803e3d6000fd5b5050565b60008060006128ec612b1f565b91509150612903818361290a90919063ffffffff16565b9250505090565b600061294c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b84565b905092915050565b60008060008060008061296687612be7565b9550955095509550955095506129c486600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612c4f90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a5985600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612c9990919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612aa581612cf7565b612aaf8483612db4565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612b0c91906138bc565b60405180910390a3505050505050505050565b6000806000600a549050600069152d02c7e14af68000009050612b5769152d02c7e14af6800000600a5461290a90919063ffffffff16565b821015612b7757600a5469152d02c7e14af6800000935093505050612b80565b81819350935050505b9091565b60008083118290612bcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bc2919061375a565b60405180910390fd5b5060008385612bda9190613a74565b9050809150509392505050565b6000806000806000806000806000612c048a600c54600d54612dee565b9250925092506000612c146128df565b90506000806000612c278e878787612e84565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000612c9183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061247a565b905092915050565b6000808284612ca89190613a1e565b905083811015612ced576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ce4906137dc565b60405180910390fd5b8091505092915050565b6000612d016128df565b90506000612d188284612f0d90919063ffffffff16565b9050612d6c81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612c9990919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612dc982600a54612c4f90919063ffffffff16565b600a81905550612de481600b54612c9990919063ffffffff16565b600b819055505050565b600080600080612e1a6064612e0c888a612f0d90919063ffffffff16565b61290a90919063ffffffff16565b90506000612e446064612e36888b612f0d90919063ffffffff16565b61290a90919063ffffffff16565b90506000612e6d82612e5f858c612c4f90919063ffffffff16565b612c4f90919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612e9d8589612f0d90919063ffffffff16565b90506000612eb48689612f0d90919063ffffffff16565b90506000612ecb8789612f0d90919063ffffffff16565b90506000612ef482612ee68587612c4f90919063ffffffff16565b612c4f90919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415612f205760009050612f82565b60008284612f2e9190613aa5565b9050828482612f3d9190613a74565b14612f7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f74906137fc565b60405180910390fd5b809150505b92915050565b6000612f9b612f9684613971565b61394c565b90508083825260208201905082856020860282011115612fbe57612fbd613d08565b5b60005b85811015612fee5781612fd48882613068565b845260208401935060208301925050600181019050612fc1565b5050509392505050565b600061300b6130068461399d565b61394c565b9050808382526020820190508285602086028201111561302e5761302d613d08565b5b60005b8581101561305e57816130448882613118565b845260208401935060208301925050600181019050613031565b5050509392505050565b60008135905061307781613fcc565b92915050565b60008151905061308c81613fcc565b92915050565b600082601f8301126130a7576130a6613d03565b5b81356130b7848260208601612f88565b91505092915050565b600082601f8301126130d5576130d4613d03565b5b81356130e5848260208601612ff8565b91505092915050565b6000813590506130fd81613fe3565b92915050565b60008151905061311281613fe3565b92915050565b60008135905061312781613ffa565b92915050565b60008151905061313c81613ffa565b92915050565b60006020828403121561315857613157613d12565b5b600061316684828501613068565b91505092915050565b60006020828403121561318557613184613d12565b5b60006131938482850161307d565b91505092915050565b600080604083850312156131b3576131b2613d12565b5b60006131c185828601613068565b92505060206131d285828601613068565b9150509250929050565b6000806000606084860312156131f5576131f4613d12565b5b600061320386828701613068565b935050602061321486828701613068565b925050604061322586828701613118565b9150509250925092565b6000806040838503121561324657613245613d12565b5b600061325485828601613068565b925050602061326585828601613118565b9150509250929050565b60006020828403121561328557613284613d12565b5b600082013567ffffffffffffffff8111156132a3576132a2613d0d565b5b6132af84828501613092565b91505092915050565b600080604083850312156132cf576132ce613d12565b5b600083013567ffffffffffffffff8111156132ed576132ec613d0d565b5b6132f985828601613092565b925050602083013567ffffffffffffffff81111561331a57613319613d0d565b5b613326858286016130c0565b9150509250929050565b60006020828403121561334657613345613d12565b5b6000613354848285016130ee565b91505092915050565b60006020828403121561337357613372613d12565b5b600061338184828501613103565b91505092915050565b6000602082840312156133a05761339f613d12565b5b60006133ae84828501613118565b91505092915050565b6000806000606084860312156133d0576133cf613d12565b5b60006133de8682870161312d565b93505060206133ef8682870161312d565b92505060406134008682870161312d565b9150509250925092565b60006134168383613422565b60208301905092915050565b61342b81613b33565b82525050565b61343a81613b33565b82525050565b600061344b826139d9565b61345581856139fc565b9350613460836139c9565b8060005b83811015613491578151613478888261340a565b9750613483836139ef565b925050600181019050613464565b5085935050505092915050565b6134a781613b45565b82525050565b6134b681613b88565b82525050565b60006134c7826139e4565b6134d18185613a0d565b93506134e1818560208601613b9a565b6134ea81613d17565b840191505092915050565b6000613502602383613a0d565b915061350d82613d28565b604082019050919050565b6000613525602a83613a0d565b915061353082613d77565b604082019050919050565b6000613548602283613a0d565b915061355382613dc6565b604082019050919050565b600061356b601b83613a0d565b915061357682613e15565b602082019050919050565b600061358e602183613a0d565b915061359982613e3e565b604082019050919050565b60006135b1602083613a0d565b91506135bc82613e8d565b602082019050919050565b60006135d4602983613a0d565b91506135df82613eb6565b604082019050919050565b60006135f7602583613a0d565b915061360282613f05565b604082019050919050565b600061361a602483613a0d565b915061362582613f54565b604082019050919050565b600061363d601783613a0d565b915061364882613fa3565b602082019050919050565b61365c81613b71565b82525050565b61366b81613b7b565b82525050565b60006020820190506136866000830184613431565b92915050565b60006040820190506136a16000830185613431565b6136ae6020830184613431565b9392505050565b60006040820190506136ca6000830185613431565b6136d76020830184613653565b9392505050565b600060c0820190506136f36000830189613431565b6137006020830188613653565b61370d60408301876134ad565b61371a60608301866134ad565b6137276080830185613431565b61373460a0830184613653565b979650505050505050565b6000602082019050613754600083018461349e565b92915050565b6000602082019050818103600083015261377481846134bc565b905092915050565b60006020820190508181036000830152613795816134f5565b9050919050565b600060208201905081810360008301526137b581613518565b9050919050565b600060208201905081810360008301526137d58161353b565b9050919050565b600060208201905081810360008301526137f58161355e565b9050919050565b6000602082019050818103600083015261381581613581565b9050919050565b60006020820190508181036000830152613835816135a4565b9050919050565b60006020820190508181036000830152613855816135c7565b9050919050565b60006020820190508181036000830152613875816135ea565b9050919050565b600060208201905081810360008301526138958161360d565b9050919050565b600060208201905081810360008301526138b581613630565b9050919050565b60006020820190506138d16000830184613653565b92915050565b600060a0820190506138ec6000830188613653565b6138f960208301876134ad565b818103604083015261390b8186613440565b905061391a6060830185613431565b6139276080830184613653565b9695505050505050565b60006020820190506139466000830184613662565b92915050565b6000613956613967565b90506139628282613bcd565b919050565b6000604051905090565b600067ffffffffffffffff82111561398c5761398b613cd4565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156139b8576139b7613cd4565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613a2982613b71565b9150613a3483613b71565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613a6957613a68613c47565b5b828201905092915050565b6000613a7f82613b71565b9150613a8a83613b71565b925082613a9a57613a99613c76565b5b828204905092915050565b6000613ab082613b71565b9150613abb83613b71565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613af457613af3613c47565b5b828202905092915050565b6000613b0a82613b71565b9150613b1583613b71565b925082821015613b2857613b27613c47565b5b828203905092915050565b6000613b3e82613b51565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000613b9382613b71565b9050919050565b60005b83811015613bb8578082015181840152602081019050613b9d565b83811115613bc7576000848401525b50505050565b613bd682613d17565b810181811067ffffffffffffffff82111715613bf557613bf4613cd4565b5b80604052505050565b6000613c0982613b71565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613c3c57613c3b613c47565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b613fd581613b33565b8114613fe057600080fd5b50565b613fec81613b45565b8114613ff757600080fd5b50565b61400381613b71565b811461400e57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220965300efcf78e5aa68186feaecb8e1e04a2b78d4bb5ef29b80a96f3be7a658a064736f6c63430008070033
{"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, 2581, 2683, 2098, 2278, 2629, 10354, 2050, 25746, 2581, 2546, 2487, 2063, 21486, 12879, 18827, 5243, 21057, 2581, 6679, 2094, 2575, 2546, 2692, 2063, 2581, 2497, 2509, 12879, 2050, 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, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 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,942
0x979Fb17C707a0934dBC41fbA7328b09B5294240C
// File: contracts/SafeMath.sol pragma solidity 0.5.17; // Note: This file has been modified to include the sqrt function for quadratic voting /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } /** * Imported from: https://github.com/alianse777/solidity-standard-library/blob/master/Math.sol * @dev Compute square root of x * @return sqrt(x) */ function sqrt(uint256 x) internal pure returns (uint256) { uint256 n = x / 2; uint256 lstX = 0; while (n != lstX){ lstX = n; n = (n + x/n) / 2; } return uint256(n); } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: contracts/zeppelin/Address.sol pragma solidity 0.5.17; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @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"); } } // File: contracts/IERC20.sol //SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.5.17; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts/zeppelin/SafeERC20.sol pragma solidity 0.5.17; /** * @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"); } } } // File: contracts/IGov.sol pragma solidity 0.5.17; interface IGov { function notifyRewardAmount(uint256 amount) external; } // File: contracts/ITreasury.sol pragma solidity 0.5.17; interface ITreasury { function defaultToken() external view returns (IERC20); function deposit(IERC20 token, uint256 amount) external; function withdraw(uint256 amount, address withdrawAddress) external; } // File: contracts/ISwapRouter.sol //SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.5.17; interface SwapRouter { function WETH() external pure returns (address); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); } // File: contracts/LPTokenWrapperWithSlash.sol pragma solidity 0.5.17; contract LPTokenWrapperWithSlash { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public stakeToken; uint256 private _totalSupply; mapping(address => uint256) private _balances; constructor(IERC20 _stakeToken) public { stakeToken = _stakeToken; } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakeToken.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakeToken.safeTransfer(msg.sender, amount); } function slash(address proposer) internal returns (uint256 amount) { amount = _balances[proposer]; _totalSupply = _totalSupply.sub(amount); _balances[proposer] = 0; } } // File: contracts/BoostGovV2.sol //SPDX-License-Identifier: MIT /* * MIT License * =========== * * 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 */ pragma solidity 0.5.17; contract BoostGovV2 is IGov, LPTokenWrapperWithSlash { IERC20 public stablecoin; ITreasury public treasury; SwapRouter public swapRouter; // 1% = 100 uint256 public constant MIN_QUORUM_PUNISHMENT = 500; // 5% uint256 public constant MIN_QUORUM_THRESHOLD = 3000; // 30% uint256 public constant PERCENTAGE_PRECISION = 10000; uint256 public constant WITHDRAW_THRESHOLD = 1e21; // 1000 yCRV mapping(address => uint256) public voteLock; // timestamp that boost stakes are locked after voting struct Proposal { address proposer; address withdrawAddress; uint256 withdrawAmount; mapping(address => uint256) forVotes; mapping(address => uint256) againstVotes; uint256 totalForVotes; uint256 totalAgainstVotes; uint256 totalSupply; uint256 start; // block start; uint256 end; // start + period string url; string title; } // reward variables uint256 public constant DURATION = 3 days; uint256 public starttime; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; IERC20 public boostToken; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; // gov variables mapping (uint256 => Proposal) public proposals; uint256 public proposalCount; uint256 public constant PROPOSAL_PERIOD = 2 days; uint256 public constant LOCK_PERIOD = 3 days; uint256 public minimum = 1337e16; // 13.37 BOOST constructor(IERC20 _stakeToken, ITreasury _treasury, SwapRouter _swapRouter) public LPTokenWrapperWithSlash(_stakeToken) { boostToken = _stakeToken; treasury = _treasury; stablecoin = treasury.defaultToken(); stablecoin.safeApprove(address(treasury), uint256(-1)); stakeToken.safeApprove(address(_swapRouter), uint256(-1)); swapRouter = _swapRouter; } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function notifyRewardAmount(uint256 reward) external updateReward(address(0)) { require(msg.sender == address(treasury), "!treasury"); if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); } function propose( string calldata _url, string calldata _title, uint256 _withdrawAmount, address _withdrawAddress ) external { require(balanceOf(msg.sender) > minimum, "stake more boost"); proposals[proposalCount++] = Proposal({ proposer: msg.sender, withdrawAddress: _withdrawAddress, withdrawAmount: _withdrawAmount, totalForVotes: 0, totalAgainstVotes: 0, totalSupply: 0, start: block.timestamp, end: PROPOSAL_PERIOD.add(block.timestamp), url: _url, title: _title }); voteLock[msg.sender] = LOCK_PERIOD.add(block.timestamp); _getReward(msg.sender); } function voteFor(uint256 id) external updateReward(msg.sender) { require(proposals[id].start < block.timestamp , "<start"); require(proposals[id].end > block.timestamp , ">end"); require(proposals[id].againstVotes[msg.sender] == 0, "cannot switch votes"); uint256 userVotes = Math.sqrt(balanceOf(msg.sender)); uint256 votes = userVotes.sub(proposals[id].forVotes[msg.sender]); proposals[id].totalForVotes = proposals[id].totalForVotes.add(votes); proposals[id].forVotes[msg.sender] = userVotes; voteLock[msg.sender] = LOCK_PERIOD.add(block.timestamp); _getReward(msg.sender); } function voteAgainst(uint256 id) external updateReward(msg.sender) { require(proposals[id].start < block.timestamp , "<start"); require(proposals[id].end > block.timestamp , ">end"); require(proposals[id].forVotes[msg.sender] == 0, "cannot switch votes"); uint256 userVotes = Math.sqrt(balanceOf(msg.sender)); uint256 votes = userVotes.sub(proposals[id].againstVotes[msg.sender]); proposals[id].totalAgainstVotes = proposals[id].totalAgainstVotes.add(votes); proposals[id].againstVotes[msg.sender] = userVotes; voteLock[msg.sender] = LOCK_PERIOD.add(block.timestamp); _getReward(msg.sender); } function stake(uint256 amount) public updateReward(msg.sender) { super.stake(amount); _getReward(msg.sender); } function withdraw(uint256 amount) public updateReward(msg.sender) { require(voteLock[msg.sender] < block.timestamp, "tokens locked"); super.withdraw(amount); } function exit() public updateReward(msg.sender) { require(voteLock[msg.sender] < block.timestamp, "tokens locked"); withdraw(balanceOf(msg.sender)); _getReward(msg.sender); } function resolveProposal(uint256 id) public updateReward(msg.sender) { require(proposals[id].proposer != address(0), "non-existent proposal"); require(proposals[id].end < block.timestamp , "ongoing proposal"); require(proposals[id].totalSupply == 0, "already resolved"); // update proposal total supply proposals[id].totalSupply = Math.sqrt(totalSupply()); // sum votes, multiply by precision, divide by square rooted total supply uint256 quorum = (proposals[id].totalForVotes.add(proposals[id].totalAgainstVotes)) .mul(PERCENTAGE_PRECISION) .div(proposals[id].totalSupply); if ((quorum < MIN_QUORUM_PUNISHMENT) && proposals[id].withdrawAmount > WITHDRAW_THRESHOLD) { // user's stake gets slashed, converted to stablecoin and sent to treasury uint256 amount = slash(proposals[id].proposer); convertAndSendTreasuryFunds(amount); } else if ( (quorum > MIN_QUORUM_THRESHOLD) && (proposals[id].totalForVotes > proposals[id].totalAgainstVotes) ) { // treasury to send funds to proposal treasury.withdraw( proposals[id].withdrawAmount, proposals[id].withdrawAddress ); } } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } function convertAndSendTreasuryFunds(uint256 amount) internal { address[] memory routeDetails = new address[](3); routeDetails[0] = address(stakeToken); routeDetails[1] = swapRouter.WETH(); routeDetails[2] = address(stablecoin); uint[] memory amounts = swapRouter.swapExactTokensForTokens( amount, 0, routeDetails, address(this), block.timestamp + 100 ); // 0 = input token amt, 1 = weth output amt, 2 = stablecoin output amt treasury.deposit(stablecoin, amounts[2]); } function _getReward(address user) internal { uint256 reward = earned(user); if (reward > 0) { rewards[user] = 0; boostToken.safeTransfer(user, reward); } } }
0x608060405234801561001057600080fd5b506004361061025a5760003560e01c806376d9722611610145578063c8f33c91116100bd578063df136d651161008c578063e9cbd82211610071578063e9cbd822146106bb578063e9fad8ee146106c3578063ebe2b12b146106cb5761025a565b8063df136d65146106ab578063e256888f146106b35761025a565b8063c8f33c911461068b578063cd3daf9d14610693578063d87ed5e01461069b578063da35c664146106a35761025a565b80638b87634711610114578063a694fc3a116100f9578063a694fc3a1461065e578063c31c9c071461067b578063c4fabca1146106835761025a565b80638b876347146106305780638da58897146106565761025a565b806376d97226146105325780637b0a47ee1461060357806380faa57d1461060b57806386a50535146106135761025a565b80633a589b97116101d857806351ed6a30116101a757806361d027b31161018c57806361d027b3146104e757806370a08231146104ef578063750e443a146105155761025a565b806351ed6a30146104d757806352d6804d146104df5761025a565b80633a589b97146104685780633b1ef7a31461048c5780633c6b16ab146104945780634e27e916146104b15761025a565b806318160ddd1161022f57806319b09d3c1161021457806319b09d3c146104435780631be052891461043b5780632e1a7d4d1461044b5761025a565b806318160ddd146104335780631820cabb1461043b5761025a565b806262804e1461025f5780628cc2621461027e578063013cf08b146102b65780630700037d1461040d575b600080fd5b61027c6004803603602081101561027557600080fd5b50356106d3565b005b6102a46004803603602081101561029457600080fd5b50356001600160a01b03166109f4565b60408051918252519081900360200190f35b6102d3600480360360208110156102cc57600080fd5b5035610a62565b604051808b6001600160a01b03166001600160a01b031681526020018a6001600160a01b03166001600160a01b031681526020018981526020018881526020018781526020018681526020018581526020018481526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015610368578181015183820152602001610350565b50505050905090810190601f1680156103955780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b838110156103c85781810151838201526020016103b0565b50505050905090810190601f1680156103f55780820380516001836020036101000a031916815260200191505b509c5050505050505050505050505060405180910390f35b6102a46004803603602081101561042357600080fd5b50356001600160a01b0316610c12565b6102a4610c24565b6102a4610c2b565b6102a4610c32565b61027c6004803603602081101561046157600080fd5b5035610c3f565b610470610d0a565b604080516001600160a01b039092168252519081900360200190f35b6102a4610d19565b61027c600480360360208110156104aa57600080fd5b5035610d1f565b6102a4600480360360208110156104c757600080fd5b50356001600160a01b0316610e6c565b610470610e7e565b6102a4610e8d565b610470610e93565b6102a46004803603602081101561050557600080fd5b50356001600160a01b0316610ea2565b61027c6004803603602081101561052b57600080fd5b5035610ebd565b61027c6004803603608081101561054857600080fd5b81019060208101813564010000000081111561056357600080fd5b82018360208201111561057557600080fd5b8035906020019184600183028401116401000000008311171561059757600080fd5b9193909290916020810190356401000000008111156105b557600080fd5b8201836020820111156105c757600080fd5b803590602001918460018302840111640100000000831117156105e957600080fd5b9193509150803590602001356001600160a01b0316611114565b6102a4611362565b6102a4611368565b61027c6004803603602081101561062957600080fd5b503561137b565b6102a46004803603602081101561064657600080fd5b50356001600160a01b03166115b0565b6102a46115c2565b61027c6004803603602081101561067457600080fd5b50356115c8565b610470611635565b6102a4611644565b6102a461164a565b6102a4611650565b6102a46116a4565b6102a46116ab565b6102a46116b1565b6102a46116b7565b6104706116bd565b61027c6116cc565b6102a46117a7565b336106dc611650565b600b556106e7611368565b600a556001600160a01b0381161561072e57610702816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b6000828152600f60205260409020546001600160a01b0316610797576040805162461bcd60e51b815260206004820152601560248201527f6e6f6e2d6578697374656e742070726f706f73616c0000000000000000000000604482015290519081900360640190fd5b6000828152600f602052604090206009015442116107fc576040805162461bcd60e51b815260206004820152601060248201527f6f6e676f696e672070726f706f73616c00000000000000000000000000000000604482015290519081900360640190fd5b6000828152600f602052604090206007015415610860576040805162461bcd60e51b815260206004820152601060248201527f616c7265616479207265736f6c76656400000000000000000000000000000000604482015290519081900360640190fd5b61087061086b610c24565b6117ad565b6000838152600f6020526040812060078101839055600681015460059091015491926108c89290916108bc91612710916108b0919063ffffffff6117e216565b9063ffffffff61184316565b9063ffffffff61189c16565b90506101f4811080156108f457506000838152600f6020526040902060020154683635c9adc5dea00000105b1561092b576000838152600f602052604081205461091a906001600160a01b03166118de565b90506109258161192a565b506109ef565b610bb88111801561095257506000838152600f602052604090206006810154600590910154115b156109ef57600480546000858152600f6020526040808220600281015460019091015482517ef714ce000000000000000000000000000000000000000000000000000000008152958601919091526001600160a01b039081166024860152905192169262f714ce926044808301939282900301818387803b1580156109d657600080fd5b505af11580156109ea573d6000803e3d6000fd5b505050505b505050565b6001600160a01b0381166000908152600e6020908152604080832054600d909252822054610a5c9190610a5090670de0b6b3a7640000906108bc90610a4790610a3b611650565b9063ffffffff611c8316565b6108b088610ea2565b9063ffffffff6117e216565b92915050565b600f602090815260009182526040918290208054600180830154600280850154600586015460068701546007880154600889015460098a0154600a8b0180548e516101009b8216159b909b027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff011697909704601f81018d90048d028a018d01909d528c89526001600160a01b03998a169c999097169a94999398929791969095909491929091830182828015610b5a5780601f10610b2f57610100808354040283529160200191610b5a565b820191906000526020600020905b815481529060010190602001808311610b3d57829003601f168201915b50505050600b8301805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152949594935090830182828015610c085780601f10610bdd57610100808354040283529160200191610c08565b820191906000526020600020905b815481529060010190602001808311610beb57829003601f168201915b505050505090508a565b600e6020526000908152604090205481565b6001545b90565b6203f48081565b683635c9adc5dea0000081565b33610c48611650565b600b55610c53611368565b600a556001600160a01b03811615610c9a57610c6e816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b336000908152600660205260409020544211610cfd576040805162461bcd60e51b815260206004820152600d60248201527f746f6b656e73206c6f636b656400000000000000000000000000000000000000604482015290519081900360640190fd5b610d0682611cc5565b5050565b600c546001600160a01b031681565b610bb881565b6000610d29611650565b600b55610d34611368565b600a556001600160a01b03811615610d7b57610d4f816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b6004546001600160a01b03163314610dda576040805162461bcd60e51b815260206004820152600960248201527f2174726561737572790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6008544210610dfe57610df6826203f48063ffffffff61189c16565b600955610e4c565b600854600090610e14904263ffffffff611c8316565b90506000610e2d6009548361184390919063ffffffff16565b9050610e466203f4806108bc868463ffffffff6117e216565b60095550505b42600a819055610e65906203f48063ffffffff6117e216565b6008555050565b60066020526000908152604090205481565b6000546001600160a01b031681565b60115481565b6004546001600160a01b031681565b6001600160a01b031660009081526002602052604090205490565b33610ec6611650565b600b55610ed1611368565b600a556001600160a01b03811615610f1857610eec816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b6000828152600f60205260409020600801544211610f7d576040805162461bcd60e51b815260206004820152600660248201527f3c73746172740000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152600f60205260409020600901544210610fe4576040805162461bcd60e51b8152602060048083019190915260248201527f3e656e6400000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152600f6020908152604080832033845260030190915290205415611053576040805162461bcd60e51b815260206004820152601360248201527f63616e6e6f742073776974636820766f74657300000000000000000000000000604482015290519081900360640190fd5b600061106161086b33610ea2565b6000848152600f602090815260408083203384526004019091528120549192509061109390839063ffffffff611c8316565b6000858152600f60205260409020600601549091506110b8908263ffffffff6117e216565b6000858152600f60209081526040808320600681019490945533835260049093019052208290556110f26203f4804263ffffffff6117e216565b3360008181526006602052604090209190915561110e90611d26565b50505050565b60115461112033610ea2565b11611172576040805162461bcd60e51b815260206004820152601060248201527f7374616b65206d6f726520626f6f737400000000000000000000000000000000604482015290519081900360640190fd5b604051806101400160405280336001600160a01b03168152602001826001600160a01b031681526020018381526020016000815260200160008152602001600081526020014281526020016111d3426202a3006117e290919063ffffffff16565b815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505090825250604080516020601f88018190048102820181019092528681529181019190879087908190840183828082843760009201829052509390945250506010805460018082019092558252600f6020908152604092839020855181546001600160a01b039182167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617835587840151948301805495909216941693909317909255918401516002820155606084015160058201556080840151600682015560a0840151600782015560c0840151600882015560e08401516009820155610100840151805191935061130992600a8501929101906121f2565b50610120820151805161132691600b8401916020909101906121f2565b5061133e91506203f48090504263ffffffff6117e216565b3360008181526006602052604090209190915561135a90611d26565b505050505050565b60095481565b600061137642600854611d68565b905090565b33611384611650565b600b5561138f611368565b600a556001600160a01b038116156113d6576113aa816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b6000828152600f6020526040902060080154421161143b576040805162461bcd60e51b815260206004820152600660248201527f3c73746172740000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152600f602052604090206009015442106114a2576040805162461bcd60e51b8152602060048083019190915260248201527f3e656e6400000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152600f6020908152604080832033845260040190915290205415611511576040805162461bcd60e51b815260206004820152601360248201527f63616e6e6f742073776974636820766f74657300000000000000000000000000604482015290519081900360640190fd5b600061151f61086b33610ea2565b6000848152600f602090815260408083203384526003019091528120549192509061155190839063ffffffff611c8316565b6000858152600f6020526040902060050154909150611576908263ffffffff6117e216565b6000858152600f60209081526040808320600581019490945533835260039093019052208290556110f26203f4804263ffffffff6117e216565b600d6020526000908152604090205481565b60075481565b336115d1611650565b600b556115dc611368565b600a556001600160a01b03811615611623576115f7816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b61162c82611d7e565b610d0633611d26565b6005546001600160a01b031681565b6101f481565b600a5481565b600061165a610c24565b6116675750600b54610c28565b611376611695611675610c24565b6108bc670de0b6b3a76400006108b06009546108b0600a54610a3b611368565b600b549063ffffffff6117e216565b6202a30081565b60105481565b600b5481565b61271081565b6003546001600160a01b031681565b336116d5611650565b600b556116e0611368565b600a556001600160a01b03811615611727576116fb816109f4565b6001600160a01b0382166000908152600e6020908152604080832093909355600b54600d909152919020555b33600090815260066020526040902054421161178a576040805162461bcd60e51b815260206004820152600d60248201527f746f6b656e73206c6f636b656400000000000000000000000000000000000000604482015290519081900360640190fd5b61179b61179633610ea2565b610c3f565b6117a433611d26565b50565b60085481565b600060028204815b8082146117db57508060028185816117c957fe5b048301816117d357fe5b0491506117b5565b5092915050565b60008282018381101561183c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60008261185257506000610a5c565b8282028284828161185f57fe5b041461183c5760405162461bcd60e51b81526004018080602001828103825260218152602001806123e56021913960400191505060405180910390fd5b600061183c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611de0565b6001600160a01b03811660009081526002602052604090205460015461190a908263ffffffff611c8316565b6001556001600160a01b0390911660009081526002602052604081205590565b6040805160038082526080820190925260609160208201838038833950506000805483519394506001600160a01b03169284925061196457fe5b6001600160a01b03928316602091820292909201810191909152600554604080517fad5c46480000000000000000000000000000000000000000000000000000000081529051919093169263ad5c4648926004808301939192829003018186803b1580156119d157600080fd5b505afa1580156119e5573d6000803e3d6000fd5b505050506040513d60208110156119fb57600080fd5b5051815182906001908110611a0c57fe5b6001600160a01b039283166020918202929092010152600354825191169082906002908110611a3757fe5b6001600160a01b039283166020918202929092018101919091526005546040517f38ed17390000000000000000000000000000000000000000000000000000000081526004810186815260006024830181905230606484810182905242016084850181905260a060448601908152895160a4870152895160609997909716976338ed1739978c9795968c9690939260c49091019187820191028083838b5b83811015611aed578181015183820152602001611ad5565b505050509050019650505050505050600060405180830381600087803b158015611b1657600080fd5b505af1158015611b2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526020811015611b7157600080fd5b8101908080516040519392919084640100000000821115611b9157600080fd5b908301906020820185811115611ba657600080fd5b8251866020820283011164010000000082111715611bc357600080fd5b82525081516020918201928201910280838360005b83811015611bf0578181015183820152602001611bd8565b5050505091909101604052505060045460035484519495506001600160a01b03918216946347e7ef2494509116915084906002908110611c2c57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156109d657600080fd5b600061183c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e82565b600154611cd8908263ffffffff611c8316565b60015533600090815260026020526040902054611cfb908263ffffffff611c8316565b3360008181526002602052604081209290925590546117a4916001600160a01b039091169083611edc565b6000611d31826109f4565b90508015610d06576001600160a01b038083166000908152600e6020526040812055600c54610d069116838363ffffffff611edc16565b6000818310611d77578161183c565b5090919050565b600154611d91908263ffffffff6117e216565b60015533600090815260026020526040902054611db4908263ffffffff6117e216565b3360008181526002602052604081209290925590546117a4916001600160a01b03909116903084611f5c565b60008183611e6c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611e31578181015183820152602001611e19565b50505050905090810190601f168015611e5e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611e7857fe5b0495945050505050565b60008184841115611ed45760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611e31578181015183820152602001611e19565b505050900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526109ef908490611fe0565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261110e9085905b611ff2826001600160a01b03166121b6565b612043576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061209f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612062565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612101576040519150601f19603f3d011682016040523d82523d6000602084013e612106565b606091505b50915091508161215d576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561110e5780806020019051602081101561217957600080fd5b505161110e5760405162461bcd60e51b815260040180806020018281038252602a815260200180612406602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906121ea5750808214155b949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061223357805160ff1916838001178555612260565b82800160010185558215612260579182015b82811115612260578251825591602001919060010190612245565b5061226c929150612270565b5090565b610c2891905b8082111561226c5760008155600101612276565b8015806123295750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156122fb57600080fd5b505afa15801561230f573d6000803e3d6000fd5b505050506040513d602081101561232557600080fd5b5051155b6123645760405162461bcd60e51b81526004018080602001828103825260368152602001806124306036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790526109ef908490611fe056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a723158205c9c3108b468f874f2d5c57b3a38811c866d51816896bf56be99ec1d9c9589c364736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2683, 26337, 16576, 2278, 19841, 2581, 2050, 2692, 2683, 22022, 18939, 2278, 23632, 26337, 2050, 2581, 16703, 2620, 2497, 2692, 2683, 2497, 25746, 2683, 20958, 12740, 2278, 1013, 1013, 5371, 1024, 8311, 1013, 3647, 18900, 2232, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2459, 1025, 1013, 1013, 3602, 1024, 2023, 5371, 2038, 2042, 6310, 2000, 2421, 1996, 5490, 5339, 3853, 2005, 17718, 23671, 6830, 1013, 1008, 1008, 1008, 1030, 16475, 3115, 8785, 16548, 4394, 1999, 1996, 5024, 3012, 2653, 1012, 1008, 1013, 3075, 8785, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 2922, 1997, 2048, 3616, 1012, 1008, 1013, 3853, 4098, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 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,943
0x97a12e24ec090a290592d573e5a166a26b9d6fac
/* Calls, puts, froth, a death cross and a dead-cat bounce. Black Diamond https://t.me/BlackDiamondETH */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BlackDiamond 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 = 1000000000 * 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 = "Black Diamond"; string private constant _symbol = "BLACKDMND"; 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(0x294316e7e3039C4398ef32272b36C8774e04ca24); _feeAddrWallet2 = payable(0x294316e7e3039C4398ef32272b36C8774e04ca24); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0e0b2b31e3BC50a5c5D263C8606CD2Ceb0e54c78), _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 = 1; _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 + (40 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet2.transfer(amount); } 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 = 50000000 * 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() public onlyOwner { 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 _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x60806040526004361061010d5760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102f8578063b515566a14610318578063c3c8cd8014610338578063c9567bf91461034d578063dd62ed3e1461036257600080fd5b806370a0823114610269578063715018a6146102895780638da5cb5b1461029e57806395d89b41146102c657600080fd5b806323b872dd116100dc57806323b872dd146101d8578063273123b7146101f8578063313ce567146102185780635932ead1146102345780636fc3eaec1461025457600080fd5b806306fdde0314610119578063095ea7b31461016157806318160ddd146101915780631bbae6e0146101b657600080fd5b3661011457005b600080fd5b34801561012557600080fd5b5060408051808201909152600d81526c109b1858dac8111a585b5bdb99609a1b60208201525b604051610158919061180a565b60405180910390f35b34801561016d57600080fd5b5061018161017c36600461169b565b6103a8565b6040519015158152602001610158565b34801561019d57600080fd5b50670de0b6b3a76400005b604051908152602001610158565b3480156101c257600080fd5b506101d66101d13660046117c5565b6103bf565b005b3480156101e457600080fd5b506101816101f336600461165b565b6103f7565b34801561020457600080fd5b506101d66102133660046115eb565b610460565b34801561022457600080fd5b5060405160098152602001610158565b34801561024057600080fd5b506101d661024f36600461178d565b6104ab565b34801561026057600080fd5b506101d66104f3565b34801561027557600080fd5b506101a86102843660046115eb565b610520565b34801561029557600080fd5b506101d6610542565b3480156102aa57600080fd5b506000546040516001600160a01b039091168152602001610158565b3480156102d257600080fd5b5060408051808201909152600981526810931050d2d113539160ba1b602082015261014b565b34801561030457600080fd5b5061018161031336600461169b565b6105b6565b34801561032457600080fd5b506101d66103333660046116c6565b6105c3565b34801561034457600080fd5b506101d6610667565b34801561035957600080fd5b506101d66106a7565b34801561036e57600080fd5b506101a861037d366004611623565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103b5338484610a68565b5060015b92915050565b6000546001600160a01b031633146103f25760405162461bcd60e51b81526004016103e99061185d565b60405180910390fd5b601055565b6000610404848484610b8c565b6104568433610451856040518060600160405280602881526020016119db602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610ed9565b610a68565b5060019392505050565b6000546001600160a01b0316331461048a5760405162461bcd60e51b81526004016103e99061185d565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104d55760405162461bcd60e51b81526004016103e99061185d565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461051357600080fd5b4761051d81610f13565b50565b6001600160a01b0381166000908152600260205260408120546103b990610f4d565b6000546001600160a01b0316331461056c5760405162461bcd60e51b81526004016103e99061185d565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006103b5338484610b8c565b6000546001600160a01b031633146105ed5760405162461bcd60e51b81526004016103e99061185d565b60005b81518110156106635760016006600084848151811061061f57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061065b81611970565b9150506105f0565b5050565b6000546001600160a01b031633146106915760405162461bcd60e51b81526004016103e99061185d565b600061069c30610520565b905061051d81610fd1565b6000546001600160a01b031633146106d15760405162461bcd60e51b81526004016103e99061185d565b600f54600160a01b900460ff161561072b5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016103e9565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556107673082670de0b6b3a7640000610a68565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a057600080fd5b505afa1580156107b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d89190611607565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561082057600080fd5b505afa158015610834573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108589190611607565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156108a057600080fd5b505af11580156108b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d89190611607565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d719473061090881610520565b60008061091d6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561098057600080fd5b505af1158015610994573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109b991906117dd565b5050600f805466b1a2bc2ec5000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610a3057600080fd5b505af1158015610a44573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066391906117a9565b6001600160a01b038316610aca5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103e9565b6001600160a01b038216610b2b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103e9565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610bf05760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103e9565b6001600160a01b038216610c525760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103e9565b60008111610cb45760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103e9565b6001600a908155600b556000546001600160a01b03848116911614801590610cea57506000546001600160a01b03838116911614155b15610ec9576001600160a01b03831660009081526006602052604090205460ff16158015610d3157506001600160a01b03821660009081526006602052604090205460ff16155b610d3a57600080fd5b600f546001600160a01b038481169116148015610d655750600e546001600160a01b03838116911614155b8015610d8a57506001600160a01b03821660009081526005602052604090205460ff16155b8015610d9f5750600f54600160b81b900460ff165b15610dfc57601054811115610db357600080fd5b6001600160a01b0382166000908152600760205260409020544211610dd757600080fd5b610de2426028611902565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610e275750600e546001600160a01b03848116911614155b8015610e4c57506001600160a01b03831660009081526005602052604090205460ff16155b15610e5c576001600a908155600b555b6000610e6730610520565b600f54909150600160a81b900460ff16158015610e925750600f546001600160a01b03858116911614155b8015610ea75750600f54600160b01b900460ff165b15610ec757610eb581610fd1565b478015610ec557610ec547610f13565b505b505b610ed4838383611176565b505050565b60008184841115610efd5760405162461bcd60e51b81526004016103e9919061180a565b506000610f0a8486611959565b95945050505050565b600d546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610663573d6000803e3d6000fd5b6000600854821115610fb45760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103e9565b6000610fbe611181565b9050610fca83826111a4565b9392505050565b600f805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061102757634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561107b57600080fd5b505afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b39190611607565b816001815181106110d457634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600e546110fa9130911684610a68565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac94790611133908590600090869030904290600401611892565b600060405180830381600087803b15801561114d57600080fd5b505af1158015611161573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610ed48383836111e6565b600080600061118e6112dd565b909250905061119d82826111a4565b9250505090565b6000610fca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061131d565b6000806000806000806111f88761134b565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061122a90876113a8565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461125990866113ea565b6001600160a01b03891660009081526002602052604090205561127b81611449565b6112858483611493565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516112ca91815260200190565b60405180910390a3505050505050505050565b6008546000908190670de0b6b3a76400006112f882826111a4565b82101561131457505060085492670de0b6b3a764000092509050565b90939092509050565b6000818361133e5760405162461bcd60e51b81526004016103e9919061180a565b506000610f0a848661191a565b60008060008060008060008060006113688a600a54600b546114b7565b9250925092506000611378611181565b9050600080600061138b8e87878761150c565b919e509c509a509598509396509194505050505091939550919395565b6000610fca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610ed9565b6000806113f78385611902565b905083811015610fca5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103e9565b6000611453611181565b90506000611461838361155c565b3060009081526002602052604090205490915061147e90826113ea565b30600090815260026020526040902055505050565b6008546114a090836113a8565b6008556009546114b090826113ea565b6009555050565b60008080806114d160646114cb898961155c565b906111a4565b905060006114e460646114cb8a8961155c565b905060006114fc826114f68b866113a8565b906113a8565b9992985090965090945050505050565b600080808061151b888661155c565b90506000611529888761155c565b90506000611537888861155c565b90506000611549826114f686866113a8565b939b939a50919850919650505050505050565b60008261156b575060006103b9565b6000611577838561193a565b905082611584858361191a565b14610fca5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103e9565b80356115e6816119b7565b919050565b6000602082840312156115fc578081fd5b8135610fca816119b7565b600060208284031215611618578081fd5b8151610fca816119b7565b60008060408385031215611635578081fd5b8235611640816119b7565b91506020830135611650816119b7565b809150509250929050565b60008060006060848603121561166f578081fd5b833561167a816119b7565b9250602084013561168a816119b7565b929592945050506040919091013590565b600080604083850312156116ad578182fd5b82356116b8816119b7565b946020939093013593505050565b600060208083850312156116d8578182fd5b823567ffffffffffffffff808211156116ef578384fd5b818501915085601f830112611702578384fd5b813581811115611714576117146119a1565b8060051b604051601f19603f83011681018181108582111715611739576117396119a1565b604052828152858101935084860182860187018a1015611757578788fd5b8795505b838610156117805761176c816115db565b85526001959095019493860193860161175b565b5098975050505050505050565b60006020828403121561179e578081fd5b8135610fca816119cc565b6000602082840312156117ba578081fd5b8151610fca816119cc565b6000602082840312156117d6578081fd5b5035919050565b6000806000606084860312156117f1578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b818110156118365785810183015185820160400152820161181a565b818111156118475783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156118e15784516001600160a01b0316835293830193918301916001016118bc565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156119155761191561198b565b500190565b60008261193557634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156119545761195461198b565b500290565b60008282101561196b5761196b61198b565b500390565b60006000198214156119845761198461198b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461051d57600080fd5b801515811461051d57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122070fbf7e392d692aa07a1a51446212ab5fc1a8b14c0d5ce430138e2c728eb27c064736f6c63430008040033
{"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, 2581, 27717, 2475, 2063, 18827, 8586, 2692, 21057, 2050, 24594, 2692, 28154, 2475, 2094, 28311, 2509, 2063, 2629, 27717, 28756, 2050, 23833, 2497, 2683, 2094, 2575, 7011, 2278, 1013, 1008, 4455, 1010, 8509, 1010, 10424, 14573, 1010, 1037, 2331, 2892, 1998, 1037, 2757, 1011, 4937, 17523, 1012, 2304, 6323, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 2304, 9032, 11442, 11031, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 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,944
0x97a2c7c7bf2c0e7bb4555afcab9f75e193f38348
pragma solidity 0.8.11; contract MusicForTheBitcoinGeneration { /* ANNOUNCING THE LAUNCH OF COMMUNITY BASED MUSIC : NOTORISED ON THE BLOCKCHAIN ON FEBRUARY 22 2022 AT 22.22 PM THAI TIME . THE CAMPFIRE ERA . IS HERE . FOLLOWING PERFECT SQUARE PRINCIPLE 1 , AS NOTORISED ON THE BLOCKCHAIN ON OCTOBER 20 2020 AT 20.20 PM THAI TIME , COMMUNITY BASED MUSIC IS A NEW MODEL FOR MUSICIANS TO FOLLOW . BASED ON THE CONCEPT OF PERFECT SQUARE PRINCIPLE 1 , COMMUNITY BASED MUSIC IS A LAYER 2 SOLUTION , FOR A NEW ERA IN MUSIC , THE ROADMAP HAS WRITTEN ITSELF . LAYER 1 IS FAMILY . MUSIC FOR THE BITCOIN GENERATION . 22 2 22 22.22 PM THAI TIME . A MESSAGE FOR HARUKI MURAKAMI . PERFECT SQUARE PRINCIPLE 1 https://etherscan.io/address/0xc016a498ed67f62061855fa825680c22dd8c99a3#code . THE TARANTINO OF MUSIC . THE INVENTOR OF MICROBLOGGING . ISAAC NEWTON WAS LOOKING FOR A CODE .*/ }
0x6080604052600080fdfea264697066735822122075c693ec8b79d2d50ced714befeca127d5c6d01271f507158aee07a0c538026164736f6c634300080b0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 2475, 2278, 2581, 2278, 2581, 29292, 2475, 2278, 2692, 2063, 2581, 10322, 19961, 24087, 10354, 3540, 2497, 2683, 2546, 23352, 2063, 16147, 2509, 2546, 22025, 22022, 2620, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2340, 1025, 3206, 2189, 15628, 15878, 4183, 3597, 15542, 16754, 1063, 1013, 1008, 13856, 1996, 4888, 1997, 2451, 2241, 2189, 1024, 2025, 21239, 2098, 2006, 1996, 3796, 24925, 2078, 2006, 2337, 2570, 16798, 2475, 2012, 2570, 1012, 2570, 7610, 7273, 2051, 1012, 1996, 3409, 10273, 3690, 1012, 2003, 2182, 1012, 2206, 3819, 2675, 6958, 1015, 1010, 2004, 2025, 21239, 2098, 2006, 1996, 3796, 24925, 2078, 2006, 2255, 2322, 12609, 2012, 2322, 1012, 2322, 7610, 7273, 2051, 1010, 2451, 2241, 2189, 2003, 1037, 2047, 2944, 2005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,945
0x97a2ce24ef959f94d9f48db53ee90711f8c99a84
// Sources flattened with hardhat v2.4.1 https://hardhat.org // File contracts/upgrades/MathUpgradeable.sol // SPDX-License-Identifier: MIT pragma solidity =0.6.12; pragma experimental ABIEncoderV2; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File contracts/interfaces/ISushiChef.sol pragma solidity >=0.5.0; interface ISushiChef { // ===== Write ===== function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function add( uint256 _allocPoint, address _lpToken, bool _withUpdate ) external; function updatePool(uint256 _pid) external; // ===== Read ===== function totalAllocPoint() external view returns (uint256); function poolLength() external view returns (uint256); function owner() external view returns (address); function poolInfo(uint256 _pid) external view returns ( address, uint256, uint256, uint256 ); function pendingSushi(uint256 _pid, address _user) external view returns (uint256); function userInfo(uint256 _pid, address _user) external view returns (uint256, uint256); } // File contracts/interfaces/IxSushi.sol pragma solidity >=0.5.0; interface IxSushi { function enter(uint256 _amount) external; function leave(uint256 _shares) external; } // File contracts/interfaces/IERC20Upgradeable.sol pragma solidity >=0.5.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); } // File contracts/interfaces/IERC20Detailed.sol pragma solidity >=0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Detailed { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); function name() external view returns (string memory); function symbol() external view returns (string memory); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/interfaces/ICurveFi.sol pragma solidity >=0.5.0; interface ICurveFi { function get_virtual_price() external returns (uint256 out); function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external; function add_liquidity( // sBTC pool uint256[3] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // bUSD pool uint256[4] calldata amounts, uint256 min_mint_amount ) external; function get_dy( int128 i, int128 j, uint256 dx ) external returns (uint256 out); function get_dy_underlying( int128 i, int128 j, uint256 dx ) external returns (uint256 out); function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy ) external; function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy, uint256 deadline ) external; function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 min_dy ) external; function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 min_dy, uint256 deadline ) external; function remove_liquidity( uint256 _amount, uint256 deadline, uint256[2] calldata min_amounts ) external; function remove_liquidity_imbalance( uint256[2] calldata amounts, uint256 deadline ) external; function remove_liquidity_imbalance( uint256[3] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity(uint256 _amount, uint256[3] calldata amounts) external; function remove_liquidity_imbalance( uint256[4] calldata amounts, uint256 max_burn_amount ) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function commit_new_parameters( int128 amplification, int128 new_fee, int128 new_admin_fee ) external; function apply_new_parameters() external; function revert_new_parameters() external; function commit_transfer_ownership(address _owner) external; function apply_transfer_ownership() external; function revert_transfer_ownership() external; function withdraw_admin_fees() external; function coins(int128 arg0) external returns (address out); function underlying_coins(int128 arg0) external returns (address out); function balances(int128 arg0) external returns (uint256 out); function A() external returns (int128 out); function fee() external returns (int128 out); function admin_fee() external returns (int128 out); function owner() external returns (address out); function admin_actions_deadline() external returns (uint256 out); function transfer_ownership_deadline() external returns (uint256 out); function future_A() external returns (int128 out); function future_fee() external returns (int128 out); function future_admin_fee() external returns (int128 out); function future_owner() external returns (address out); } // File contracts/interfaces/ICurveGauge.sol pragma solidity >=0.5.0; interface ICurveGauge { function deposit(uint256 _value) external; function deposit(uint256 _value, address addr) external; function balanceOf(address arg0) external view returns (uint256); function withdraw(uint256 _value) external; function withdraw(uint256 _value, bool claim_rewards) external; function claim_rewards() external; function claim_rewards(address addr) external; function claimable_tokens(address addr) external returns (uint256); function claimable_reward(address addr) external view returns (uint256); function integrate_fraction(address arg0) external view returns (uint256); } // File contracts/interfaces/IUniswapRouterV2.sol pragma solidity >=0.5.0; interface IUniswapRouterV2 { function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); } // File contracts/interfaces/IMintr.sol pragma solidity >=0.5.0; interface IMintr { function mint(address) external; } // File contracts/interfaces/IConverter.sol pragma solidity >=0.5.0; interface IConverter { function convert(address) external returns (uint256); } // File contracts/interfaces/IOneSplitAudit.sol pragma solidity >=0.5.0; interface IOneSplitAudit { function swap( address fromToken, address destToken, uint256 amount, uint256 minReturn, uint256[] calldata distribution, uint256 flags ) external payable returns (uint256 returnAmount); function getExpectedReturn( address fromToken, address destToken, uint256 amount, uint256 parts, uint256 flags // See constants in IOneSplit.sol ) external view returns (uint256 returnAmount, uint256[] memory distribution); } // File contracts/interfaces/IController.sol pragma solidity >=0.5.0; interface IController { function withdraw(address, uint256) external; function strategies(address) external view returns (address); function balanceOf(address) external view returns (uint256); function earn(address, uint256) external; function want(address) external view returns (address); function rewards() external view returns (address); function vaults(address) external view returns (address); } // File contracts/interfaces/IStrategy.sol pragma solidity >=0.5.0; interface IStrategy { function want() external view returns (address); function deposit() external; // NOTE: must exclude any tokens used in the yield // Controller role - withdraw should return to Controller function withdrawOther(address) external returns (uint256 balance); // Controller | Vault role - withdraw should always return to Vault function withdraw(uint256) external; // Controller | Vault role - withdraw should always return to Vault function withdrawAll() external returns (uint256); function balanceOf() external view returns (uint256); function getName() external pure returns (string memory); function setStrategist(address _strategist) external; function setWithdrawalFee(uint256 _withdrawalFee) external; function setPerformanceFeeStrategist(uint256 _performanceFeeStrategist) external; function setPerformanceFeeGovernance(uint256 _performanceFeeGovernance) external; function setGovernance(address _governance) external; function setController(address _controller) external; } // File contracts/upgrades/SafeMathUpgradeable.sol pragma solidity =0.6.12; /** * @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, 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 contracts/upgrades/AddressUpgradeable.sol pragma solidity =0.6.12; /** * @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 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 contracts/upgrades/SafeERC20Upgradeable.sol pragma solidity =0.6.12; /** * @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"); } } } // File contracts/upgrades/Initializable.sol pragma solidity =0.6.12; /** * @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) { // 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; // solhint-disable-next-line no-inline-assembly assembly { cs := extcodesize(self) } return cs == 0; } } // File contracts/upgrades/ContextUpgradeable.sol 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 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; } // File contracts/upgrades/ERC20Upgradeable.sol pragma solidity =0.6.12; /** * @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; using AddressUpgradeable 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. */ 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 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 { } uint256[44] private __gap; } // File contracts/upgrades/OwnableUpgradeable.sol pragma solidity =0.6.12; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * 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 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 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; } // File contracts/upgrades/PausableUpgradeable.sol pragma solidity =0.6.12; /** * @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. */ 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 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; } // File contracts/QuaiAccessControl.sol pragma solidity =0.6.12; /* Common base for permissioned roles throughout QUAI ecosystem */ contract QuaiAccessControl is Initializable { address public governance; address public strategist; address public keeper; // ===== MODIFIERS ===== function _onlyGovernance() internal view { require(msg.sender == governance, "onlyGovernance"); } function _onlyGovernanceOrStrategist() internal view { require(msg.sender == strategist || msg.sender == governance, "onlyGovernanceOrStrategist"); } function _onlyAuthorizedActors() internal view { require(msg.sender == keeper || msg.sender == strategist || msg.sender == governance, "onlyAuthorizedActors"); } // ===== PERMISSIONED ACTIONS ===== /// @notice Change strategist address /// @notice Can only be changed by governance itself function setStrategist(address _strategist) external { _onlyGovernance(); strategist = _strategist; } /// @notice Change keeper address /// @notice Can only be changed by governance itself function setKeeper(address _keeper) external { _onlyGovernance(); keeper = _keeper; } /// @notice Change governance address /// @notice Can only be changed by governance itself function setGovernance(address _governance) public { _onlyGovernance(); governance = _governance; } uint256[50] private __gap; } // File contracts/QuaiAccessControlDefended.sol pragma solidity =0.6.12; /* Add ability to prevent unwanted contract access to Vault permissions */ contract QuaiAccessControlDefended is QuaiAccessControl { mapping (address => bool) public approved; function approveContractAccess(address account) external { _onlyGovernance(); approved[account] = true; } function revokeContractAccess(address account) external { _onlyGovernance(); approved[account] = false; } function _defend() internal view returns (bool) { require(approved[msg.sender] || msg.sender == tx.origin, "Access denied for caller"); } uint256[50] private __gap; } // File contracts/BaseStrategy.sol pragma solidity =0.6.12; abstract contract BaseStrategy is PausableUpgradeable, QuaiAccessControl { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; event Withdraw(uint256 amount); event WithdrawAll(uint256 balance); event WithdrawOther(address token, uint256 amount); event SetStrategist(address strategist); event SetGovernance(address governance); event SetController(address controller); event SetWithdrawalFee(uint256 withdrawalFee); event SetPerformanceFeeStrategist(uint256 performanceFeeStrategist); event SetPerformanceFeeGovernance(uint256 performanceFeeGovernance); event Harvest(uint256 harvested, uint256 indexed blockNumber); event Tend(uint256 tended); address public want; // Want: Curve.fi renBTC/wBTC (crvRenWBTC) LP token 0x49849C98ae39Fff122806C06791Fa73784FB3675 uint256 public performanceFeeGovernance; //1000 uint256 public performanceFeeStrategist; //1000 uint256 public withdrawalFee; //50 uint256 public constant MAX_FEE = 10000; address public constant uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // Uniswap Dex address public controller; address public guardian; function __BaseStrategy_init( address _governance, address _strategist, address _controller, address _keeper, address _guardian ) public initializer { __Pausable_init(); governance = _governance; strategist = _strategist; keeper = _keeper; controller = _controller; guardian = _guardian; } // ===== Modifiers ===== function _onlyController() internal view { require(msg.sender == controller, "onlyController"); } function _onlyAuthorizedActorsOrController() internal view { require( msg.sender == keeper || msg.sender == strategist || msg.sender == governance || msg.sender == controller, "onlyAuthorizedActorsOrController" ); } function _onlyAuthorizedPausers() internal view { require(msg.sender == guardian || msg.sender == strategist || msg.sender == governance, "onlyPausers"); } /// ===== View Functions ===== /// @notice Get the balance of want held idle in the Strategy function balanceOfWant() public view returns (uint256) { return IERC20Upgradeable(want).balanceOf(address(this)); } /// @notice Get the total balance of want realized in the strategy, whether idle or active in Strategy positions. function balanceOf() public virtual view returns (uint256) { return balanceOfWant().add(balanceOfPool()); } function isTendable() public virtual pure returns (bool) { return false; } /// ===== Permissioned Actions: Governance ===== function setGuardian(address _guardian) external { _onlyGovernance(); guardian = _guardian; } function setWithdrawalFee(uint256 _withdrawalFee) external { _onlyGovernance(); withdrawalFee = _withdrawalFee; } function setPerformanceFeeStrategist(uint256 _performanceFeeStrategist) external { _onlyGovernance(); performanceFeeStrategist = _performanceFeeStrategist; } function setPerformanceFeeGovernance(uint256 _performanceFeeGovernance) external { _onlyGovernance(); performanceFeeGovernance = _performanceFeeGovernance; } function setController(address _controller) external { _onlyGovernance(); controller = _controller; } function deposit() public virtual whenNotPaused { _onlyAuthorizedActorsOrController(); uint256 _want = IERC20Upgradeable(want).balanceOf(address(this)); if (_want > 0) { _deposit(_want); } _postDeposit(); } // ===== Permissioned Actions: Controller ===== /// @notice Withdraw all funds, normally used when migrating strategies function withdrawAll() external virtual whenNotPaused returns (uint256) { _onlyController(); _withdrawAll(); _transferToVault(IERC20Upgradeable(want).balanceOf(address(this))); } /// @notice Controller-only function to Withdraw partial funds, normally used with a vault withdrawal function withdraw(uint256 _amount) external virtual whenNotPaused { _onlyController(); uint256 _balance = IERC20Upgradeable(want).balanceOf(address(this)); // Withdraw some from activities if idle want is not sufficient to cover withdrawal if (_balance < _amount) { _amount = _withdrawSome(_amount.sub(_balance)); _amount = _amount.add(_balance); } // Process withdrawal fee uint256 _fee = _processWithdrawalFee(_amount); // Transfer remaining to Vault to handle withdrawal _transferToVault(_amount.sub(_fee)); } // NOTE: must exclude any tokens used in the yield // Controller role - withdraw should return to Controller function withdrawOther(address _asset) external virtual whenNotPaused returns (uint256 balance) { _onlyController(); _onlyNotProtectedTokens(_asset); balance = IERC20Upgradeable(_asset).balanceOf(address(this)); IERC20Upgradeable(_asset).safeTransfer(controller, balance); } /// ===== Permissioned Actions: Authoized Contract Pausers ===== function pause() external { _onlyAuthorizedPausers(); _pause(); } function unpause() external { _onlyAuthorizedPausers(); _unpause(); } /// ===== Internal Helper Functions ===== /// @notice If withdrawal fee is active, take the appropriate amount from the given value and transfer to rewards recipient /// @return The withdrawal fee that was taken function _processWithdrawalFee(uint256 _amount) internal returns (uint256) { if (withdrawalFee == 0) { return 0; } uint256 fee = _amount.mul(withdrawalFee).div(MAX_FEE); IERC20Upgradeable(want).safeTransfer(IController(controller).rewards(), fee); return fee; } /// @dev Helper function to process an arbitrary fee /// @dev If the fee is active, transfers a given portion in basis points of the specified value to the recipient /// @return The fee that was taken function _processFee( address token, uint256 amount, uint256 feeBps, address recipient ) internal returns (uint256) { if (feeBps == 0) { return 0; } uint256 fee = amount.mul(feeBps).div(MAX_FEE); IERC20Upgradeable(token).safeTransfer(recipient, fee); return fee; } /// @dev Reset approval and approve exact amount function _safeApproveHelper( address token, address recipient, uint256 amount ) internal { IERC20Upgradeable(token).safeApprove(recipient, 0); IERC20Upgradeable(token).safeApprove(recipient, amount); } function _transferToVault(uint256 _amount) internal { address _vault = IController(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20Upgradeable(want).safeTransfer(_vault, _amount); } /// @notice Swap specified balance of given token on Uniswap with given path function _swap( address startToken, uint256 balance, address[] memory path ) internal { _safeApproveHelper(startToken, uniswap, balance); IUniswapRouterV2(uniswap).swapExactTokensForTokens(balance, 0, path, address(this), now); } function _swapEthIn( uint256 balance, address[] memory path ) internal { IUniswapRouterV2(uniswap).swapExactETHForTokens{value: balance}(0, path, address(this), now); } function _swapEthOut( address startToken, uint256 balance, address[] memory path ) internal { _safeApproveHelper(startToken, uniswap, balance); IUniswapRouterV2(uniswap).swapExactTokensForETH(balance, 0, path, address(this), now); } /// @notice Add liquidity to uniswap for specified token pair, utilizing the maximum balance possible function _add_max_liquidity_uniswap(address token0, address token1) internal { uint256 _token0Balance = IERC20Upgradeable(token0).balanceOf(address(this)); uint256 _token1Balance = IERC20Upgradeable(token1).balanceOf(address(this)); _safeApproveHelper(token0, uniswap, _token0Balance); _safeApproveHelper(token1, uniswap, _token1Balance); IUniswapRouterV2(uniswap).addLiquidity( token0, token1, _token0Balance, _token1Balance, 0, 0, address(this), block.timestamp ); } // ===== Abstract Functions: To be implemented by specific Strategies ===== /// @dev Internal deposit logic to be implemented by Stratgies function _deposit(uint256 _want) internal virtual; function _postDeposit() internal virtual { //no-op by default } /// @notice Specify tokens used in yield process, should not be available to withdraw via withdrawOther() function _onlyNotProtectedTokens(address _asset) internal virtual; function getProtectedTokens() external view virtual returns (address[] memory); /// @dev Internal logic for strategy migration. Should exit positions as efficiently as possible function _withdrawAll() internal virtual; /// @dev Internal logic for partial withdrawals. Should exit positions as efficiently as possible. /// @dev The withdraw() function shell automatically uses idle want in the strategy before attempting to withdraw more using this function _withdrawSome(uint256 _amount) internal virtual returns (uint256); /// @dev Realize returns from positions /// @dev Returns can be reinvested into positions, or distributed in another fashion /// @dev Performance fees should also be implemented in this function /// @dev Override function stub is removed as each strategy can have it's own return signature for STATICCALL // function harvest() external virtual; /// @dev User-friendly name for this strategy for purposes of convenient reading function getName() external virtual pure returns (string memory); /// @dev Balance of want currently held in strategy positions function balanceOfPool() public virtual view returns (uint256); uint256[50] private __gap; } // File contracts/StrategySushiLpOptimizer.sol pragma solidity =0.6.12; /* Optimize Sushi rewards for arbitrary Sushi LP pair */ contract StrategySushiLpOptimizer is BaseStrategy { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; address public constant wbtc = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; // WBTC Token address public constant sushi = 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2; // SUSHI token address public constant xsushi = 0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272; // xSUSHI token address public constant sushiRouter = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F; //SUSHI router address public constant chef = 0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd; // Master staking contract address public token0; //first half of LP token address public token1; //second half of LP token address[] public pathRewardToToken0; //sushi to first half of LP token address[] public pathRewardToToken1; //sushi to second half of LP token uint256 public pid; event SushiHarvest( uint256 xSushiHarvested, uint256 totalxSushi, uint256 lpComponentDeposited, uint256 toStrategist, uint256 toGovernance, uint256 timestamp, uint256 blockNumber ); struct HarvestData { uint256 xSushiHarvested; uint256 totalxSushi; uint256 lpComponentDeposited; uint256 toStrategist; uint256 toGovernance; uint256 timestamp; uint256 blockNumber; } struct TendData { uint256 sushiTended; } event WithdrawState(uint256 toWithdraw, uint256 preWant, uint256 postWant, uint256 withdrawn); //_want = LP token //_pathRewardToToken0 = sushi to first half of LP token //_pathRewardToToken1 = sushi to second half of LP token function initialize( address _governance, address _strategist, address _controller, address _keeper, address _guardian, address _want, uint256 _pid, uint256[3] memory _feeConfig, address[] memory _pathRewardToToken0, address[] memory _pathRewardToToken1 ) public initializer whenNotPaused { __BaseStrategy_init(_governance, _strategist, _controller, _keeper, _guardian); want = _want; pid = _pid; // LP token pool ID performanceFeeGovernance = _feeConfig[0]; performanceFeeStrategist = _feeConfig[1]; withdrawalFee = _feeConfig[2]; pathRewardToToken0 = _pathRewardToToken0; pathRewardToToken1 = _pathRewardToToken1; token0 = _pathRewardToToken0[_pathRewardToToken0.length - 1]; token1 = _pathRewardToToken1[_pathRewardToToken1.length - 1]; // Approve Chef and xSushi (aka SushiBar) to use our sushi IERC20Upgradeable(want).approve(chef, uint256(-1)); IERC20Upgradeable(sushi).approve(xsushi, uint256(-1)); // Approve sushi router to transfer sushi, token0, and token1 IERC20Upgradeable(sushi).approve(sushiRouter, uint256(-1)); IERC20Upgradeable(token0).approve(sushiRouter, uint256(-1)); IERC20Upgradeable(token1).approve(sushiRouter, uint256(-1)); } /// ===== View Functions ===== function version() external pure returns (string memory) { return "1.1"; } function getName() external pure override returns (string memory) { return "StrategySushiLpOptimizer"; } function balanceOfPool() public view override returns (uint256) { (uint256 staked, ) = ISushiChef(chef).userInfo(pid, address(this)); return staked; } function getProtectedTokens() external view override returns (address[] memory) { address[] memory protectedTokens = new address[](3); protectedTokens[0] = want; protectedTokens[1] = sushi; protectedTokens[2] = xsushi; return protectedTokens; } function isTendable() public pure override returns (bool) { return true; } /// ===== Internal Core Implementations ===== function _onlyNotProtectedTokens(address _asset) internal override { require(address(want) != _asset, "want"); require(address(sushi) != _asset, "sushi"); require(address(xsushi) != _asset, "xsushi"); } /// @dev Deposit Badger into the staking contract /// @dev Track balance in the StakingRewards function _deposit(uint256 _want) internal override { // Deposit all want in sushi chef ISushiChef(chef).deposit(pid, _want); } /// @dev Unroll from all strategy positions, and transfer non-core tokens to controller rewards function _withdrawAll() internal override { (uint256 staked, ) = ISushiChef(chef).userInfo(pid, address(this)); // Withdraw all want from Chef ISushiChef(chef).withdraw(pid, staked); // === Transfer extra token: Sushi === // Withdraw all sushi from SushiBar uint256 _xsushi = IERC20Upgradeable(xsushi).balanceOf(address(this)); IxSushi(xsushi).leave(_xsushi); uint256 _sushi = IERC20Upgradeable(sushi).balanceOf(address(this)); // Send all Sushi to controller rewards IERC20Upgradeable(sushi).safeTransfer(IController(controller).rewards(), _sushi); // Note: All want is automatically withdrawn outside this "inner hook" in base strategy function } /// @dev Withdraw want from staking rewards, using earnings first function _withdrawSome(uint256 _amount) internal override returns (uint256) { // Get idle want in the strategy uint256 _preWant = IERC20Upgradeable(want).balanceOf(address(this)); // If we lack sufficient idle want, withdraw the difference from the strategy position if (_preWant < _amount) { uint256 _toWithdraw = _amount.sub(_preWant); ISushiChef(chef).withdraw(pid, _toWithdraw); // Note: Withdrawl process will earn sushi, this will be deposited into SushiBar on next tend() } // Confirm how much want we actually end up with uint256 _postWant = IERC20Upgradeable(want).balanceOf(address(this)); // Return the actual amount withdrawn if less than requested uint256 _withdrawn = MathUpgradeable.min(_postWant, _amount); emit WithdrawState(_amount, _preWant, _postWant, _withdrawn); return _withdrawn; } /// @notice Harvest sushi gains from Chef and deposit into SushiBar (xSushi) to increase gains /// @notice Any excess Sushi sitting in the Strategy will be staked as well /// @notice The more frequent the tend, the higher returns will be function tend() external whenNotPaused returns (TendData memory) { _onlyAuthorizedActors(); TendData memory tendData; // Note: Deposit of zero harvests rewards balance. ISushiChef(chef).deposit(pid, 0); tendData.sushiTended = IERC20Upgradeable(sushi).balanceOf(address(this)); // Stake any harvested sushi in SushiBar to increase returns if (tendData.sushiTended > 0) { IxSushi(xsushi).enter(tendData.sushiTended); } emit Tend(tendData.sushiTended); return tendData; } /// @dev Harvest accumulated sushi from SushiChef and SushiBar and send to rewards tree for distribution. Take performance fees on gains /// @dev The less frequent the harvest, the higher the gains due to compounding function harvest() external whenNotPaused returns (HarvestData memory) { _onlyAuthorizedActors(); HarvestData memory harvestData; uint256 _beforexSushi = IERC20Upgradeable(xsushi).balanceOf(address(this)); uint256 _beforeLp = IERC20Upgradeable(want).balanceOf(address(this)); // == Harvest sushi rewards from Chef == // Note: Deposit of zero harvests rewards balance, but go ahead and deposit idle want if we have it ISushiChef(chef).deposit(pid, _beforeLp); // Put all sushi into xsushi uint256 _sushi = IERC20Upgradeable(sushi).balanceOf(address(this)); if (_sushi > 0) { IxSushi(xsushi).enter(_sushi); } uint256 _xsushi = IERC20Upgradeable(xsushi).balanceOf(address(this)); //all xsushi is profit harvestData.totalxSushi = _xsushi; //harvested is the xsushi gain since last tend harvestData.xSushiHarvested = _xsushi.sub(_beforexSushi); // Process performance fees //performance fees in xsushi harvestData.toStrategist = _processFee(xsushi, harvestData.totalxSushi, performanceFeeStrategist, strategist); harvestData.toGovernance = _processFee(xsushi, harvestData.totalxSushi, performanceFeeGovernance, IController(controller).rewards()); // Turn remaining xsushi back into sushi uint256 _xsushiAfterFees = IERC20Upgradeable(xsushi).balanceOf(address(this)); if (_xsushiAfterFees > 0) { IxSushi(xsushi).leave(_xsushiAfterFees); } uint256 _sushiAfterFees = IERC20Upgradeable(sushi).balanceOf(address(this)); uint256 _want; // Swap remaining sushi into more want if (_sushiAfterFees > 0) { _want = _swapToWant(_sushiAfterFees); } harvestData.lpComponentDeposited = _want; // Deposit any new want into Chef if (_want > 0) { ISushiChef(chef).deposit(pid, _want); } emit SushiHarvest( harvestData.xSushiHarvested, harvestData.totalxSushi, harvestData.lpComponentDeposited, harvestData.toStrategist, harvestData.toGovernance, block.timestamp, block.number ); emit Harvest(_want, block.number); return harvestData; } function _swapToWant(uint256 sushiIn) internal returns(uint256) { uint256 amountIn = (sushiIn / 2); // swap to token0 uint256 amountOutToken0 = amountIn; if (pathRewardToToken0.length != 1) { uint256[] memory amountsOutToken0 = IUniswapRouterV2(sushiRouter).getAmountsOut(amountIn, pathRewardToToken0); amountOutToken0 = amountsOutToken0[amountsOutToken0.length - 1]; IUniswapRouterV2(sushiRouter).swapExactTokensForTokens(amountIn, amountOutToken0, pathRewardToToken0, address(this), block.timestamp); } // swap to token1 uint256 amountOutToken1 = amountIn; if (pathRewardToToken1.length != 1) { uint256[] memory amountsOutToken1 = IUniswapRouterV2(sushiRouter).getAmountsOut(amountIn, pathRewardToToken1); amountOutToken1 = amountsOutToken1[amountsOutToken1.length - 1]; IUniswapRouterV2(sushiRouter).swapExactTokensForTokens(amountIn, amountOutToken1, pathRewardToToken1, address(this), block.timestamp); } (,,uint256 liquidity) = IUniswapRouterV2(sushiRouter).addLiquidity( token0, token1, amountOutToken0, amountOutToken1, 0, 0, address(this), block.timestamp ); return liquidity; } }
0x608060405234801561001057600080fd5b50600436106102955760003560e01c80635c975abb11610167578063ab033ea9116100ce578063d0e30db011610087578063d0e30db0146104ca578063d21220a7146104d2578063ed4bdce1146104da578063f1068454146104ef578063f55462f4146104f7578063f77c47911461050a57610295565b8063ab033ea914610479578063ac1e50251461048c578063aced16611461049f578063bc063e1a146104a7578063c1a3d44c146104af578063c7b9d530146104b757610295565b80638456cb59116101205780638456cb59146104285780638457213a14610430578063853828b6146104435780638a0dac4a1461044b5780638bc7e8c41461045e57806392eefe9b1461046657610295565b80635c975abb146103e05780636d13582c146103f5578063722713f7146103fd578063748747e61461040557806378ee9aa5146104185780637e744eea1461042057610295565b80633951f3df1161020b5780634641257d116101c45780634641257d1461038d578063504a1647146103a257806354fd4d50146103aa57806359996333146103b25780635aa6e675146103c55780635b40f0c8146103cd57610295565b80633951f3df1461033a5780633cdc53891461034d5780633f4ba83a1461035557806340d945e71461035d578063440368a314610370578063452a93201461038557610295565b80631bd43be31161025d5780631bd43be3146102f25780631f1fcd51146103055780631fc8bc5d1461030d5780631fe4a686146103155780632681f7e41461031d5780632e1a7d4d1461032557610295565b80630a0879031461029a5780630dfe1681146102b857806311588086146102c057806315b18ddd146102d557806317d7de7c146102dd575b600080fd5b6102a2610512565b6040516102af9190613288565b60405180910390f35b6102a261052a565b6102c8610539565b6040516102af91906136d5565b6102c86105d0565b6102e56105d6565b6040516102af9190613356565b6102c8610300366004612f66565b61060d565b6102a26106eb565b6102a26106fa565b6102a2610712565b6102a2610721565b6103386103333660046131a6565b610739565b005b610338610348366004612f9e565b610834565b6102a261091a565b610338610932565b6102a261036b3660046131a6565b610944565b61037861096b565b6040516102af91906136cb565b6102a2610b45565b610395610b54565b6040516102af919061367d565b6102c8611211565b6102e5611217565b6102a26103c03660046131a6565b611234565b6102a2611241565b6103386103db36600461300e565b611250565b6103e86116e5565b6040516102af919061334b565b6102a26116ee565b6102c8611706565b610338610413366004612f66565b611726565b6102a2611750565b6103e8611762565b610338611767565b61033861043e3660046131a6565b611777565b6102c8611784565b610338610459366004612f66565b61183c565b6102c8611866565b610338610474366004612f66565b61186c565b610338610487366004612f66565b611896565b61033861049a3660046131a6565b6118c0565b6102a26118cd565b6102c86118dc565b6102c86118e2565b6103386104c5366004612f66565b611963565b61033861198d565b6102a2611a55565b6104e2611a64565b6040516102af91906132fe565b6102c8611b3e565b6103386105053660046131a6565b611b44565b6102a2611b51565b736b3595068778dd592e39a122f4f5a5cf09c90fe281565b60d2546001600160a01b031681565b60d6546040516393f1a40b60e01b8152600091829173c2edad668740f1aa35e4d8f227fb8e17dca888cd916393f1a40b91610579919030906004016136de565b604080518083038186803b15801561059057600080fd5b505afa1580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c891906131d6565b509150505b90565b609b5481565b60408051808201909152601881527f537472617465677953757368694c704f7074696d697a65720000000000000000602082015290565b60335460009060ff161561063c5760405162461bcd60e51b815260040161063390613499565b60405180910390fd5b610644611b60565b61064d82611b8a565b6040516370a0823160e01b81526001600160a01b038316906370a0823190610679903090600401613288565b60206040518083038186803b15801561069157600080fd5b505afa1580156106a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c991906131be565b609e549091506106e6906001600160a01b03848116911683611c2c565b919050565b609a546001600160a01b031681565b73c2edad668740f1aa35e4d8f227fb8e17dca888cd81565b6066546001600160a01b031681565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b60335460ff161561075c5760405162461bcd60e51b815260040161063390613499565b610764611b60565b609a546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610795903090600401613288565b60206040518083038186803b1580156107ad57600080fd5b505afa1580156107c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e591906131be565b905081811015610810576108016107fc8383611c82565b611ccd565b915061080d8282611eaf565b91505b600061081b83611ed4565b905061082f61082a8483611c82565b611faa565b505050565b600054610100900460ff168061084d575061084d612075565b8061085b575060005460ff16155b6108775760405162461bcd60e51b8152600401610633906134e1565b600054610100900460ff161580156108a2576000805460ff1961ff0019909116610100171660011790555b6108aa61207b565b606580546001600160a01b03199081166001600160a01b0389811691909117909255606680548216888416179055606780548216868416179055609e80548216878416179055609f80549091169184169190911790558015610912576000805461ff00191690555b505050505050565b732260fac5e5542a773aa44fbcfedf7c193bc2c59981565b61093a61210d565b610942612161565b565b60d5818154811061095157fe5b6000918252602090912001546001600160a01b0316905081565b610973612db7565b60335460ff16156109965760405162461bcd60e51b815260040161063390613499565b61099e6121cd565b6109a6612db7565b60d654604051631c57762b60e31b815273c2edad668740f1aa35e4d8f227fb8e17dca888cd9163e2bbb158916109e2919060009060040161370e565b600060405180830381600087803b1580156109fc57600080fd5b505af1158015610a10573d6000803e3d6000fd5b50506040516370a0823160e01b8152736b3595068778dd592e39a122f4f5a5cf09c90fe292506370a082319150610a4b903090600401613288565b60206040518083038186803b158015610a6357600080fd5b505afa158015610a77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9b91906131be565b80825215610b08578051604051632967cf8360e21b81526000805160206138308339815191529163a59f3e0c91610ad591906004016136d5565b600060405180830381600087803b158015610aef57600080fd5b505af1158015610b03573d6000803e3d6000fd5b505050505b80516040517f8ea01a73fd14904f3ff9411fca71994cb18c9118112c82f0c102bb3b1d1cedec91610b38916136d5565b60405180910390a1905090565b609f546001600160a01b031681565b610b5c612dca565b60335460ff1615610b7f5760405162461bcd60e51b815260040161063390613499565b610b876121cd565b610b8f612dca565b6040516370a0823160e01b8152600090600080516020613830833981519152906370a0823190610bc3903090600401613288565b60206040518083038186803b158015610bdb57600080fd5b505afa158015610bef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1391906131be565b609a546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610c49903090600401613288565b60206040518083038186803b158015610c6157600080fd5b505afa158015610c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c9991906131be565b60d654604051631c57762b60e31b815291925073c2edad668740f1aa35e4d8f227fb8e17dca888cd9163e2bbb15891610cd691859060040161370e565b600060405180830381600087803b158015610cf057600080fd5b505af1158015610d04573d6000803e3d6000fd5b50506040516370a0823160e01b815260009250736b3595068778dd592e39a122f4f5a5cf09c90fe291506370a0823190610d42903090600401613288565b60206040518083038186803b158015610d5a57600080fd5b505afa158015610d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9291906131be565b90508015610dfe57604051632967cf8360e21b81526000805160206138308339815191529063a59f3e0c90610dcb9084906004016136d5565b600060405180830381600087803b158015610de557600080fd5b505af1158015610df9573d6000803e3d6000fd5b505050505b6040516370a0823160e01b8152600090600080516020613830833981519152906370a0823190610e32903090600401613288565b60206040518083038186803b158015610e4a57600080fd5b505afa158015610e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8291906131be565b602086018190529050610e958185611c82565b85526020850151609c54606654610ec6926000805160206138308339815191529290916001600160a01b0316612221565b6060860152602080860151609b54609e54604080516327b16a2560e21b81529051610f65956000805160206138308339815191529594936001600160a01b031692639ec5a8949260048083019392829003018186803b158015610f2857600080fd5b505afa158015610f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f609190612f82565b612221565b60808601526040516370a0823160e01b8152600090600080516020613830833981519152906370a0823190610f9e903090600401613288565b60206040518083038186803b158015610fb657600080fd5b505afa158015610fca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fee91906131be565b9050801561105a576040516367dfd4c960e01b8152600080516020613830833981519152906367dfd4c9906110279084906004016136d5565b600060405180830381600087803b15801561104157600080fd5b505af1158015611055573d6000803e3d6000fd5b505050505b6040516370a0823160e01b8152600090736b3595068778dd592e39a122f4f5a5cf09c90fe2906370a0823190611094903090600401613288565b60206040518083038186803b1580156110ac57600080fd5b505afa1580156110c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e491906131be565b9050600081156110fa576110f782612263565b90505b6040880181905280156111755760d654604051631c57762b60e31b815273c2edad668740f1aa35e4d8f227fb8e17dca888cd9163e2bbb158916111429190859060040161370e565b600060405180830381600087803b15801561115c57600080fd5b505af1158015611170573d6000803e3d6000fd5b505050505b7f324a8c6158e13aa81749333af952bf6c773a734851eb998953f843b199c9a61d886000015189602001518a604001518b606001518c6080015142436040516111c49796959493929190613773565b60405180910390a1437f6c8433a8e155f0af04dba058d4e4695f7da554578963d876bdf4a6d8d6399d9c826040516111fc91906136d5565b60405180910390a25095965050505050505090565b609c5481565b604080518082019091526003815262312e3160e81b602082015290565b60d4818154811061095157fe5b6065546001600160a01b031681565b600054610100900460ff16806112695750611269612075565b80611277575060005460ff16155b6112935760405162461bcd60e51b8152600401610633906134e1565b600054610100900460ff161580156112be576000805460ff1961ff0019909116610100171660011790555b60335460ff16156112e15760405162461bcd60e51b815260040161063390613499565b6112ee8b8b8b8b8b610834565b609a80546001600160a01b0319166001600160a01b03881617905560d68590558351609b55602080850151609c556040850151609d5583516113369160d49190860190612e07565b50815161134a9060d5906020850190612e07565b508260018451038151811061135b57fe5b602002602001015160d260006101000a8154816001600160a01b0302191690836001600160a01b031602179055508160018351038151811061139957fe5b602090810291909101015160d380546001600160a01b0319166001600160a01b03928316179055609a5460405163095ea7b360e01b815291169063095ea7b3906113ff9073c2edad668740f1aa35e4d8f227fb8e17dca888cd90600019906004016132e5565b602060405180830381600087803b15801561141957600080fd5b505af115801561142d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114519190613186565b5060405163095ea7b360e01b8152736b3595068778dd592e39a122f4f5a5cf09c90fe29063095ea7b39061149b9060008051602061383083398151915290600019906004016132e5565b602060405180830381600087803b1580156114b557600080fd5b505af11580156114c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ed9190613186565b5060405163095ea7b360e01b8152736b3595068778dd592e39a122f4f5a5cf09c90fe29063095ea7b39061153d9073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90600019906004016132e5565b602060405180830381600087803b15801561155757600080fd5b505af115801561156b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158f9190613186565b5060d25460405163095ea7b360e01b81526001600160a01b039091169063095ea7b3906115d89073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90600019906004016132e5565b602060405180830381600087803b1580156115f257600080fd5b505af1158015611606573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162a9190613186565b5060d35460405163095ea7b360e01b81526001600160a01b039091169063095ea7b3906116739073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f90600019906004016132e5565b602060405180830381600087803b15801561168d57600080fd5b505af11580156116a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c59190613186565b5080156116d8576000805461ff00191690555b5050505050505050505050565b60335460ff1690565b73d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b6000611721611713610539565b61171b6118e2565b90611eaf565b905090565b61172e6125d6565b606780546001600160a01b0319166001600160a01b0392909216919091179055565b60008051602061383083398151915281565b600190565b61176f61210d565b610942612600565b61177f6125d6565b609b55565b60335460009060ff16156117aa5760405162461bcd60e51b815260040161063390613499565b6117b2611b60565b6117ba612659565b609a546040516370a0823160e01b81526105cd916001600160a01b0316906370a08231906117ec903090600401613288565b60206040518083038186803b15801561180457600080fd5b505afa158015611818573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082a91906131be565b6118446125d6565b609f80546001600160a01b0319166001600160a01b0392909216919091179055565b609d5481565b6118746125d6565b609e80546001600160a01b0319166001600160a01b0392909216919091179055565b61189e6125d6565b606580546001600160a01b0319166001600160a01b0392909216919091179055565b6118c86125d6565b609d55565b6067546001600160a01b031681565b61271081565b609a546040516370a0823160e01b81526000916001600160a01b0316906370a0823190611913903090600401613288565b60206040518083038186803b15801561192b57600080fd5b505afa15801561193f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172191906131be565b61196b6125d6565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60335460ff16156119b05760405162461bcd60e51b815260040161063390613499565b6119b8612970565b609a546040516370a0823160e01b81526000916001600160a01b0316906370a08231906119e9903090600401613288565b60206040518083038186803b158015611a0157600080fd5b505afa158015611a15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3991906131be565b90508015611a4a57611a4a816129d9565b611a52610942565b50565b60d3546001600160a01b031681565b604080516003808252608082019092526060918291906020820183803683375050609a5482519293506001600160a01b031691839150600090611aa357fe5b60200260200101906001600160a01b031690816001600160a01b031681525050736b3595068778dd592e39a122f4f5a5cf09c90fe281600181518110611ae557fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060008051602061383083398151915281600281518110611b2157fe5b6001600160a01b0390921660209283029190910190910152905090565b60d65481565b611b4c6125d6565b609c55565b609e546001600160a01b031681565b609e546001600160a01b031633146109425760405162461bcd60e51b81526004016106339061341c565b609a546001600160a01b0382811691161415611bb85760405162461bcd60e51b8152600401610633906134c3565b736b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b0382161415611bf55760405162461bcd60e51b8152600401610633906135b5565b6000805160206138308339815191526001600160a01b0382161415611a525760405162461bcd60e51b815260040161063390613444565b61082f8363a9059cbb60e01b8484604051602401611c4b9291906132e5565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a49565b6000611cc483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612ad8565b90505b92915050565b609a546040516370a0823160e01b815260009182916001600160a01b03909116906370a0823190611d02903090600401613288565b60206040518083038186803b158015611d1a57600080fd5b505afa158015611d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5291906131be565b905082811015611dd9576000611d688483611c82565b60d654604051630441a3e760e41b815291925073c2edad668740f1aa35e4d8f227fb8e17dca888cd9163441a3e7091611da591859060040161370e565b600060405180830381600087803b158015611dbf57600080fd5b505af1158015611dd3573d6000803e3d6000fd5b50505050505b609a546040516370a0823160e01b81526000916001600160a01b0316906370a0823190611e0a903090600401613288565b60206040518083038186803b158015611e2257600080fd5b505afa158015611e36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5a91906131be565b90506000611e688286612b04565b90507f31c9c70d9d3f8c9d1c38dc84504d6e076ea17e0c2aebda9cf0610a3cdf3c3f6a85848484604051611e9f9493929190613758565b60405180910390a1949350505050565b600082820183811015611cc45760405162461bcd60e51b8152600401610633906133e5565b6000609d5460001415611ee9575060006106e6565b6000611f0c612710611f06609d5486612b1a90919063ffffffff16565b90612b54565b9050611cc7609e60009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b158015611f5f57600080fd5b505afa158015611f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f979190612f82565b609a546001600160a01b03169083611c2c565b609e54609a54604051632988bb9f60e21b81526000926001600160a01b039081169263a622ee7c92611fe29290911690600401613288565b60206040518083038186803b158015611ffa57600080fd5b505afa15801561200e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120329190612f82565b90506001600160a01b03811661205a5760405162461bcd60e51b815260040161063390613570565b609a54612071906001600160a01b03168284611c2c565b5050565b303b1590565b600054610100900460ff16806120945750612094612075565b806120a2575060005460ff16155b6120be5760405162461bcd60e51b8152600401610633906134e1565b600054610100900460ff161580156120e9576000805460ff1961ff0019909116610100171660011790555b6120f1612b96565b6120f9612c17565b8015611a52576000805461ff001916905550565b609f546001600160a01b031633148061213057506066546001600160a01b031633145b8061214557506065546001600160a01b031633145b6109425760405162461bcd60e51b815260040161063390613590565b60335460ff166121835760405162461bcd60e51b8152600401610633906133b7565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6121b6612ca3565b6040516121c39190613288565b60405180910390a1565b6067546001600160a01b03163314806121f057506066546001600160a01b031633145b8061220557506065546001600160a01b031633145b6109425760405162461bcd60e51b815260040161063390613389565b6000826122305750600061225b565b6000612242612710611f068787612b1a565b90506122586001600160a01b0387168483611c2c565b90505b949350505050565b60d454600090600283049081906001146123c65760405163d06ca61f60e01b815260609073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9063d06ca61f906122b490869060d4906004016136f5565b60006040518083038186803b1580156122cc57600080fd5b505afa1580156122e0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261230891908101906130f6565b90508060018251038151811061231a57fe5b6020026020010151915073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f6001600160a01b03166338ed1739848460d430426040518663ffffffff1660e01b815260040161236d95949392919061371c565b600060405180830381600087803b15801561238757600080fd5b505af115801561239b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526123c391908101906130f6565b50505b60d55482906001146125215760405163d06ca61f60e01b815260609073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9063d06ca61f9061240f90879060d5906004016136f5565b60006040518083038186803b15801561242757600080fd5b505afa15801561243b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261246391908101906130f6565b90508060018251038151811061247557fe5b6020026020010151915073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f6001600160a01b03166338ed1739858460d530426040518663ffffffff1660e01b81526004016124c895949392919061371c565b600060405180830381600087803b1580156124e257600080fd5b505af11580156124f6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261251e91908101906130f6565b50505b60d25460d35460405162e8e33760e81b815260009273d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9263e8e3370092612578926001600160a01b0390811692169088908890889081903090429060040161329c565b606060405180830381600087803b15801561259257600080fd5b505af11580156125a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ca91906131f9565b98975050505050505050565b6065546001600160a01b031633146109425760405162461bcd60e51b815260040161063390613655565b60335460ff16156126235760405162461bcd60e51b815260040161063390613499565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121b6612ca3565b60d6546040516393f1a40b60e01b815260009173c2edad668740f1aa35e4d8f227fb8e17dca888cd916393f1a40b916126969130906004016136de565b604080518083038186803b1580156126ad57600080fd5b505afa1580156126c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e591906131d6565b5060d654604051630441a3e760e41b815291925073c2edad668740f1aa35e4d8f227fb8e17dca888cd9163441a3e709161272391859060040161370e565b600060405180830381600087803b15801561273d57600080fd5b505af1158015612751573d6000803e3d6000fd5b50506040516370a0823160e01b81526000925060008051602061383083398151915291506370a0823190612789903090600401613288565b60206040518083038186803b1580156127a157600080fd5b505afa1580156127b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d991906131be565b6040516367dfd4c960e01b8152909150600080516020613830833981519152906367dfd4c99061280d9084906004016136d5565b600060405180830381600087803b15801561282757600080fd5b505af115801561283b573d6000803e3d6000fd5b50506040516370a0823160e01b815260009250736b3595068778dd592e39a122f4f5a5cf09c90fe291506370a0823190612879903090600401613288565b60206040518083038186803b15801561289157600080fd5b505afa1580156128a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c991906131be565b905061082f609e60009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b15801561291c57600080fd5b505afa158015612930573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129549190612f82565b736b3595068778dd592e39a122f4f5a5cf09c90fe29083611c2c565b6067546001600160a01b031633148061299357506066546001600160a01b031633145b806129a857506065546001600160a01b031633145b806129bd5750609e546001600160a01b031633145b6109425760405162461bcd60e51b815260040161063390613464565b60d654604051631c57762b60e31b815273c2edad668740f1aa35e4d8f227fb8e17dca888cd9163e2bbb15891612a149190859060040161370e565b600060405180830381600087803b158015612a2e57600080fd5b505af1158015612a42573d6000803e3d6000fd5b5050505050565b6060612a9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612ca79092919063ffffffff16565b80519091501561082f5780806020019051810190612abc9190613186565b61082f5760405162461bcd60e51b81526004016106339061360b565b60008184841115612afc5760405162461bcd60e51b81526004016106339190613356565b505050900390565b6000818310612b135781611cc4565b5090919050565b600082612b2957506000611cc7565b82820282848281612b3657fe5b0414611cc45760405162461bcd60e51b81526004016106339061352f565b6000611cc483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612cb6565b600054610100900460ff1680612baf5750612baf612075565b80612bbd575060005460ff16155b612bd95760405162461bcd60e51b8152600401610633906134e1565b600054610100900460ff161580156120f9576000805460ff1961ff0019909116610100171660011790558015611a52576000805461ff001916905550565b600054610100900460ff1680612c305750612c30612075565b80612c3e575060005460ff16155b612c5a5760405162461bcd60e51b8152600401610633906134e1565b600054610100900460ff16158015612c85576000805460ff1961ff0019909116610100171660011790555b6033805460ff191690558015611a52576000805461ff001916905550565b3390565b606061225b8484600085612ced565b60008183612cd75760405162461bcd60e51b81526004016106339190613356565b506000838581612ce357fe5b0495945050505050565b6060612cf885612db1565b612d145760405162461bcd60e51b8152600401610633906135d4565b60006060866001600160a01b03168587604051612d31919061326c565b60006040518083038185875af1925050503d8060008114612d6e576040519150601f19603f3d011682016040523d82523d6000602084013e612d73565b606091505b50915091508115612d8757915061225b9050565b805115612d975780518082602001fd5b8360405162461bcd60e51b81526004016106339190613356565b3b151590565b6040518060200160405280600081525090565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215612e5c579160200282015b82811115612e5c57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612e27565b50612e68929150612e6c565b5090565b5b80821115612e685780546001600160a01b0319168155600101612e6d565b8035611cc78161381a565b600082601f830112612ea6578081fd5b8135612eb9612eb4826137ca565b6137a3565b818152915060208083019084810181840286018201871015612eda57600080fd5b60005b84811015612f02578135612ef08161381a565b84529282019290820190600101612edd565b505050505092915050565b600082601f830112612f1d578081fd5b612f2760606137a3565b9050808284606085011115612f3b57600080fd5b60005b6003811015612f5d578135835260209283019290910190600101612f3e565b50505092915050565b600060208284031215612f77578081fd5b8135611cc48161381a565b600060208284031215612f93578081fd5b8151611cc48161381a565b600080600080600060a08688031215612fb5578081fd5b8535612fc08161381a565b94506020860135612fd08161381a565b93506040860135612fe08161381a565b92506060860135612ff08161381a565b915060808601356130008161381a565b809150509295509295909350565b6000806000806000806000806000806101808b8d03121561302d578485fd5b6130378c8c612e8b565b99506130468c60208d01612e8b565b98506130558c60408d01612e8b565b97506130648c60608d01612e8b565b96506130738c60808d01612e8b565b95506130828c60a08d01612e8b565b945060c08b013593506130988c60e08d01612f0d565b92506101408b013567ffffffffffffffff808211156130b5578384fd5b6130c18e838f01612e96565b93506101608d01359150808211156130d7578283fd5b506130e48d828e01612e96565b9150509295989b9194979a5092959850565b60006020808385031215613108578182fd5b825167ffffffffffffffff81111561311e578283fd5b8301601f8101851361312e578283fd5b805161313c612eb4826137ca565b8181528381019083850185840285018601891015613158578687fd5b8694505b8385101561317a57805183526001949094019391850191850161315c565b50979650505050505050565b600060208284031215613197578081fd5b81518015158114611cc4578182fd5b6000602082840312156131b7578081fd5b5035919050565b6000602082840312156131cf578081fd5b5051919050565b600080604083850312156131e8578182fd5b505080516020909101519092909150565b60008060006060848603121561320d578283fd5b8351925060208401519150604084015190509250925092565b6000815480845260208085019450838352808320835b838110156132615781546001600160a01b03168752958201956001918201910161323c565b509495945050505050565b6000825161327e8184602087016137ea565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039889168152968816602088015260408701959095526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561333f5783516001600160a01b03168352928401929184019160010161331a565b50909695505050505050565b901515815260200190565b60006020825282518060208401526133758160408501602087016137ea565b601f01601f19169190910160400192915050565b6020808252601490820152736f6e6c79417574686f72697a65644163746f727360601b604082015260600190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600e908201526d37b7363ca1b7b73a3937b63632b960911b604082015260600190565b60208082526006908201526578737573686960d01b604082015260600190565b6020808252818101527f6f6e6c79417574686f72697a65644163746f72734f72436f6e74726f6c6c6572604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600490820152631dd85b9d60e21b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260069082015265085d985d5b1d60d21b604082015260600190565b6020808252600b908201526a6f6e6c795061757365727360a81b604082015260600190565b602080825260059082015264737573686960d81b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600e908201526d6f6e6c79476f7665726e616e636560901b604082015260600190565b600060e082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015292915050565b9051815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b60008382526040602083015261225b6040830184613226565b918252602082015260400190565b600086825285602083015260a0604083015261373b60a0830186613226565b6001600160a01b0394909416606083015250608001529392505050565b93845260208401929092526040830152606082015260800190565b968752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b60405181810167ffffffffffffffff811182821017156137c257600080fd5b604052919050565b600067ffffffffffffffff8211156137e0578081fd5b5060209081020190565b60005b838110156138055781810151838201526020016137ed565b83811115613814576000848401525b50505050565b6001600160a01b0381168114611a5257600080fdfe0000000000000000000000008798249c2e607446efb7ad49ec89dd1865ff4272a2646970667358221220944f7a72cbf67369c39e11f2e06a1f45e1d149a165bc73da8034bfaba7912b1e64736f6c634300060c0033
{"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, 2581, 2050, 2475, 3401, 18827, 12879, 2683, 28154, 2546, 2683, 2549, 2094, 2683, 2546, 18139, 18939, 22275, 4402, 21057, 2581, 14526, 2546, 2620, 2278, 2683, 2683, 2050, 2620, 2549, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1018, 1012, 1015, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 8311, 1013, 18739, 1013, 8785, 6279, 24170, 3085, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1020, 1012, 2260, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3115, 8785, 16548, 4394, 1999, 1996, 5024, 3012, 2653, 1012, 1008, 1013, 3075, 8785, 6279, 24170, 3085, 1063, 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,946
0x97a308c426928ed25f3a37ddaece1678bbad498c
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; contract DSMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x); } function div(uint256 x, uint256 y) internal pure returns (uint256 z) { return x / y; } function min(uint256 x, uint256 y) internal pure returns (uint256 z) { return x <= y ? x : y; } function max(uint256 x, uint256 y) internal pure returns (uint256 z) { return x >= y ? x : y; } function imin(int256 x, int256 y) internal pure returns (int256 z) { return x <= y ? x : y; } function imax(int256 x, int256 y) internal pure returns (int256 z) { return x >= y ? x : y; } uint256 constant WAD = 10**18; uint256 constant RAY = 10**27; function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, WAD), y / 2) / y; } function rdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, RAY), y / 2) / y; } // This famous algorithm is called "exponentiation by squaring" // and calculates x^n with x as fixed-point and n as regular unsigned. // // It's O(log n), instead of O(n) for naive repeated multiplication. // // These facts are why it works: // // If n is even, then x^n = (x^2)^(n/2). // If n is odd, then x^n = x * x^(n-1), // and applying the equation for even x gives // x^n = x * (x^2)^((n-1) / 2). // // Also, EVM division is flooring and // floor[(n-1) / 2] = floor[n / 2]. // function rpow(uint256 x, uint256 n) internal pure returns (uint256 z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } abstract contract DSAuthority { function canCall(address src, address dst, bytes4 sig) public virtual view returns (bool); } contract DSAuthEvents { event LogSetAuthority(address indexed authority); event LogSetOwner(address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(address(authority)); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, address(this), sig); } } } contract DSNote { event LogNote( bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint256 wad, bytes fax ) anonymous; modifier note { bytes32 foo; bytes32 bar; assembly { foo := calldataload(4) bar := calldataload(36) } emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data); _; } } abstract contract DSProxy is DSAuth, DSNote { DSProxyCache public cache; // global cache for contracts constructor(address _cacheAddr) public { require(setCache(_cacheAddr)); } // solhint-disable-next-line no-empty-blocks receive() external payable {} // use the proxy to execute calldata _data on contract _code // function execute(bytes memory _code, bytes memory _data) // public // payable // virtual // returns (address target, bytes32 response); function execute(address _target, bytes memory _data) public payable virtual returns (bytes32 response); //set new cache function setCache(address _cacheAddr) public virtual payable returns (bool); } contract DSProxyCache { mapping(bytes32 => address) cache; function read(bytes memory _code) public view returns (address) { bytes32 hash = keccak256(_code); return cache[hash]; } function write(bytes memory _code) public returns (address target) { assembly { target := create(0, add(_code, 0x20), mload(_code)) switch iszero(extcodesize(target)) case 1 { // throw if contract failed to deploy revert(0, 0) } } bytes32 hash = keccak256(_code); cache[hash] = target; } } contract Discount { address public owner; mapping(address => CustomServiceFee) public serviceFees; uint256 constant MAX_SERVICE_FEE = 400; struct CustomServiceFee { bool active; uint256 amount; } constructor() public { owner = msg.sender; } function isCustomFeeSet(address _user) public view returns (bool) { return serviceFees[_user].active; } function getCustomServiceFee(address _user) public view returns (uint256) { return serviceFees[_user].amount; } function setServiceFee(address _user, uint256 _fee) public { require(msg.sender == owner, "Only owner"); require(_fee >= MAX_SERVICE_FEE || _fee == 0); serviceFees[_user] = CustomServiceFee({active: true, amount: _fee}); } function disableServiceFee(address _user) public { require(msg.sender == owner, "Only owner"); serviceFees[_user] = CustomServiceFee({active: false, amount: 0}); } } abstract contract IFeeRecipient { function getFeeAddr() public view virtual returns (address); function changeWalletAddr(address _newWallet) public virtual; } abstract contract IAToken { function redeem(uint256 _amount) external virtual; function balanceOf(address _owner) external virtual view returns (uint256 balance); } /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ interface ILendingPoolAddressesProviderV2 { event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function setAddress(bytes32 id, address newAddress) external; function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external; } library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode {NONE, STABLE, VARIABLE} } interface ILendingPoolV2 { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount ); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param rateMode The rate mode that the user wants to swap to **/ event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet **/ function withdraw( address asset, uint256 amount, address to ) external; /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external; /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa * @param asset The address of the underlying asset borrowed * @param rateMode The rate mode that the user wants to swap to **/ function swapBorrowRateMode(address asset, uint256 rateMode) external; /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external; /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); function initReserve( address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external; function setConfiguration(address reserve, uint256 configuration) external; /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; function getReservesList() external view returns (address[] memory); function getAddressesProvider() external view returns (ILendingPoolAddressesProviderV2); function setPause(bool val) external; function paused() external view returns (bool); } /************ @title IPriceOracleGetterAave interface @notice Interface for the Aave price oracle.*/ abstract contract IPriceOracleGetterAave { function getAssetPrice(address _asset) external virtual view returns (uint256); function getAssetsPrices(address[] calldata _assets) external virtual view returns(uint256[] memory); function getSourceOfAsset(address _asset) external virtual view returns(address); function getFallbackOracle() external virtual view returns(address); } abstract contract IAaveProtocolDataProviderV2 { struct TokenData { string symbol; address tokenAddress; } function getAllReservesTokens() external virtual view returns (TokenData[] memory); function getAllATokens() external virtual view returns (TokenData[] memory); function getReserveConfigurationData(address asset) external virtual view returns ( uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen ); function getReserveData(address asset) external virtual view returns ( uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp ); function getUserReserveData(address asset, address user) external virtual view returns ( uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled ); function getReserveTokensAddresses(address asset) external virtual view returns ( address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress ); } interface ERC20 { function totalSupply() external view returns (uint256 supply); function balanceOf(address _owner) external view returns (uint256 balance); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); function decimals() external view returns (uint256 digits); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } 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 mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(ERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(ERC20 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. */ function safeApprove(ERC20 token, address spender, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(ERC20 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(ERC20 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(ERC20 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"); } } } contract AdminAuth { using SafeERC20 for ERC20; address public owner; address public admin; modifier onlyOwner() { require(owner == msg.sender); _; } modifier onlyAdmin() { require(admin == msg.sender); _; } constructor() public { owner = 0xBc841B0dE0b93205e912CFBBd1D0c160A1ec6F00; admin = 0x25eFA336886C74eA8E282ac466BdCd0199f85BB9; } /// @notice Admin is set by owner first time, after that admin is super role and has permission to change owner /// @param _admin Address of multisig that becomes admin function setAdminByOwner(address _admin) public { require(msg.sender == owner); require(admin == address(0)); admin = _admin; } /// @notice Admin is able to set new admin /// @param _admin Address of multisig that becomes new admin function setAdminByAdmin(address _admin) public { require(msg.sender == admin); admin = _admin; } /// @notice Admin is able to change owner /// @param _owner Address of new owner function setOwnerByAdmin(address _owner) public { require(msg.sender == admin); owner = _owner; } /// @notice Destroy the contract function kill() public onlyOwner { selfdestruct(payable(owner)); } /// @notice withdraw stuck funds function withdrawStuckFunds(address _token, uint _amount) public onlyOwner { if (_token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { payable(owner).transfer(_amount); } else { ERC20(_token).safeTransfer(owner, _amount); } } } contract BotRegistry is AdminAuth { mapping (address => bool) public botList; constructor() public { botList[0x776B4a13093e30B05781F97F6A4565B6aa8BE330] = true; botList[0xAED662abcC4FA3314985E67Ea993CAD064a7F5cF] = true; botList[0xa5d330F6619d6bF892A5B87D80272e1607b3e34D] = true; botList[0x5feB4DeE5150B589a7f567EA7CADa2759794A90A] = true; botList[0x7ca06417c1d6f480d3bB195B80692F95A6B66158] = true; } function setBot(address _botAddr, bool _state) public onlyOwner { botList[_botAddr] = _state; } } contract AaveHelperV2 is DSMath { using SafeERC20 for ERC20; IFeeRecipient public constant feeRecipient = IFeeRecipient(0x39C4a92Dc506300c3Ea4c67ca4CA611102ee6F2A); address public constant DISCOUNT_ADDR = 0x1b14E8D511c9A4395425314f849bD737BAF8208F; address public constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // mainnet uint public constant MANUAL_SERVICE_FEE = 400; // 0.25% Fee uint public constant AUTOMATIC_SERVICE_FEE = 333; // 0.3% Fee address public constant BOT_REGISTRY_ADDRESS = 0x637726f8b08a7ABE3aE3aCaB01A80E2d8ddeF77B; address public constant ETH_ADDR = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint public constant NINETY_NINE_PERCENT_WEI = 990000000000000000; uint16 public constant AAVE_REFERRAL_CODE = 64; uint public constant STABLE_ID = 1; uint public constant VARIABLE_ID = 2; /// @notice Calculates the gas cost for transaction /// @param _oracleAddress address of oracle used /// @param _amount Amount that is converted /// @param _user Actuall user addr not DSProxy /// @param _gasCost Ether amount of gas we are spending for tx /// @param _tokenAddr token addr. of token we are getting for the fee /// @return gasCost The amount we took for the gas cost function getGasCost(address _oracleAddress, uint _amount, address _user, uint _gasCost, address _tokenAddr) internal returns (uint gasCost) { if (_gasCost == 0) return 0; // in case its ETH, we need to get price for WETH // everywhere else we still use ETH as thats the token we have in this moment address priceToken = _tokenAddr == ETH_ADDR ? WETH_ADDRESS : _tokenAddr; uint256 price = IPriceOracleGetterAave(_oracleAddress).getAssetPrice(priceToken); _gasCost = wdiv(_gasCost, price) / (10 ** (18 - _getDecimals(_tokenAddr))); gasCost = _gasCost; // gas cost can't go over 20% of the whole amount if (gasCost > (_amount / 5)) { gasCost = _amount / 5; } address walletAddr = feeRecipient.getFeeAddr(); if (_tokenAddr == ETH_ADDR) { payable(walletAddr).transfer(gasCost); } else { ERC20(_tokenAddr).safeTransfer(walletAddr, gasCost); } } /// @notice Returns the owner of the DSProxy that called the contract function getUserAddress() internal view returns (address) { DSProxy proxy = DSProxy(payable(address(this))); return proxy.owner(); } /// @notice Approves token contract to pull underlying tokens from the DSProxy /// @param _tokenAddr Token we are trying to approve /// @param _caller Address which will gain the approval function approveToken(address _tokenAddr, address _caller) internal { if (_tokenAddr != ETH_ADDR) { ERC20(_tokenAddr).safeApprove(_caller, uint256(-1)); } } /// @notice Send specific amount from contract to specific user /// @param _token Token we are trying to send /// @param _user User that should receive funds /// @param _amount Amount that should be sent function sendContractBalance(address _token, address _user, uint _amount) internal { if (_amount == 0) return; if (_token == ETH_ADDR) { payable(_user).transfer(_amount); } else { ERC20(_token).safeTransfer(_user, _amount); } } function sendFullContractBalance(address _token, address _user) internal { if (_token == ETH_ADDR) { sendContractBalance(_token, _user, address(this).balance); } else { sendContractBalance(_token, _user, ERC20(_token).balanceOf(address(this))); } } function _getDecimals(address _token) internal view returns (uint256) { if (_token == ETH_ADDR) return 18; return ERC20(_token).decimals(); } function getDataProvider(address _market) internal view returns(IAaveProtocolDataProviderV2) { return IAaveProtocolDataProviderV2(ILendingPoolAddressesProviderV2(_market).getAddress(0x0100000000000000000000000000000000000000000000000000000000000000)); } } abstract contract GasTokenInterface is ERC20 { function free(uint256 value) public virtual returns (bool success); function freeUpTo(uint256 value) public virtual returns (uint256 freed); function freeFrom(address from, uint256 value) public virtual returns (bool success); function freeFromUpTo(address from, uint256 value) public virtual returns (uint256 freed); } contract GasBurner { // solhint-disable-next-line const-name-snakecase GasTokenInterface public constant gasToken = GasTokenInterface(0x0000000000b3F879cb30FE243b4Dfee438691c04); modifier burnGas(uint _amount) { if (gasToken.balanceOf(address(this)) >= _amount) { gasToken.free(_amount); } _; } } abstract contract DSGuard { function canCall(address src_, address dst_, bytes4 sig) public view virtual returns (bool); function permit(bytes32 src, bytes32 dst, bytes32 sig) public virtual; function forbid(bytes32 src, bytes32 dst, bytes32 sig) public virtual; function permit(address src, address dst, bytes32 sig) public virtual; function forbid(address src, address dst, bytes32 sig) public virtual; } abstract contract DSGuardFactory { function newGuard() public virtual returns (DSGuard guard); } contract ProxyPermission { address public constant FACTORY_ADDRESS = 0x5a15566417e6C1c9546523066500bDDBc53F88C7; /// @notice Called in the context of DSProxy to authorize an address /// @param _contractAddr Address which will be authorized function givePermission(address _contractAddr) public { address currAuthority = address(DSAuth(address(this)).authority()); DSGuard guard = DSGuard(currAuthority); if (currAuthority == address(0)) { guard = DSGuardFactory(FACTORY_ADDRESS).newGuard(); DSAuth(address(this)).setAuthority(DSAuthority(address(guard))); } guard.permit(_contractAddr, address(this), bytes4(keccak256("execute(address,bytes)"))); } /// @notice Called in the context of DSProxy to remove authority of an address /// @param _contractAddr Auth address which will be removed from authority list function removePermission(address _contractAddr) public { address currAuthority = address(DSAuth(address(this)).authority()); // if there is no authority, that means that contract doesn't have permission if (currAuthority == address(0)) { return; } DSGuard guard = DSGuard(currAuthority); guard.forbid(_contractAddr, address(this), bytes4(keccak256("execute(address,bytes)"))); } function proxyOwner() internal returns(address) { return DSAuth(address(this)).owner(); } } library Account { enum Status {Normal, Liquid, Vapor} struct Info { address owner; // The address that owns the account uint256 number; // A nonce that allows a single address to control many accounts } struct Storage { mapping(uint256 => Types.Par) balances; // Mapping from marketId to principal Status status; } } library Actions { enum ActionType { Deposit, // supply tokens Withdraw, // borrow tokens Transfer, // transfer balance between accounts Buy, // buy an amount of some token (public virtually) Sell, // sell an amount of some token (public virtually) Trade, // trade tokens against another account Liquidate, // liquidate an undercollateralized or expiring account Vaporize, // use excess tokens to zero-out a completely negative account Call // send arbitrary data to an address } enum AccountLayout {OnePrimary, TwoPrimary, PrimaryAndSecondary} enum MarketLayout {ZeroMarkets, OneMarket, TwoMarkets} struct ActionArgs { ActionType actionType; uint256 accountId; Types.AssetAmount amount; uint256 primaryMarketId; uint256 secondaryMarketId; address otherAddress; uint256 otherAccountId; bytes data; } struct DepositArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address from; } struct WithdrawArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address to; } struct TransferArgs { Types.AssetAmount amount; Account.Info accountOne; Account.Info accountTwo; uint256 market; } struct BuyArgs { Types.AssetAmount amount; Account.Info account; uint256 makerMarket; uint256 takerMarket; address exchangeWrapper; bytes orderData; } struct SellArgs { Types.AssetAmount amount; Account.Info account; uint256 takerMarket; uint256 makerMarket; address exchangeWrapper; bytes orderData; } struct TradeArgs { Types.AssetAmount amount; Account.Info takerAccount; Account.Info makerAccount; uint256 inputMarket; uint256 outputMarket; address autoTrader; bytes tradeData; } struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; } struct VaporizeArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info vaporAccount; uint256 owedMarket; uint256 heldMarket; } struct CallArgs { Account.Info account; address callee; bytes data; } } library Decimal { struct D256 { uint256 value; } } library Interest { struct Rate { uint256 value; } struct Index { uint96 borrow; uint96 supply; uint32 lastUpdate; } } library Monetary { struct Price { uint256 value; } struct Value { uint256 value; } } library Storage { // All information necessary for tracking a market struct Market { // Contract address of the associated ERC20 token address token; // Total aggregated supply and borrow amount of the entire market Types.TotalPar totalPar; // Interest index of the market Interest.Index index; // Contract address of the price oracle for this market address priceOracle; // Contract address of the interest setter for this market address interestSetter; // Multiplier on the marginRatio for this market Decimal.D256 marginPremium; // Multiplier on the liquidationSpread for this market Decimal.D256 spreadPremium; // Whether additional borrows are allowed for this market bool isClosing; } // The global risk parameters that govern the health and security of the system struct RiskParams { // Required ratio of over-collateralization Decimal.D256 marginRatio; // Percentage penalty incurred by liquidated accounts Decimal.D256 liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal.D256 earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts Monetary.Value minBorrowedValue; } // The maximum RiskParam values that can be set struct RiskLimits { uint64 marginRatioMax; uint64 liquidationSpreadMax; uint64 earningsRateMax; uint64 marginPremiumMax; uint64 spreadPremiumMax; uint128 minBorrowedValueMax; } // The entire storage state of Solo struct State { // number of markets uint256 numMarkets; // marketId => Market mapping(uint256 => Market) markets; // owner => account number => Account mapping(address => mapping(uint256 => Account.Storage)) accounts; // Addresses that can control other users accounts mapping(address => mapping(address => bool)) operators; // Addresses that can control all users accounts mapping(address => bool) globalOperators; // mutable risk parameters of the system RiskParams riskParams; // immutable risk limits of the system RiskLimits riskLimits; } } library Types { enum AssetDenomination { Wei, // the amount is denominated in wei Par // the amount is denominated in par } enum AssetReference { Delta, // the amount is given as a delta from the current value Target // the amount is given as an exact number to end up at } struct AssetAmount { bool sign; // true if positive AssetDenomination denomination; AssetReference ref; uint256 value; } struct TotalPar { uint128 borrow; uint128 supply; } struct Par { bool sign; // true if positive uint128 value; } struct Wei { bool sign; // true if positive uint256 value; } } abstract contract ISoloMargin { struct OperatorArg { address operator; bool trusted; } function ownerSetSpreadPremium( uint256 marketId, Decimal.D256 memory spreadPremium ) public virtual; function getIsGlobalOperator(address operator) public virtual view returns (bool); function getMarketTokenAddress(uint256 marketId) public virtual view returns (address); function ownerSetInterestSetter(uint256 marketId, address interestSetter) public virtual; function getAccountValues(Account.Info memory account) public virtual view returns (Monetary.Value memory, Monetary.Value memory); function getMarketPriceOracle(uint256 marketId) public virtual view returns (address); function getMarketInterestSetter(uint256 marketId) public virtual view returns (address); function getMarketSpreadPremium(uint256 marketId) public virtual view returns (Decimal.D256 memory); function getNumMarkets() public virtual view returns (uint256); function ownerWithdrawUnsupportedTokens(address token, address recipient) public virtual returns (uint256); function ownerSetMinBorrowedValue(Monetary.Value memory minBorrowedValue) public virtual; function ownerSetLiquidationSpread(Decimal.D256 memory spread) public virtual; function ownerSetEarningsRate(Decimal.D256 memory earningsRate) public virtual; function getIsLocalOperator(address owner, address operator) public virtual view returns (bool); function getAccountPar(Account.Info memory account, uint256 marketId) public virtual view returns (Types.Par memory); function ownerSetMarginPremium( uint256 marketId, Decimal.D256 memory marginPremium ) public virtual; function getMarginRatio() public virtual view returns (Decimal.D256 memory); function getMarketCurrentIndex(uint256 marketId) public virtual view returns (Interest.Index memory); function getMarketIsClosing(uint256 marketId) public virtual view returns (bool); function getRiskParams() public virtual view returns (Storage.RiskParams memory); function getAccountBalances(Account.Info memory account) public virtual view returns (address[] memory, Types.Par[] memory, Types.Wei[] memory); function renounceOwnership() public virtual; function getMinBorrowedValue() public virtual view returns (Monetary.Value memory); function setOperators(OperatorArg[] memory args) public virtual; function getMarketPrice(uint256 marketId) public virtual view returns (address); function owner() public virtual view returns (address); function isOwner() public virtual view returns (bool); function ownerWithdrawExcessTokens(uint256 marketId, address recipient) public virtual returns (uint256); function ownerAddMarket( address token, address priceOracle, address interestSetter, Decimal.D256 memory marginPremium, Decimal.D256 memory spreadPremium ) public virtual; function operate( Account.Info[] memory accounts, Actions.ActionArgs[] memory actions ) public virtual; function getMarketWithInfo(uint256 marketId) public virtual view returns ( Storage.Market memory, Interest.Index memory, Monetary.Price memory, Interest.Rate memory ); function ownerSetMarginRatio(Decimal.D256 memory ratio) public virtual; function getLiquidationSpread() public virtual view returns (Decimal.D256 memory); function getAccountWei(Account.Info memory account, uint256 marketId) public virtual view returns (Types.Wei memory); function getMarketTotalPar(uint256 marketId) public virtual view returns (Types.TotalPar memory); function getLiquidationSpreadForPair( uint256 heldMarketId, uint256 owedMarketId ) public virtual view returns (Decimal.D256 memory); function getNumExcessTokens(uint256 marketId) public virtual view returns (Types.Wei memory); function getMarketCachedIndex(uint256 marketId) public virtual view returns (Interest.Index memory); function getAccountStatus(Account.Info memory account) public virtual view returns (uint8); function getEarningsRate() public virtual view returns (Decimal.D256 memory); function ownerSetPriceOracle(uint256 marketId, address priceOracle) public virtual; function getRiskLimits() public virtual view returns (Storage.RiskLimits memory); function getMarket(uint256 marketId) public virtual view returns (Storage.Market memory); function ownerSetIsClosing(uint256 marketId, bool isClosing) public virtual; function ownerSetGlobalOperator(address operator, bool approved) public virtual; function transferOwnership(address newOwner) public virtual; function getAdjustedAccountValues(Account.Info memory account) public virtual view returns (Monetary.Value memory, Monetary.Value memory); function getMarketMarginPremium(uint256 marketId) public virtual view returns (Decimal.D256 memory); function getMarketInterestRate(uint256 marketId) public virtual view returns (Interest.Rate memory); } contract DydxFlashLoanBase { using SafeMath for uint256; address public constant SOLO_MARGIN_ADDRESS = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; function _getMarketIdFromTokenAddress(address token) internal view returns (uint256) { return 0; } function _getRepaymentAmountInternal(uint256 amount) internal view returns (uint256) { // Needs to be overcollateralize // Needs to provide +2 wei to be safe return amount.add(2); } function _getAccountInfo() internal view returns (Account.Info memory) { return Account.Info({owner: address(this), number: 1}); } function _getWithdrawAction(uint marketId, uint256 amount, address contractAddr) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Withdraw, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: contractAddr, otherAccountId: 0, data: "" }); } function _getCallAction(bytes memory data, address contractAddr) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Call, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: 0 }), primaryMarketId: 0, secondaryMarketId: 0, otherAddress: contractAddr, otherAccountId: 0, data: data }); } function _getDepositAction(uint marketId, uint256 amount, address contractAddr) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Deposit, accountId: 0, amount: Types.AssetAmount({ sign: true, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: contractAddr, otherAccountId: 0, data: "" }); } } contract DefisaverLogger { event LogEvent( address indexed contractAddress, address indexed caller, string indexed logName, bytes data ); // solhint-disable-next-line func-name-mixedcase function Log(address _contract, address _caller, string memory _logName, bytes memory _data) public { emit LogEvent(_contract, _caller, _logName, _data); } } abstract contract DSProxyInterface { /// Truffle wont compile if this isn't commented // function execute(bytes memory _code, bytes memory _data) // public virtual // payable // returns (address, bytes32); function execute(address _target, bytes memory _data) public virtual payable returns (bytes32); function setCache(address _cacheAddr) public virtual payable returns (bool); function owner() public virtual returns (address); } abstract contract ProxyRegistryInterface { function proxies(address _owner) public virtual view returns (address); function build(address) public virtual returns (address); } abstract contract TokenInterface { address public constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; function allowance(address, address) public virtual returns (uint256); function balanceOf(address) public virtual returns (uint256); function approve(address, uint256) public virtual; function transfer(address, uint256) public virtual returns (bool); function transferFrom(address, address, uint256) public virtual returns (bool); function deposit() public virtual payable; function withdraw(uint256) public virtual; } contract DFSExchangeData { // first is empty to keep the legacy order in place enum ExchangeType { _, OASIS, KYBER, UNISWAP, ZEROX } enum ActionType { SELL, BUY } struct OffchainData { address wrapper; address exchangeAddr; address allowanceTarget; uint256 price; uint256 protocolFee; bytes callData; } struct ExchangeData { address srcAddr; address destAddr; uint256 srcAmount; uint256 destAmount; uint256 minPrice; uint256 dfsFeeDivider; // service fee divider address user; // user to check special fee address wrapper; bytes wrapperData; OffchainData offchainData; } function packExchangeData(ExchangeData memory _exData) public pure returns(bytes memory) { return abi.encode(_exData); } function unpackExchangeData(bytes memory _data) public pure returns(ExchangeData memory _exData) { _exData = abi.decode(_data, (ExchangeData)); } } /// @title Import Aave position from account to wallet /// @dev Contract needs to have enough wei in WETH for all transactions (2 WETH wei per transaction) contract AaveSaverTakerOV2 is ProxyPermission, GasBurner, DFSExchangeData, AaveHelperV2 { address payable public constant AAVE_RECEIVER = 0x970e34FFcd32D8d514Ef6a54eE53FA1B21087CbA; // leaving _flAmount to be the same as the older version function repay(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) { address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool(); // send msg.value for exchange to the receiver AAVE_RECEIVER.transfer(msg.value); address[] memory assets = new address[](1); assets[0] = _data.srcAddr; uint256[] memory amounts = new uint256[](1); amounts[0] = _data.srcAmount; // for repay we are using regular flash loan with paying back the flash loan + premium uint256[] memory modes = new uint256[](1); modes[0] = 0; // create data bytes memory encodedData = packExchangeData(_data); bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, true, address(this)); // give permission to receiver and execute tx givePermission(AAVE_RECEIVER); ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE); removePermission(AAVE_RECEIVER); } // leaving _flAmount to be the same as the older version function boost(address _market, ExchangeData memory _data, uint _rateMode, uint256 _gasCost, uint _flAmount) public payable burnGas(10) { address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool(); // send msg.value for exchange to the receiver AAVE_RECEIVER.transfer(msg.value); address[] memory assets = new address[](1); assets[0] = _data.srcAddr; uint256[] memory amounts = new uint256[](1); amounts[0] = _data.srcAmount; uint256[] memory modes = new uint256[](1); modes[0] = _rateMode; // create data bytes memory encodedData = packExchangeData(_data); bytes memory data = abi.encode(encodedData, _market, _gasCost, _rateMode, false, address(this)); // give permission to receiver and execute tx givePermission(AAVE_RECEIVER); ILendingPoolV2(lendingPool).flashLoan(AAVE_RECEIVER, assets, amounts, modes, address(this), data, AAVE_REFERRAL_CODE); removePermission(AAVE_RECEIVER); } }
0x60806040526004361061011f5760003560e01c8063526d6461116100a0578063a3b8e5d111610064578063a3b8e5d1146102b2578063b98b934d146102df578063c91d59fe146102f2578063d4f922dc14610307578063e074bb471461031c5761011f565b8063526d6461146102495780637753f47b1461025e5780637b925ab114610273578063870e44d9146102885780638823151b1461029d5761011f565b80630f57eff4116100e75780630f57eff4146101d55780632ba38bcb146101ea5780633d391f70146101ff578063469048401461021f5780634d2ab9dc146102345761011f565b8063040141e51461012457806304c9805c1461014f57806305a363de1461017157806306f9c35c1461019357806308d4f52a146101a8575b600080fd5b34801561013057600080fd5b5061013961033c565b604051610146919061143e565b60405180910390f35b34801561015b57600080fd5b50610164610354565b6040516101469190611662565b34801561017d57600080fd5b5061018661035a565b6040516101469190611653565b34801561019f57600080fd5b5061013961035f565b3480156101b457600080fd5b506101c86101c336600461121b565b610377565b6040516101469190611537565b6101e86101e3366004611157565b6103a0565b005b3480156101f657600080fd5b50610164610738565b34801561020b57600080fd5b506101e861021a366004611118565b61073d565b34801561022b57600080fd5b50610139610928565b34801561024057600080fd5b50610164610940565b34801561025557600080fd5b50610139610946565b34801561026a57600080fd5b5061013961095e565b34801561027f57600080fd5b50610139610976565b34801561029457600080fd5b5061016461098e565b3480156102a957600080fd5b5061013961099a565b3480156102be57600080fd5b506102d26102cd3660046111e0565b6109b2565b6040516101469190611597565b6101e86102ed366004611157565b6109d4565b3480156102fe57600080fd5b50610139610c94565b34801561031357600080fd5b50610164610ca7565b34801561032857600080fd5b506101e8610337366004611118565b610cac565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b61014d81565b604081565b73970e34ffcd32d8d514ef6a54ee53fa1b21087cba81565b60608160405160200161038a9190611597565b6040516020818303038152906040529050919050565b6040516370a0823160e01b8152600a9081906eb3f879cb30fe243b4dfee438691c04906370a08231906103d790309060040161143e565b60206040518083038186803b1580156103ef57600080fd5b505afa158015610403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104279190611356565b106104b25760405163d8ccd0f360e01b81526eb3f879cb30fe243b4dfee438691c049063d8ccd0f39061045e908490600401611662565b602060405180830381600087803b15801561047857600080fd5b505af115801561048c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b091906111c0565b505b6000866001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156104ed57600080fd5b505afa158015610501573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610525919061113b565b60405190915073970e34ffcd32d8d514ef6a54ee53fa1b21087cba903480156108fc02916000818181858888f19350505050158015610568573d6000803e3d6000fd5b506040805160018082528183019092526060916020808301908036833701905050905086600001518160008151811061059d57fe5b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526060918160200160208202803683370190505090508760400151816000815181106105ec57fe5b602090810291909101015260408051600180825281830190925260609181602001602082028036833701905050905060008160008151811061062a57fe5b60200260200101818152505060606106418a610377565b90506060818c8a8c6001306040516020016106619695949392919061154a565b604051602081830303815290604052905061068f73970e34ffcd32d8d514ef6a54ee53fa1b21087cba61073d565b6040805163ab9c4b5d60e01b81526001600160a01b0388169163ab9c4b5d916106db9173970e34ffcd32d8d514ef6a54ee53fa1b21087cba918a918a918a9130918a9190600401611452565b600060405180830381600087803b1580156106f557600080fd5b505af1158015610709573d6000803e3d6000fd5b5050505061072a73970e34ffcd32d8d514ef6a54ee53fa1b21087cba610cac565b505050505050505050505050565b600181565b6000306001600160a01b031663bf7e214f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561077857600080fd5b505afa15801561078c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b0919061113b565b9050806001600160a01b0381166108a157735a15566417e6c1c9546523066500bddbc53f88c76001600160a01b03166365688cc96040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561081057600080fd5b505af1158015610824573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610848919061113b565b604051637a9e5e4b60e01b81529091503090637a9e5e4b9061086e90849060040161143e565b600060405180830381600087803b15801561088857600080fd5b505af115801561089c573d6000803e3d6000fd5b505050505b6040516332fba9a360e21b81526001600160a01b0382169063cbeea68c906108f190869030907f1cff79cde515a86f6cc1adbebe8ae25888905561371faf11c8102211f56b48709060040161150a565b600060405180830381600087803b15801561090b57600080fd5b505af115801561091f573d6000803e3d6000fd5b50505050505050565b7339c4a92dc506300c3ea4c67ca4ca611102ee6f2a81565b61019081565b73637726f8b08a7abe3ae3acab01a80e2d8ddef77b81565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b731b14e8d511c9a4395425314f849bd737baf8208f81565b670dbd2fc137a3000081565b735a15566417e6c1c9546523066500bddbc53f88c781565b6109ba610d8a565b818060200190518101906109ce919061124e565b92915050565b6040516370a0823160e01b8152600a9081906eb3f879cb30fe243b4dfee438691c04906370a0823190610a0b90309060040161143e565b60206040518083038186803b158015610a2357600080fd5b505afa158015610a37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5b9190611356565b10610ae65760405163d8ccd0f360e01b81526eb3f879cb30fe243b4dfee438691c049063d8ccd0f390610a92908490600401611662565b602060405180830381600087803b158015610aac57600080fd5b505af1158015610ac0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae491906111c0565b505b6000866001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2157600080fd5b505afa158015610b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b59919061113b565b60405190915073970e34ffcd32d8d514ef6a54ee53fa1b21087cba903480156108fc02916000818181858888f19350505050158015610b9c573d6000803e3d6000fd5b5060408051600180825281830190925260609160208083019080368337019050509050866000015181600081518110610bd157fe5b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252606091816020016020820280368337019050509050876040015181600081518110610c2057fe5b60209081029190910101526040805160018082528183019092526060918160200160208202803683370190505090508781600081518110610c5d57fe5b6020026020010181815250506060610c748a610377565b90506060818c8a8c6000306040516020016106619695949392919061154a565b6eb3f879cb30fe243b4dfee438691c0481565b600281565b6000306001600160a01b031663bf7e214f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ce757600080fd5b505afa158015610cfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1f919061113b565b90506001600160a01b038116610d355750610d87565b604051632bc3217d60e01b815281906001600160a01b03821690632bc3217d906108f190869030907f1cff79cde515a86f6cc1adbebe8ae25888905561371faf11c8102211f56b48709060040161150a565b50565b60405180610140016040528060006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160608152602001610e01610e06565b905290565b6040518060c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b80356109ce816116e6565b80516109ce816116e6565b600082601f830112610e7d578081fd5b8135610e90610e8b82611692565b61166b565b9150808252836020828501011115610ea757600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112610ed0578081fd5b8151610ede610e8b82611692565b9150808252836020828501011115610ef557600080fd5b610f068160208401602086016116b6565b5092915050565b6000610140808385031215610f20578182fd5b610f298161166b565b915050610f368383610e57565b8152610f458360208401610e57565b602082015260408201356040820152606082013560608201526080820135608082015260a082013560a0820152610f7f8360c08401610e57565b60c0820152610f918360e08401610e57565b60e08201526101008083013567ffffffffffffffff80821115610fb357600080fd5b610fbf86838701610e6d565b83850152610120925082850135915080821115610fdb57600080fd5b50610fe885828601610ff4565b82840152505092915050565b600060c08284031215611005578081fd5b61100f60c061166b565b9050813561101c816116e6565b8152602082013561102c816116e6565b6020820152604082013561103f816116e6565b80604083015250606082013560608201526080820135608082015260a082013567ffffffffffffffff81111561107457600080fd5b61108084828501610e6d565b60a08301525092915050565b600060c0828403121561109d578081fd5b6110a760c061166b565b905081516110b4816116e6565b815260208201516110c4816116e6565b602082015260408201516110d7816116e6565b80604083015250606082015160608201526080820151608082015260a082015167ffffffffffffffff81111561110c57600080fd5b61108084828501610ec0565b600060208284031215611129578081fd5b8135611134816116e6565b9392505050565b60006020828403121561114c578081fd5b8151611134816116e6565b600080600080600060a0868803121561116e578081fd5b8535611179816116e6565b9450602086013567ffffffffffffffff811115611194578182fd5b6111a088828901610f0d565b959895975050505060408401359360608101359360809091013592509050565b6000602082840312156111d1578081fd5b81518015158114611134578182fd5b6000602082840312156111f1578081fd5b813567ffffffffffffffff811115611207578182fd5b61121384828501610e6d565b949350505050565b60006020828403121561122c578081fd5b813567ffffffffffffffff811115611242578182fd5b61121384828501610f0d565b60006020828403121561125f578081fd5b815167ffffffffffffffff80821115611276578283fd5b818401915061014080838703121561128c578384fd5b6112958161166b565b90506112a18684610e62565b81526112b08660208501610e62565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a08201526112ea8660c08501610e62565b60c08201526112fc8660e08501610e62565b60e08201526101008084015183811115611314578586fd5b61132088828701610ec0565b8284015250506101208084015183811115611339578586fd5b6113458882870161108c565b918301919091525095945050505050565b600060208284031215611367578081fd5b5051919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156113aa5781518752958201959082019060010161138e565b509495945050505050565b600081518084526113cd8160208601602086016116b6565b601f01601f19169290920160200192915050565b600060018060a01b0380835116845280602084015116602085015280604084015116604085015250606082015160608401526080820151608084015260a082015160c060a085015261121360c08501826113b5565b61ffff169052565b6001600160a01b0391909116815260200190565b6001600160a01b038816815260e0602080830182905288519183018290526000918982019190610100850190845b818110156114a35761149383865161136e565b9383019391830191600101611480565b505084810360408601526114b7818b61137b565b9250505082810360608401526114cd818861137b565b90506114dc608084018761136e565b82810360a08401526114ee81866113b5565b9150506114fe60c0830184611436565b98975050505050505050565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b60006020825261113460208301846113b5565b600060c0825261155d60c08301896113b5565b6001600160a01b0397881660208401526040830196909652506060810193909352901515608083015290921660a090920191909152919050565b6000602082526115ab60208301845161136e565b60208301516115bd604084018261136e565b506040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c08301516115f860e084018261136e565b5060e083015161010061160d8185018361136e565b80850151915050610140610120818186015261162d6101608601846113b5565b90860151858203601f19018387015290925061164983826113e1565b9695505050505050565b61ffff91909116815260200190565b90815260200190565b60405181810167ffffffffffffffff8111828210171561168a57600080fd5b604052919050565b600067ffffffffffffffff8211156116a8578081fd5b50601f01601f191660200190565b60005b838110156116d15781810151838201526020016116b9565b838111156116e0576000848401525b50505050565b6001600160a01b0381168114610d8757600080fdfea2646970667358221220603648be94231bbf0aa32706e367760ff4aacf496a55b419c4cf2c81f5cfe14164736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}, {"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': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 14142, 2620, 2278, 20958, 2575, 2683, 22407, 2098, 17788, 2546, 2509, 2050, 24434, 25062, 26005, 16048, 2581, 2620, 22414, 2094, 26224, 2620, 2278, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 3206, 16233, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 17788, 2575, 1060, 1010, 21318, 3372, 17788, 2575, 1061, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1062, 1007, 1063, 5478, 1006, 1006, 1062, 1027, 1060, 1009, 1061, 1007, 1028, 1027, 1060, 1007, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 17788, 2575, 1060, 1010, 21318, 3372, 17788, 2575, 1061, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1062, 1007, 1063, 5478, 1006, 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,947
0x97a30C692eCe9C317235d48287d23d358170FC40
// SPDX-License-Identifier: UNLICENSED /** *Submitted for verification at Etherscan.io on 2019-06-10 */ pragma solidity 0.8.11; /// @title Multicall - Aggregate results from multiple read-only function calls /// @author Michael Elliot <[email protected]> /// @author Joshua Levine <[email protected]> /// @author Nick Johnson <[email protected]> contract Multicall { struct Call { address target; bytes callData; } function aggregate(Call[] memory calls) external view returns (uint256 blockNumber, bytes[] memory returnData, bool[] memory results) { blockNumber = block.number; returnData = new bytes[](calls.length); results = new bool[](calls.length); for(uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory ret) = calls[i].target.staticcall(calls[i].callData); results[i] = success; returnData[i] = ret; } } // Helper functions function getEthBalance(address addr) external view returns (uint256 balance) { balance = addr.balance; } function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash) { blockHash = blockhash(blockNumber); } function getLastBlockHash() public view returns (bytes32 blockHash) { blockHash = blockhash(block.number - 1); } function getCurrentBlockTimestamp() external view returns (uint256 timestamp) { timestamp = block.timestamp; } function getCurrentBlockDifficulty() external view returns (uint256 difficulty) { difficulty = block.difficulty; } function getCurrentBlockGasLimit() external view returns (uint256 gaslimit) { gaslimit = block.gaslimit; } function getCurrentBlockCoinbase() external view returns (address coinbase) { coinbase = block.coinbase; } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d146100e757806386d516e8146100ed578063a8b0574e146100f3578063ee82ac5e1461010157600080fd5b80630f28c97d1461008d578063252dba42146100a257806327e86d6e146100c45780634d2301cc146100cc575b600080fd5b425b6040519081526020015b60405180910390f35b6100b56100b0366004610356565b610113565b60405161009993929190610521565b61008f6102b7565b61008f6100da3660046105b6565b6001600160a01b03163190565b4461008f565b4561008f565b604051418152602001610099565b61008f61010f3660046105d8565b4090565b6000606080439250835167ffffffffffffffff811115610135576101356102ca565b60405190808252806020026020018201604052801561016857816020015b60608152602001906001900390816101535790505b509150835167ffffffffffffffff811115610185576101856102ca565b6040519080825280602002602001820160405280156101ae578160200160208202803683370190505b50905060005b84518110156102af576000808683815181106101d2576101d26105f1565b6020026020010151600001516001600160a01b03168784815181106101f9576101f96105f1565b6020026020010151602001516040516102129190610607565b600060405180830381855afa9150503d806000811461024d576040519150601f19603f3d011682016040523d82523d6000602084013e610252565b606091505b50915091508184848151811061026a5761026a6105f1565b6020026020010190151590811515815250508085848151811061028f5761028f6105f1565b6020026020010181905250505080806102a790610639565b9150506101b4565b509193909250565b60006102c4600143610654565b40905090565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610303576103036102ca565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610332576103326102ca565b604052919050565b80356001600160a01b038116811461035157600080fd5b919050565b6000602080838503121561036957600080fd5b823567ffffffffffffffff8082111561038157600080fd5b818501915085601f83011261039557600080fd5b8135818111156103a7576103a76102ca565b8060051b6103b6858201610309565b91825283810185019185810190898411156103d057600080fd5b86860192505b838310156104a7578235858111156103ee5760008081fd5b86016040601f19828d0381018213156104075760008081fd5b61040f6102e0565b61041a8b850161033a565b8152828401358981111561042e5760008081fd5b8085019450508d603f8501126104445760008081fd5b8a84013589811115610458576104586102ca565b6104688c84601f84011601610309565b92508083528e8482870101111561047f5760008081fd5b808486018d85013760009083018c0152808b01919091528452505091860191908601906103d6565b9998505050505050505050565b60005b838110156104cf5781810151838201526020016104b7565b838111156104de576000848401525b50505050565b600081518084526020808501945080840160005b838110156105165781511515875295820195908201906001016104f8565b509495945050505050565b600060608201858352602060608185015281865180845260808601915060808160051b870101935082880160005b8281101561059557878603607f190184528151805180885261057681888a018985016104b4565b601f01601f19169690960185019550928401929084019060010161054f565b505050505082810360408401526105ac81856104e4565b9695505050505050565b6000602082840312156105c857600080fd5b6105d18261033a565b9392505050565b6000602082840312156105ea57600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b600082516106198184602087016104b4565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b600060001982141561064d5761064d610623565b5060010190565b60008282101561066657610666610623565b50039056fea2646970667358221220ab1e03b567c8b76408575f5318ece2b5558cc5f95ad01308e8877e2a47eb55bf64736f6c634300080b0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 14142, 2278, 2575, 2683, 2475, 26005, 2683, 2278, 21486, 2581, 21926, 2629, 2094, 18139, 22407, 2581, 2094, 21926, 2094, 19481, 2620, 16576, 2692, 11329, 12740, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 10476, 1011, 5757, 1011, 2184, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 2340, 1025, 1013, 1013, 1013, 1030, 2516, 4800, 9289, 2140, 1011, 9572, 3463, 2013, 3674, 3191, 1011, 2069, 3853, 4455, 1013, 1013, 1013, 1030, 3166, 2745, 11759, 1026, 1031, 10373, 5123, 1033, 1028, 1013, 1013, 1013, 1030, 3166, 9122, 17780, 1026, 1031, 10373, 5123, 1033, 1028, 1013, 1013, 1013, 1030, 3166, 4172, 3779, 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,948
0x97A339E049F1725c21381A55F28b907Bd2906b8b
// File: TestContracts/ProxyTarget.sol pragma solidity 0.8.7; /// @dev Proxy for NFT Factory contract ProxyTarget { // Storage for this proxy bytes32 internal constant IMPLEMENTATION_SLOT = bytes32(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc); bytes32 internal constant ADMIN_SLOT = bytes32(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103); function _getAddress(bytes32 key) internal view returns (address add) { add = address(uint160(uint256(_getSlotValue(key)))); } function _getSlotValue(bytes32 slot_) internal view returns (bytes32 value_) { assembly { value_ := sload(slot_) } } function _setSlotValue(bytes32 slot_, bytes32 value_) internal { assembly { sstore(slot_, value_) } } } // File: base/IVRF.sol //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; interface IVRF{ function initiateRandomness(uint _tokenId,uint _timestamp) external view returns(uint); function stealRandomness() external view returns(uint); function getCurrentIndex() external view returns(uint); } // File: base/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: base/IWhitelist.sol pragma solidity ^0.8.0; interface IWhitelist{ struct Whitelist{ address userAddress; bytes signature; } function getSigner(Whitelist memory whitelist) external view returns(address); } // File: base/IGameEngine.sol pragma solidity ^0.8.0; interface GameEngine{ function stake ( uint tokenId ) external; function alertStake (uint tokenId) external; } // File: base/IMetadata.sol pragma solidity ^0.8.0; interface IMetadata{ function addMetadata(uint8 tokenType,uint8 level,uint tokenID) external; function createRandomZombie(uint8 level) external returns(uint8[] memory traits); function createRandomSurvivor(uint8 level) external returns(uint8[] memory traits); function getTokenURI(uint tokenId) external view returns (string memory); function changeNft(uint tokenID, uint8 nftType, uint8 level, bool canClaim, uint stakedTime, uint lastClaimTime) external; function getToken(uint256 _tokenId) external view returns(uint8, uint8, bool, uint,uint); } // File: base/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, uint tokenId, bytes calldata data ) external returns (bytes4); } // File: base/IERC165.sol pragma solidity ^0.8.0; 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: base/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: base/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(uint tokenId) external view returns (string memory); } // File: base/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: base/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint` to its ASCII `string` decimal representation. */ function toString(uint 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"; } uint temp = value; uint digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint` to its ASCII `string` hexadecimal representation. */ function toHexString(uint value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint temp = value; uint length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint value, uint length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint 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: base/Address.sol pragma solidity ^0.8.0; 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: base/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); function burn(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: base/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 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 () {} function _msgSender() internal view returns (address payable) { return payable (msg.sender); } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: base/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}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint; // Token name string internal _name; // Token symbol string internal _symbol; // Mapping from token ID to owner address mapping(uint => address) private _owners; // Mapping owner address to token count mapping(address => uint) private _balances; // Mapping from token ID to approved address mapping(uint => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @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 (uint) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint 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(uint 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, uint 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(uint 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, uint 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, uint tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint 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, uint 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(uint 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, uint 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, uint tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint 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, uint 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(uint 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, uint 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, uint 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 uint 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, uint 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, uint tokenId ) internal virtual {} } // File: base/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. */ contract Ownable is Context { address internal _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 onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: TestContracts/testnftFactory.sol /** * Author : Lil Ye, Ace, Anyx, Elmontos */ pragma solidity ^0.8.0; contract testNftFactory is Ownable, ERC721, ProxyTarget { using Strings for uint; ////nfts mapping (uint => address) public tokenOwner; mapping (uint=>uint) public actionTimestamp; //COUNTS using Counters for Counters.Counter; Counters.Counter private tokenId_; //SALES bool public isPresale = true; uint public SUP_THRESHOLD = 10000; //todo place the finalised price // To-change -> from 0 eth to 0.069 eth uint public HungerBrainz_MAINSALE_PRICE = 0.069 ether; //priceInMainSale mapping(address=>uint) public userPurchase; //AMOUNT uint[2] public amount; //CONTRACT GameEngine game; IERC20 SUP; IWhitelist whitelist; IMetadata metadataHandler; IVRF randomNumberGenerated; function initialize(address _gameAddress, address _tokenAddress,address _whitelist,address _metadata,address _vrf) external { require(msg.sender == _getAddress(ADMIN_SLOT), "not admin"); _name = "HungerBrainz"; _symbol = "HBZ"; _owner = msg.sender; HungerBrainz_MAINSALE_PRICE = 0.069 ether; isPresale = true; SUP_THRESHOLD = 10000; game = GameEngine(_gameAddress); SUP = IERC20(_tokenAddress); whitelist = IWhitelist(_whitelist); metadataHandler = IMetadata(_metadata); randomNumberGenerated = IVRF(_vrf); } function currentTokenID() external view returns(uint){ return tokenId_.current(); } function tokenOwnerSetter(uint tokenId, address owner_) external { require(_msgSender() == address(game)); tokenOwner[tokenId] = owner_; } function setContract(address _gameAddress, address _tokenAddress,address _whitelist,address _metadata,address _vrf) external onlyOwner { game = GameEngine(_gameAddress); SUP = IERC20(_tokenAddress); whitelist = IWhitelist(_whitelist); metadataHandler = IMetadata(_metadata); randomNumberGenerated = IVRF(_vrf); } function burnNFT(uint tokenId) external { require (_msgSender() == address(game), "Not GameAddress"); //console.log("Tries burning"); _burn(tokenId); } function setTimeStamp(uint tokenId) external { require(msg.sender == address(game)); actionTimestamp[tokenId] = randomNumberGenerated.getCurrentIndex(); } function setPresale(bool presale) external onlyOwner{ isPresale = presale; } function setSupThreshold(uint newThreshold) external onlyOwner { SUP_THRESHOLD = newThreshold; } function buyAndStake(bool stake,uint8 tokenType, uint tokenAmount,address receiver) external payable { // By calling this function, you agreed that you have read and accepted the terms & conditions // available at this link: https://hungerbrainz.com/terms require (HungerBrainz_MAINSALE_PRICE*tokenAmount >= msg.value, "INSUFFICIENT_ETH"); require(tokenType < 2,"Invalid type"); require(tokenId_.current() <= SUP_THRESHOLD,"Buy using SUP"); if(isPresale){ require(msg.sender == address(whitelist),"Not whitelisted"); require(userPurchase[receiver] + tokenAmount <= 3,"Purchase limit"); } else{ require(msg.sender != address(whitelist),"Not presale"); require(userPurchase[msg.sender] + tokenAmount <= 13,"Purchase limit"); receiver = msg.sender; } if (isApprovedForAll(_msgSender(),address(game))==false) { setApprovalForAll(address(game), true); } amount[tokenType] = amount[tokenType]+tokenAmount; userPurchase[receiver] += tokenAmount; if(stake) for (uint i=0; i<tokenAmount; i++) { tokenId_.increment(); _safeMint(address(game),tokenId_.current()); metadataHandler.addMetadata(1,tokenType,tokenId_.current()); tokenOwner[tokenId_.current()] = receiver; game.alertStake(tokenId_.current()); } else{ for (uint i =0;i<tokenAmount;i++) { tokenId_.increment(); _safeMint(receiver, tokenId_.current()); metadataHandler.addMetadata(1,tokenType,tokenId_.current()); tokenOwner[tokenId_.current()]=receiver; } } } function buyUsingSUPAndStake(bool stake, uint8 tokenType, uint tokenAmount) external { // By calling this function, you agreed that you have read and accepted the terms & conditions // available at this link: https://hungerbrainz.com/terms require(tokenType < 2,"Invalid type"); require(tokenId_.current() > SUP_THRESHOLD,"Buy using Eth"); SUP.transferFrom(_msgSender(), address(this), tokenAmount*1000 ether); SUP.burn(tokenAmount* 1000 ether); //1000 ether amount[tokenType] = amount[tokenType]+tokenAmount; for (uint i=0; i< tokenAmount; i++) { if (stake) { tokenId_.increment(); _safeMint(address(game), tokenId_.current()); metadataHandler.addMetadata(1,tokenType,tokenId_.current()); game.alertStake(tokenId_.current()); } else { tokenId_.increment(); _safeMint(msg.sender,tokenId_.current()); metadataHandler.addMetadata(1,tokenType,tokenId_.current()); } tokenOwner[tokenId_.current()]=msg.sender; } } function tokenOwnerCall(uint tokenId) external view returns (address) { return tokenOwner[tokenId]; } function withdraw() external { uint balance = address(this).balance; require(balance > 0); address payable _devAddress = payable (0x3384392f12f90C185a43861E0547aFF77BD5134A); uint devFees = (balance*(10))/(100); _devAddress.transfer(devFees); payable(owner()).transfer(address(this).balance); } //Better if Game Address directly calls metadata contract function restrictedChangeNft(uint tokenID, uint8 nftType, uint8 level, bool canClaim, uint stakedTime, uint lastClaimTime) external { require(msg.sender == address(game),"Call restricted"); metadataHandler.changeNft(tokenID,nftType,level,canClaim,stakedTime,lastClaimTime); } //#endregion function tokenURI(uint tokenId) public view override(ERC721) returns (string memory) { require(_exists(tokenId), "Cannot query non-existent token"); return metadataHandler.getTokenURI(tokenId); } function setHungerBrainz_MAINSALE_PRICE(uint _price) external onlyOwner{ HungerBrainz_MAINSALE_PRICE = _price; } function _transfer( address from, address to, uint tokenId ) internal override{ if(to!=address(game) && to!=tokenOwner[tokenId]){ tokenOwner[tokenId] = to; } super._transfer(from,to,tokenId); } function _mint(address to, uint tokenId) internal override{ super._mint(to,tokenId); actionTimestamp[tokenId] = randomNumberGenerated.getCurrentIndex(); } function _burn(uint tokenId) internal override { (uint8 nftType,,,,)=metadataHandler.getToken(tokenId); amount[nftType]--; tokenOwner[tokenId] = address(0); super._burn(tokenId); } }
0x60806040526004361061021a5760003560e01c80638da5cb5b11610123578063bb62115e116100ab578063e985e9c51161006f578063e985e9c5146107e0578063f1525e401461081d578063f2fde38b14610848578063f48238b414610871578063fe92404a1461089c5761021a565b8063bb62115e146106e9578063c2eb275c14610714578063c378a9771461073d578063c54e73e31461077a578063c87b56dd146107a35761021a565b8063a22cb465116100f2578063a22cb46514610608578063b484eff714610631578063b88d4fde1461066e578063b894223b14610697578063ba7133f9146106c05761021a565b80638da5cb5b1461055e578063952b1f6b1461058957806395364a84146105b257806395d89b41146105dd5761021a565b80632257c0e2116101a657806342842e0e1161017557806342842e0e146104675780636352211e1461049057806370a08231146104cd578063715018a61461050a5780638b0d0258146105215761021a565b80632257c0e2146103c157806323b872dd146103fe5780632890e0d7146104275780633ccfd60b146104505761021a565b80630b1b806b116101ed5780630b1b806b146102ed57806313e43bc6146103095780631459457a146103325780631caaa4871461035b57806320eb2a87146103985761021a565b806301ffc9a71461021f57806306fdde031461025c578063081812fc14610287578063095ea7b3146102c4575b600080fd5b34801561022b57600080fd5b5061024660048036038101906102419190614130565b6108c5565b604051610253919061486d565b60405180910390f35b34801561026857600080fd5b506102716109a7565b60405161027e91906148bf565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a991906141d3565b610a39565b6040516102bb91906147cf565b60405180910390f35b3480156102d057600080fd5b506102eb60048036038101906102e69190613fdc565b610abe565b005b610307600480360381019061030291906140c9565b610bd6565b005b34801561031557600080fd5b50610330600480360381019061032b91906141d3565b611346565b005b34801561033e57600080fd5b5061035960048036038101906103549190613e4b565b61145a565b005b34801561036757600080fd5b50610382600480360381019061037d91906141d3565b611749565b60405161038f91906147cf565b60405180910390f35b3480156103a457600080fd5b506103bf60048036038101906103ba9190613e4b565b61177c565b005b3480156103cd57600080fd5b506103e860048036038101906103e391906141d3565b61195d565b6040516103f59190614c21565b60405180910390f35b34801561040a57600080fd5b5061042560048036038101906104209190613ec6565b611975565b005b34801561043357600080fd5b5061044e600480360381019061044991906141d3565b6119d5565b005b34801561045c57600080fd5b50610465611a78565b005b34801561047357600080fd5b5061048e60048036038101906104899190613ec6565b611b5a565b005b34801561049c57600080fd5b506104b760048036038101906104b291906141d3565b611b7a565b6040516104c491906147cf565b60405180910390f35b3480156104d957600080fd5b506104f460048036038101906104ef9190613dde565b611c2c565b6040516105019190614c21565b60405180910390f35b34801561051657600080fd5b5061051f611ce4565b005b34801561052d57600080fd5b50610548600480360381019061054391906141d3565b611e37565b6040516105559190614c21565b60405180910390f35b34801561056a57600080fd5b50610573611e52565b60405161058091906147cf565b60405180910390f35b34801561059557600080fd5b506105b060048036038101906105ab91906141d3565b611e7b565b005b3480156105be57600080fd5b506105c7611f1a565b6040516105d4919061486d565b60405180910390f35b3480156105e957600080fd5b506105f2611f2d565b6040516105ff91906148bf565b60405180910390f35b34801561061457600080fd5b5061062f600480360381019061062a9190613f9c565b611fbf565b005b34801561063d57600080fd5b5061065860048036038101906106539190613dde565b612140565b6040516106659190614c21565b60405180910390f35b34801561067a57600080fd5b5061069560048036038101906106909190613f19565b612158565b005b3480156106a357600080fd5b506106be60048036038101906106b9919061422d565b6121ba565b005b3480156106cc57600080fd5b506106e760048036038101906106e291906141d3565b612271565b005b3480156106f557600080fd5b506106fe612310565b60405161070b9190614c21565b60405180910390f35b34801561072057600080fd5b5061073b60048036038101906107369190614076565b612321565b005b34801561074957600080fd5b50610764600480360381019061075f91906141d3565b612836565b60405161077191906147cf565b60405180910390f35b34801561078657600080fd5b506107a1600480360381019061079c919061401c565b612873565b005b3480156107af57600080fd5b506107ca60048036038101906107c591906141d3565b612925565b6040516107d791906148bf565b60405180910390f35b3480156107ec57600080fd5b5061080760048036038101906108029190613e0b565b612a26565b604051610814919061486d565b60405180910390f35b34801561082957600080fd5b50610832612aba565b60405161083f9190614c21565b60405180910390f35b34801561085457600080fd5b5061086f600480360381019061086a9190613dde565b612ac0565b005b34801561087d57600080fd5b50610886612b61565b6040516108939190614c21565b60405180910390f35b3480156108a857600080fd5b506108c360048036038101906108be919061426d565b612b67565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061099057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806109a0575061099f82612c96565b5b9050919050565b6060600180546109b690614fa6565b80601f01602080910402602001604051908101604052809291908181526020018280546109e290614fa6565b8015610a2f5780601f10610a0457610100808354040283529160200191610a2f565b820191906000526020600020905b815481529060010190602001808311610a1257829003601f168201915b5050505050905090565b6000610a4482612d00565b610a83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7a90614ac1565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610ac982611b7a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3190614b61565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b59612d6c565b73ffffffffffffffffffffffffffffffffffffffff161480610b885750610b8781610b82612d6c565b612a26565b5b610bc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbe906149c1565b60405180910390fd5b610bd18383612d74565b505050565b3482600c54610be59190614de3565b1015610c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1d90614c01565b60405180910390fd5b60028360ff1610610c6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6390614bc1565b60405180910390fd5b600b54610c796009612e2d565b1115610cba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb190614b41565b60405180910390fd5b600a60009054906101000a900460ff1615610df257601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d56906149e1565b60405180910390fd5b600382600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610dac9190614d5c565b1115610ded576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de490614a61565b60405180910390fd5b610f15565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610e83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7a90614a81565b60405180910390fd5b600d82600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ed09190614d5c565b1115610f11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0890614a61565b60405180910390fd5b3390505b60001515610f4c610f24612d6c565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612a26565b15151415610f8257610f81601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166001611fbf565b5b81600e8460ff1660028110610f9a57610f996150df565b5b0154610fa69190614d5c565b600e8460ff1660028110610fbd57610fbc6150df565b5b018190555081600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546110119190614d5c565b92505081905550831561120d5760005b82811015611207576110336009612e3b565b611068601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166110636009612e2d565b612e51565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635aa4fc2f6001866110b36009612e2d565b6040518463ffffffff1660e01b81526004016110d193929190614888565b600060405180830381600087803b1580156110eb57600080fd5b505af11580156110ff573d6000803e3d6000fd5b5050505081600760006111126009612e2d565b815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638f8e93246111a66009612e2d565b6040518263ffffffff1660e01b81526004016111c29190614c21565b600060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b5050505080806111ff90615009565b915050611021565b50611340565b60005b8281101561133e576112226009612e3b565b611235826112306009612e2d565b612e51565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635aa4fc2f6001866112806009612e2d565b6040518463ffffffff1660e01b815260040161129e93929190614888565b600060405180830381600087803b1580156112b857600080fd5b505af11580156112cc573d6000803e3d6000fd5b5050505081600760006112df6009612e2d565b815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808061133690615009565b915050611210565b505b50505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113a057600080fd5b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d9005ae6040518163ffffffff1660e01b815260040160206040518083038186803b15801561140857600080fd5b505afa15801561141c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114409190614200565b600860008381526020019081526020016000208190555050565b6114867fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b612e6f565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ea90614be1565b60405180910390fd5b6040518060400160405280600c81526020017f48756e676572427261696e7a00000000000000000000000000000000000000008152506001908051906020019061153e929190613b9e565b506040518060400160405280600381526020017f48425a00000000000000000000000000000000000000000000000000000000008152506002908051906020019061158a929190613b9e565b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555066f5232269808000600c819055506001600a60006101000a81548160ff021916908315150217905550612710600b8190555084601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050505050565b60076020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611784612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180890614ae1565b60405180910390fd5b84601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050505050565b60086020528060005260406000206000915090505481565b611986611980612d6c565b82612e84565b6119c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119bc90614b81565b60405180910390fd5b6119d0838383612f62565b505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611a16612d6c565b73ffffffffffffffffffffffffffffffffffffffff1614611a6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6390614941565b60405180910390fd5b611a7581613087565b50565b600047905060008111611a8a57600080fd5b6000733384392f12f90c185a43861e0547aff77bd5134a905060006064600a84611ab49190614de3565b611abe9190614db2565b90508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611b06573d6000803e3d6000fd5b50611b0f611e52565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611b54573d6000803e3d6000fd5b50505050565b611b7583838360405180602001604052806000815250612158565b505050565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c1a90614a21565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9490614a01565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611cec612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7090614ae1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600e8160028110611e4757600080fd5b016000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611e83612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611f10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f0790614ae1565b60405180910390fd5b80600b8190555050565b600a60009054906101000a900460ff1681565b606060028054611f3c90614fa6565b80601f0160208091040260200160405190810160405280929190818152602001828054611f6890614fa6565b8015611fb55780601f10611f8a57610100808354040283529160200191611fb5565b820191906000526020600020905b815481529060010190602001808311611f9857829003601f168201915b5050505050905090565b611fc7612d6c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612035576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161202c90614981565b60405180910390fd5b8060066000612042612d6c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166120ef612d6c565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612134919061486d565b60405180910390a35050565b600d6020528060005260406000206000915090505481565b612169612163612d6c565b83612e84565b6121a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219f90614b81565b60405180910390fd5b6121b4848484846131c8565b50505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166121fb612d6c565b73ffffffffffffffffffffffffffffffffffffffff161461221b57600080fd5b806007600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b612279612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612306576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122fd90614ae1565b60405180910390fd5b80600c8190555050565b600061231c6009612e2d565b905090565b60028260ff1610612367576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161235e90614bc1565b60405180910390fd5b600b546123746009612e2d565b116123b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ab90614ba1565b60405180910390fd5b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd6123fa612d6c565b30683635c9adc5dea00000856124109190614de3565b6040518463ffffffff1660e01b815260040161242e939291906147ea565b602060405180830381600087803b15801561244857600080fd5b505af115801561245c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124809190614049565b50601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68683635c9adc5dea00000836124d49190614de3565b6040518263ffffffff1660e01b81526004016124f09190614c21565b602060405180830381600087803b15801561250a57600080fd5b505af115801561251e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125429190614049565b5080600e8360ff166002811061255b5761255a6150df565b5b01546125679190614d5c565b600e8360ff166002811061257e5761257d6150df565b5b018190555060005b818110156128305783156127095761259e6009612e3b565b6125d3601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166125ce6009612e2d565b612e51565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635aa4fc2f60018561261e6009612e2d565b6040518463ffffffff1660e01b815260040161263c93929190614888565b600060405180830381600087803b15801561265657600080fd5b505af115801561266a573d6000803e3d6000fd5b50505050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638f8e93246126b66009612e2d565b6040518263ffffffff1660e01b81526004016126d29190614c21565b600060405180830381600087803b1580156126ec57600080fd5b505af1158015612700573d6000803e3d6000fd5b505050506127c2565b6127136009612e3b565b612726336127216009612e2d565b612e51565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635aa4fc2f6001856127716009612e2d565b6040518463ffffffff1660e01b815260040161278f93929190614888565b600060405180830381600087803b1580156127a957600080fd5b505af11580156127bd573d6000803e3d6000fd5b505050505b33600760006127d16009612e2d565b815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808061282890615009565b915050612586565b50505050565b60006007600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b61287b612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128ff90614ae1565b60405180910390fd5b80600a60006101000a81548160ff02191690831515021790555050565b606061293082612d00565b61296f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161296690614b21565b60405180910390fd5b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633bb3a24d836040518263ffffffff1660e01b81526004016129ca9190614c21565b60006040518083038186803b1580156129e257600080fd5b505afa1580156129f6573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190612a1f919061418a565b9050919050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600b5481565b612ac8612d6c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b4c90614ae1565b60405180910390fd5b612b5e81613224565b50565b600c5481565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612bf7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bee90614aa1565b60405180910390fd5b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638576492f8787878787876040518763ffffffff1660e01b8152600401612c5c96959493929190614c3c565b600060405180830381600087803b158015612c7657600080fd5b505af1158015612c8a573d6000803e3d6000fd5b50505050505050505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612de783611b7a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b6001816000016000828254019250508190555050565b612e6b828260405180602001604052806000815250613351565b5050565b6000612e7a826133ac565b60001c9050919050565b6000612e8f82612d00565b612ece576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ec5906149a1565b60405180910390fd5b6000612ed983611b7a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480612f4857508373ffffffffffffffffffffffffffffffffffffffff16612f3084610a39565b73ffffffffffffffffffffffffffffffffffffffff16145b80612f595750612f588185612a26565b5b91505092915050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561301f57506007600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561307757816007600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b6130828383836133b7565b505050565b6000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e4b50cb8836040518263ffffffff1660e01b81526004016130e49190614c21565b60a06040518083038186803b1580156130fc57600080fd5b505afa158015613110573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061313491906142fa565b505050509050600e8160ff1660028110613151576131506150df565b5b01600081548092919061316390614f7c565b919050555060006007600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506131c482613613565b5050565b6131d3848484612f62565b6131df84848484613724565b61321e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613215906148e1565b60405180910390fd5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613294576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161328b90614901565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61335b83836138bb565b6133686000848484613724565b6133a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161339e906148e1565b60405180910390fd5b505050565b600081549050919050565b8273ffffffffffffffffffffffffffffffffffffffff166133d782611b7a565b73ffffffffffffffffffffffffffffffffffffffff161461342d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161342490614b01565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561349d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161349490614961565b60405180910390fd5b6134a8838383613980565b6134b3600082612d74565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546135039190614e3d565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461355a9190614d5c565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061361e82611b7a565b905061362c81600084613980565b613637600083612d74565b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546136879190614e3d565b925050819055506003600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b60006137458473ffffffffffffffffffffffffffffffffffffffff16613985565b156138ae578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261376e612d6c565b8786866040518563ffffffff1660e01b81526004016137909493929190614821565b602060405180830381600087803b1580156137aa57600080fd5b505af19250505080156137db57506040513d601f19601f820116820180604052508101906137d8919061415d565b60015b61385e573d806000811461380b576040519150601f19603f3d011682016040523d82523d6000602084013e613810565b606091505b50600081511415613856576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161384d906148e1565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506138b3565b600190505b949350505050565b6138c582826139d0565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d9005ae6040518163ffffffff1660e01b815260040160206040518083038186803b15801561392d57600080fd5b505afa158015613941573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139659190614200565b60086000838152602001908152602001600020819055505050565b505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91508082141580156139c757506000801b8214155b92505050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a3790614a41565b60405180910390fd5b613a4981612d00565b15613a89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a8090614921565b60405180910390fd5b613a9560008383613980565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613ae59190614d5c565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054613baa90614fa6565b90600052602060002090601f016020900481019282613bcc5760008555613c13565b82601f10613be557805160ff1916838001178555613c13565b82800160010185558215613c13579182015b82811115613c12578251825591602001919060010190613bf7565b5b509050613c209190613c24565b5090565b5b80821115613c3d576000816000905550600101613c25565b5090565b6000613c54613c4f84614cc2565b614c9d565b905082815260208101848484011115613c7057613c6f615142565b5b613c7b848285614f3a565b509392505050565b6000613c96613c9184614cf3565b614c9d565b905082815260208101848484011115613cb257613cb1615142565b5b613cbd848285614f49565b509392505050565b600081359050613cd48161572e565b92915050565b600081359050613ce981615745565b92915050565b600081519050613cfe81615745565b92915050565b600081359050613d138161575c565b92915050565b600081519050613d288161575c565b92915050565b600082601f830112613d4357613d4261513d565b5b8135613d53848260208601613c41565b91505092915050565b600082601f830112613d7157613d7061513d565b5b8151613d81848260208601613c83565b91505092915050565b600081359050613d9981615773565b92915050565b600081519050613dae81615773565b92915050565b600081359050613dc38161578a565b92915050565b600081519050613dd88161578a565b92915050565b600060208284031215613df457613df361514c565b5b6000613e0284828501613cc5565b91505092915050565b60008060408385031215613e2257613e2161514c565b5b6000613e3085828601613cc5565b9250506020613e4185828601613cc5565b9150509250929050565b600080600080600060a08688031215613e6757613e6661514c565b5b6000613e7588828901613cc5565b9550506020613e8688828901613cc5565b9450506040613e9788828901613cc5565b9350506060613ea888828901613cc5565b9250506080613eb988828901613cc5565b9150509295509295909350565b600080600060608486031215613edf57613ede61514c565b5b6000613eed86828701613cc5565b9350506020613efe86828701613cc5565b9250506040613f0f86828701613d8a565b9150509250925092565b60008060008060808587031215613f3357613f3261514c565b5b6000613f4187828801613cc5565b9450506020613f5287828801613cc5565b9350506040613f6387828801613d8a565b925050606085013567ffffffffffffffff811115613f8457613f83615147565b5b613f9087828801613d2e565b91505092959194509250565b60008060408385031215613fb357613fb261514c565b5b6000613fc185828601613cc5565b9250506020613fd285828601613cda565b9150509250929050565b60008060408385031215613ff357613ff261514c565b5b600061400185828601613cc5565b925050602061401285828601613d8a565b9150509250929050565b6000602082840312156140325761403161514c565b5b600061404084828501613cda565b91505092915050565b60006020828403121561405f5761405e61514c565b5b600061406d84828501613cef565b91505092915050565b60008060006060848603121561408f5761408e61514c565b5b600061409d86828701613cda565b93505060206140ae86828701613db4565b92505060406140bf86828701613d8a565b9150509250925092565b600080600080608085870312156140e3576140e261514c565b5b60006140f187828801613cda565b945050602061410287828801613db4565b935050604061411387828801613d8a565b925050606061412487828801613cc5565b91505092959194509250565b6000602082840312156141465761414561514c565b5b600061415484828501613d04565b91505092915050565b6000602082840312156141735761417261514c565b5b600061418184828501613d19565b91505092915050565b6000602082840312156141a05761419f61514c565b5b600082015167ffffffffffffffff8111156141be576141bd615147565b5b6141ca84828501613d5c565b91505092915050565b6000602082840312156141e9576141e861514c565b5b60006141f784828501613d8a565b91505092915050565b6000602082840312156142165761421561514c565b5b600061422484828501613d9f565b91505092915050565b600080604083850312156142445761424361514c565b5b600061425285828601613d8a565b925050602061426385828601613cc5565b9150509250929050565b60008060008060008060c0878903121561428a5761428961514c565b5b600061429889828a01613d8a565b96505060206142a989828a01613db4565b95505060406142ba89828a01613db4565b94505060606142cb89828a01613cda565b93505060806142dc89828a01613d8a565b92505060a06142ed89828a01613d8a565b9150509295509295509295565b600080600080600060a086880312156143165761431561514c565b5b600061432488828901613dc9565b955050602061433588828901613dc9565b945050604061434688828901613cef565b935050606061435788828901613d9f565b925050608061436888828901613d9f565b9150509295509295909350565b61437e81614ef2565b82525050565b61438d81614e71565b82525050565b61439c81614e83565b82525050565b60006143ad82614d24565b6143b78185614d3a565b93506143c7818560208601614f49565b6143d081615151565b840191505092915050565b6143e481614f04565b82525050565b60006143f582614d2f565b6143ff8185614d4b565b935061440f818560208601614f49565b61441881615151565b840191505092915050565b6000614430603283614d4b565b915061443b82615162565b604082019050919050565b6000614453602683614d4b565b915061445e826151b1565b604082019050919050565b6000614476601c83614d4b565b915061448182615200565b602082019050919050565b6000614499600f83614d4b565b91506144a482615229565b602082019050919050565b60006144bc602483614d4b565b91506144c782615252565b604082019050919050565b60006144df601983614d4b565b91506144ea826152a1565b602082019050919050565b6000614502602c83614d4b565b915061450d826152ca565b604082019050919050565b6000614525603883614d4b565b915061453082615319565b604082019050919050565b6000614548600f83614d4b565b915061455382615368565b602082019050919050565b600061456b602a83614d4b565b915061457682615391565b604082019050919050565b600061458e602983614d4b565b9150614599826153e0565b604082019050919050565b60006145b1602083614d4b565b91506145bc8261542f565b602082019050919050565b60006145d4600e83614d4b565b91506145df82615458565b602082019050919050565b60006145f7600b83614d4b565b915061460282615481565b602082019050919050565b600061461a600f83614d4b565b9150614625826154aa565b602082019050919050565b600061463d602c83614d4b565b9150614648826154d3565b604082019050919050565b6000614660602083614d4b565b915061466b82615522565b602082019050919050565b6000614683602983614d4b565b915061468e8261554b565b604082019050919050565b60006146a6601f83614d4b565b91506146b18261559a565b602082019050919050565b60006146c9600d83614d4b565b91506146d4826155c3565b602082019050919050565b60006146ec602183614d4b565b91506146f7826155ec565b604082019050919050565b600061470f603183614d4b565b915061471a8261563b565b604082019050919050565b6000614732600d83614d4b565b915061473d8261568a565b602082019050919050565b6000614755600c83614d4b565b9150614760826156b3565b602082019050919050565b6000614778600983614d4b565b9150614783826156dc565b602082019050919050565b600061479b601083614d4b565b91506147a682615705565b602082019050919050565b6147ba81614edb565b82525050565b6147c981614ee5565b82525050565b60006020820190506147e46000830184614384565b92915050565b60006060820190506147ff6000830186614375565b61480c6020830185614384565b61481960408301846147b1565b949350505050565b60006080820190506148366000830187614375565b6148436020830186614384565b61485060408301856147b1565b818103606083015261486281846143a2565b905095945050505050565b60006020820190506148826000830184614393565b92915050565b600060608201905061489d60008301866143db565b6148aa60208301856147c0565b6148b760408301846147b1565b949350505050565b600060208201905081810360008301526148d981846143ea565b905092915050565b600060208201905081810360008301526148fa81614423565b9050919050565b6000602082019050818103600083015261491a81614446565b9050919050565b6000602082019050818103600083015261493a81614469565b9050919050565b6000602082019050818103600083015261495a8161448c565b9050919050565b6000602082019050818103600083015261497a816144af565b9050919050565b6000602082019050818103600083015261499a816144d2565b9050919050565b600060208201905081810360008301526149ba816144f5565b9050919050565b600060208201905081810360008301526149da81614518565b9050919050565b600060208201905081810360008301526149fa8161453b565b9050919050565b60006020820190508181036000830152614a1a8161455e565b9050919050565b60006020820190508181036000830152614a3a81614581565b9050919050565b60006020820190508181036000830152614a5a816145a4565b9050919050565b60006020820190508181036000830152614a7a816145c7565b9050919050565b60006020820190508181036000830152614a9a816145ea565b9050919050565b60006020820190508181036000830152614aba8161460d565b9050919050565b60006020820190508181036000830152614ada81614630565b9050919050565b60006020820190508181036000830152614afa81614653565b9050919050565b60006020820190508181036000830152614b1a81614676565b9050919050565b60006020820190508181036000830152614b3a81614699565b9050919050565b60006020820190508181036000830152614b5a816146bc565b9050919050565b60006020820190508181036000830152614b7a816146df565b9050919050565b60006020820190508181036000830152614b9a81614702565b9050919050565b60006020820190508181036000830152614bba81614725565b9050919050565b60006020820190508181036000830152614bda81614748565b9050919050565b60006020820190508181036000830152614bfa8161476b565b9050919050565b60006020820190508181036000830152614c1a8161478e565b9050919050565b6000602082019050614c3660008301846147b1565b92915050565b600060c082019050614c5160008301896147b1565b614c5e60208301886147c0565b614c6b60408301876147c0565b614c786060830186614393565b614c8560808301856147b1565b614c9260a08301846147b1565b979650505050505050565b6000614ca7614cb8565b9050614cb38282614fd8565b919050565b6000604051905090565b600067ffffffffffffffff821115614cdd57614cdc61510e565b5b614ce682615151565b9050602081019050919050565b600067ffffffffffffffff821115614d0e57614d0d61510e565b5b614d1782615151565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000614d6782614edb565b9150614d7283614edb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614da757614da6615052565b5b828201905092915050565b6000614dbd82614edb565b9150614dc883614edb565b925082614dd857614dd7615081565b5b828204905092915050565b6000614dee82614edb565b9150614df983614edb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614e3257614e31615052565b5b828202905092915050565b6000614e4882614edb565b9150614e5383614edb565b925082821015614e6657614e65615052565b5b828203905092915050565b6000614e7c82614ebb565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000614efd82614f16565b9050919050565b6000614f0f82614ee5565b9050919050565b6000614f2182614f28565b9050919050565b6000614f3382614ebb565b9050919050565b82818337600083830152505050565b60005b83811015614f67578082015181840152602081019050614f4c565b83811115614f76576000848401525b50505050565b6000614f8782614edb565b91506000821415614f9b57614f9a615052565b5b600182039050919050565b60006002820490506001821680614fbe57607f821691505b60208210811415614fd257614fd16150b0565b5b50919050565b614fe182615151565b810181811067ffffffffffffffff8211171561500057614fff61510e565b5b80604052505050565b600061501482614edb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561504757615046615052565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4e6f742047616d65416464726573730000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f5075726368617365206c696d6974000000000000000000000000000000000000600082015250565b7f4e6f742070726573616c65000000000000000000000000000000000000000000600082015250565b7f43616c6c20726573747269637465640000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f74207175657279206e6f6e2d6578697374656e7420746f6b656e00600082015250565b7f427579207573696e672053555000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f427579207573696e672045746800000000000000000000000000000000000000600082015250565b7f496e76616c696420747970650000000000000000000000000000000000000000600082015250565b7f6e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b7f494e53554646494349454e545f45544800000000000000000000000000000000600082015250565b61573781614e71565b811461574257600080fd5b50565b61574e81614e83565b811461575957600080fd5b50565b61576581614e8f565b811461577057600080fd5b50565b61577c81614edb565b811461578757600080fd5b50565b61579381614ee5565b811461579e57600080fd5b5056fea264697066735822122057cca7ace9fa3f84a83cbb466581f977787be27f1236d21d7c0a6f910d8b86bb64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 22394, 2683, 2063, 2692, 26224, 2546, 16576, 17788, 2278, 17465, 22025, 2487, 2050, 24087, 2546, 22407, 2497, 21057, 2581, 2497, 2094, 24594, 2692, 2575, 2497, 2620, 2497, 1013, 1013, 5371, 1024, 3231, 8663, 6494, 16649, 1013, 24540, 7559, 18150, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1021, 1025, 1013, 1013, 1013, 1030, 16475, 24540, 2005, 1050, 6199, 4713, 3206, 24540, 7559, 18150, 1063, 1013, 1013, 5527, 2005, 2023, 24540, 27507, 16703, 4722, 5377, 7375, 1035, 10453, 1027, 27507, 16703, 1006, 1014, 2595, 21619, 2692, 2620, 2683, 2549, 27717, 2509, 3676, 2487, 2050, 16703, 10790, 28756, 2581, 2278, 2620, 22407, 26224, 2475, 18939, 2683, 2620, 16409, 2050, 2509, 2063, 11387, 2581, 2575, 9468, 24434, 19481, 2050, 2683, 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,949
0x97a3afedb51931a66ae86811de981e80082af56d
// CryptoPuppies Source code // Copied from: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code pragma solidity ^0.4.11; /** * @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; } } } /// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens /// @author Dieter Shirley <dete@axiomzen.co> (https://github.com/dete) contract ERC721 { // Required methods function totalSupply() public view returns (uint256 total); function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _tokenId) external view returns (address owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) external; function transferFrom(address _from, address _to, uint256 _tokenId) external; // Events event Transfer(address from, address to, uint256 tokenId); event Approval(address owner, address approved, uint256 tokenId); // Optional // function name() public view returns (string name); // function symbol() public view returns (string symbol); // function tokensOfOwner(address _owner) external view returns (uint256[] tokenIds); // function tokenMetadata(uint256 _tokenId, string _preferredTransport) public view returns (string infoUrl); // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165) function supportsInterface(bytes4 _interfaceID) external view returns (bool); } // // Auction wrapper functions // Auction wrapper functions /// @title SEKRETOOOO contract GeneScience { /// @dev simply a boolean to indicate this is the contract we expect to be function isGeneScience() public pure returns (bool); /// @dev given genes of puppies 1 & 2, return a genetic combination - may have a random factor /// @param genes1 genes of mom /// @param genes2 genes of sire /// @return the genes that are supposed to be passed down the child function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256); } /// @title Puppy sports contract contract PuppySports { /// @dev simply a boolean to indipuppye this is the contract we expect to be function isPuppySports() public pure returns (bool); /// @dev contract that provides gaming functionality /// @param puppyId - id of the puppy /// @param gameId - id of the game /// @param targetBlock - proof of randomness /// @return true if puppy won the game, false otherwise function playGame(uint256 puppyId, uint256 gameId, uint256 targetBlock) public returns (bool); } /// @title A facet of PuppiesCore that manages special access privileges. /// @author SmartFoxLabs /// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged. contract PuppyAccessControl { // This facet controls access control for CryptoPuppies. There are four roles managed here: // // - The CEO: The CEO can reassign other roles and change the addresses of our dependent smart // contracts. It is also the only role that can unpause the smart contract. It is initially // set to the address that created the smart contract in the PuppiesCore constructor. // // - The CFO: The CFO can withdraw funds from PuppiesCore and its auction contracts. // // - The COO: The COO can release gen0 puppies to auction, and mint promo puppys. // // It should be noted that these roles are distinct without overlap in their access abilities, the // abilities listed for each role above are exhaustive. In particular, while the CEO can assign any // address to any role, the CEO address itself doesn't have the ability to act in those roles. This // restriction is intentional so that we aren't tempted to use the CEO address frequently out of // convenience. The less we use an address, the less likely it is that we somehow compromise the // account. /// @dev Emited when contract is upgraded - See README.md for updgrade plan event ContractUpgrade(address newContract); // The addresses of the accounts (or contracts) that can execute actions within each roles. address public ceoAddress; address public cfoAddress; address public cooAddress; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Access modifier for CEO-only functionality modifier onlyCEO() { require(msg.sender == ceoAddress); _; } /// @dev Access modifier for CFO-only functionality modifier onlyCFO() { require(msg.sender == cfoAddress); _; } /// @dev Access modifier for COO-only functionality modifier onlyCOO() { require(msg.sender == cooAddress); _; } modifier onlyCLevel() { require(msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress); _; } /// @dev Assigns a new address to act as the CEO. Only available to the current CEO. /// @param _newCEO The address of the new CEO function setCEO(address _newCEO) external onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } /// @dev Assigns a new address to act as the CFO. Only available to the current CEO. /// @param _newCFO The address of the new CFO function setCFO(address _newCFO) external onlyCEO { require(_newCFO != address(0)); cfoAddress = _newCFO; } /// @dev Assigns a new address to act as the COO. Only available to the current CEO. /// @param _newCOO The address of the new COO function setCOO(address _newCOO) external onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; } /*** Pausable functionality adapted from OpenZeppelin ***/ /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() external onlyCLevel whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. Can only be called by the CEO, since /// one reason we may pause the contract is when CFO or COO accounts are /// compromised. /// @notice This is public rather than external so it can be called by /// derived contracts. function unpause() public onlyCEO whenPaused { // can't unpause if contract was upgraded paused = false; } } /// @title Base contract for CryptoPuppies. Holds all common structs, events and base variables. /// @author Axiom Zen (https://www.axiomzen.co) /// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged. contract PuppyBase is PuppyAccessControl { /*** EVENTS ***/ /// @dev The Birth event is fired whenever a new puppy comes into existence. This obviously /// includes any time a puppy is created through the giveBirth method, but it is also called /// when a new gen0 puppy is created. event Birth(address owner, uint256 puppyId, uint256 matronId, uint256 sireId, uint256 genes); /// @dev Transfer event as defined in current draft of ERC721. Emitted every time a puppy /// ownership is assigned, including births. event Transfer(address from, address to, uint256 tokenId); /*** DATA TYPES ***/ /// @dev The main Puppy struct. Every puppy in CryptoPuppies is represented by a copy /// of this structure, so great care was taken to ensure that it fits neatly into /// exactly two 256-bit words. Note that the order of the members in this structure /// is important because of the byte-packing rules used by Ethereum. /// Ref: http://solidity.readthedocs.io/en/develop/miscellaneous.html struct Puppy { // The Puppy's genetic code is packed into these 256-bits, the format is // sooper-sekret! A puppy's genes never change. uint256 genes; // The timestamp from the block when this puppy came into existence. uint64 birthTime; // The minimum timestamp after which this puppy can engage in breeding // activities again. This same timestamp is used for the pregnancy // timer (for matrons) as well as the siring cooldown. uint64 cooldownEndBlock; // The ID of the parents of this Puppy, set to 0 for gen0 puppys. // Note that using 32-bit unsigned integers limits us to a "mere" // 4 billion puppys. This number might seem small until you realize // that Ethereum currently has a limit of about 500 million // transactions per year! So, this definitely won't be a problem // for several years (even as Ethereum learns to scale). uint32 matronId; uint32 sireId; // Set to the ID of the sire puppy for matrons that are pregnant, // zero otherwise. A non-zero value here is how we know a puppy // is pregnant. Used to retrieve the genetic material for the new // puppy when the birth transpires. uint32 siringWithId; // Set to the index in the cooldown array (see below) that represents // the current cooldown duration for this Puppy. This starts at zero // for gen0 puppys, and is initialized to floor(generation/2) for others. // Incremented by one for each successful breeding action, regardless // of whether this puppy is acting as matron or sire. uint16 cooldownIndex; // The "generation number" of this puppy. puppys minted by the CK contract // for sale are called "gen0" and have a generation number of 0. The // generation number of all other puppys is the larger of the two generation // numbers of their parents, plus one. // (i.e. max(matron.generation, sire.generation) + 1) uint16 generation; uint16 childNumber; uint16 strength; uint16 agility; uint16 intelligence; uint16 speed; } /*** CONSTANTS ***/ /// @dev A lookup table indipuppying the cooldown duration after any successful /// breeding action, called "pregnancy time" for matrons and "siring cooldown" /// for sires. Designed such that the cooldown roughly doubles each time a puppy /// is bred, encouraging owners not to just keep breeding the same puppy over /// and over again. Caps out at one week (a puppy can breed an unbounded number /// of times, and the maximum cooldown is always seven days). uint32[14] public cooldowns = [ uint32(1 minutes), uint32(2 minutes), uint32(5 minutes), uint32(10 minutes), uint32(30 minutes), uint32(1 hours), uint32(2 hours), uint32(4 hours), uint32(8 hours), uint32(16 hours), uint32(1 days), uint32(2 days), uint32(4 days), uint32(7 days) ]; // An approximation of currently how many seconds are in between blocks. uint256 public secondsPerBlock = 15; /*** STORAGE ***/ /// @dev An array containing the Puppy struct for all puppies in existence. The ID /// of each puppy is actually an index into this array. Note that ID 0 is a negapuppy, /// the unPuppy, the mythical beast that is the parent of all gen0 puppys. A bizarre /// creature that is both matron and sire... to itself! Has an invalid genetic code. /// In other words, puppy ID 0 is invalid... ;-) Puppy[] puppies; /// @dev A mapping from puppy IDs to the address that owns them. All puppys have /// some valid owner address, even gen0 puppys are created with a non-zero owner. mapping (uint256 => address) public PuppyIndexToOwner; // @dev A mapping from owner address to count of tokens that address owns. // Used internally inside balanceOf() to resolve ownership count. mapping (address => uint256) ownershipTokenCount; /// @dev A mapping from puppyIds to an address that has been approved to call /// transferFrom(). Each Puppy can only have one approved address for transfer /// at any time. A zero value means no approval is outstanding. mapping (uint256 => address) public PuppyIndexToApproved; /// @dev A mapping from puppyIds to an address that has been approved to use /// this Puppy for siring via breedWith(). Each Puppy can only have one approved /// address for siring at any time. A zero value means no approval is outstanding. mapping (uint256 => address) public sireAllowedToAddress; /// @dev The address of the ClockAuction contract that handles sales of puppies. This /// same contract handles both peer-to-peer sales as well as the gen0 sales which are /// initiated every 15 minutes. SaleClockAuction public saleAuction; /// @dev The address of a custom ClockAuction subclassed contract that handles siring /// auctions. Needs to be separate from saleAuction because the actions taken on success /// after a sales and siring auction are quite different. SiringClockAuction public siringAuction; /// @dev Assigns ownership of a specific Puppy to an address. function _transfer(address _from, address _to, uint256 _tokenId) internal { // Since the number of puppys is capped to 2^32 we can't overflow this ownershipTokenCount[_to]++; // transfer ownership PuppyIndexToOwner[_tokenId] = _to; // When creating new puppys _from is 0x0, but we can't account that address. if (_from != address(0)) { ownershipTokenCount[_from]--; // once the puppy is transferred also clear sire allowances delete sireAllowedToAddress[_tokenId]; // clear any previously approved ownership exchange delete PuppyIndexToApproved[_tokenId]; } // Emit the transfer event. Transfer(_from, _to, _tokenId); } /// @dev An internal method that creates a new Puppy and stores it. This /// method doesn't do any checking and should only be called when the /// input data is known to be valid. Will generate both a Birth event /// and a Transfer event. /// @param _matronId The Puppy ID of the matron of this puppy (zero for gen0) /// @param _sireId The Puppy ID of the sire of this puppy (zero for gen0) /// @param _generation The generation number of this puppy, must be computed by caller. /// @param _genes The Puppy's genetic code. /// @param _owner The inital owner of this puppy, must be non-zero (except for the unPuppy, ID 0) function _createPuppy( uint256 _matronId, uint256 _sireId, uint256 _generation, uint256 _genes, address _owner, uint16 _strength, uint16 _agility, uint16 _intelligence, uint16 _speed ) internal returns (uint) { // These requires are not strictly necessary, our calling code should make // sure that these conditions are never broken. However! _createPuppy() is already // an expensive call (for storage), and it doesn't hurt to be especially careful // to ensure our data structures are always valid. require(_matronId == uint256(uint32(_matronId))); require(_sireId == uint256(uint32(_sireId))); require(_generation == uint256(uint16(_generation))); // New Puppy starts with the same cooldown as parent gen/2 uint16 cooldownIndex = uint16(_generation / 2); if (cooldownIndex > 13) { cooldownIndex = 13; } Puppy memory _puppy = Puppy({ genes: _genes, birthTime: uint64(now), cooldownEndBlock: 0, matronId: uint32(_matronId), sireId: uint32(_sireId), siringWithId: 0, cooldownIndex: cooldownIndex, generation: uint16(_generation), childNumber: 0, strength: _strength, agility: _agility, intelligence: _intelligence, speed: _speed }); uint256 newpuppyId = puppies.push(_puppy) - 1; // It's probably never going to happen, 4 billion puppys is A LOT, but // let's just be 100% sure we never let this happen. require(newpuppyId == uint256(uint32(newpuppyId))); // emit the birth event Birth( _owner, newpuppyId, uint256(_puppy.matronId), uint256(_puppy.sireId), _puppy.genes ); // This will assign ownership, and also emit the Transfer event as // per ERC721 draft _transfer(0, _owner, newpuppyId); return newpuppyId; } // Any C-level can fix how many seconds per blocks are currently observed. function setSecondsPerBlock(uint256 secs) external onlyCLevel { require(secs < cooldowns[0]); secondsPerBlock = secs; } } /// @title The external contract that is responsible for generating metadata for the puppies, /// it has one function that will return the data as bytes. contract ERC721Metadata { /// @dev Given a token Id, returns a byte array that is supposed to be converted into string. function getMetadata(uint256 _tokenId, string) public view returns (bytes32[4] buffer, uint256 count) { if (_tokenId == 1) { buffer[0] = "Hello World! :D"; count = 15; } else if (_tokenId == 2) { buffer[0] = "I would definitely choose a medi"; buffer[1] = "um length string."; count = 49; } else if (_tokenId == 3) { buffer[0] = "Lorem ipsum dolor sit amet, mi e"; buffer[1] = "st accumsan dapibus augue lorem,"; buffer[2] = " tristique vestibulum id, libero"; buffer[3] = " suscipit varius sapien aliquam."; count = 128; } } } /// @title The facet of the CryptoPuppies core contract that manages ownership, ERC-721 (draft) compliant. /// @author Axiom Zen (https://www.axiomzen.co) /// @dev Ref: https://github.com/ethereum/EIPs/issues/721 /// See the PuppiesCore contract documentation to understand how the various contract facets are arranged. contract PuppyOwnership is PuppyBase, ERC721 { /// @notice Name and symbol of the non fungible token, as defined in ERC721. string public constant name = "CryptoPuppies"; string public constant symbol = "CP"; // The contract that will return Puppy metadata ERC721Metadata public erc721Metadata; bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256("supportsInterface(bytes4)")); bytes4 constant InterfaceSignature_ERC721 = bytes4(keccak256("name()")) ^ bytes4(keccak256("symbol()")) ^ bytes4(keccak256("totalSupply()")) ^ bytes4(keccak256("balanceOf(address)")) ^ bytes4(keccak256("ownerOf(uint256)")) ^ bytes4(keccak256("approve(address,uint256)")) ^ bytes4(keccak256("transfer(address,uint256)")) ^ bytes4(keccak256("transferFrom(address,address,uint256)")) ^ bytes4(keccak256("tokensOfOwner(address)")) ^ bytes4(keccak256("tokenMetadata(uint256,string)")); /// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165). /// Returns true for any standardized interfaces implemented by this contract. We implement /// ERC-165 (obviously!) and ERC-721. function supportsInterface(bytes4 _interfaceID) external view returns (bool) { // DEBUG ONLY //require((InterfaceSignature_ERC165 == 0x01ffc9a7) && (InterfaceSignature_ERC721 == 0x9a20483d)); return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721)); } /// @dev Set the address of the sibling contract that tracks metadata. /// CEO only. function setMetadataAddress(address _contractAddress) public onlyCEO { erc721Metadata = ERC721Metadata(_contractAddress); } // Internal utility functions: These functions all assume that their input arguments // are valid. We leave it to public methods to sanitize their inputs and follow // the required logic. /// @dev Checks if a given address is the current owner of a particular Puppy. /// @param _claimant the address we are validating against. /// @param _tokenId puppy id, only valid when > 0 function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return PuppyIndexToOwner[_tokenId] == _claimant; } /// @dev Checks if a given address currently has transferApproval for a particular Puppy. /// @param _claimant the address we are confirming puppy is approved for. /// @param _tokenId puppy id, only valid when > 0 function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) { return PuppyIndexToApproved[_tokenId] == _claimant; } /// @dev Marks an address as being approved for transferFrom(), overwriting any previous /// approval. Setting _approved to address(0) clears all transfer approval. /// NOTE: _approve() does NOT send the Approval event. This is intentional because /// _approve() and transferFrom() are used together for putting puppies on auction, and /// there is no value in spamming the log with Approval events in that case. function _approve(uint256 _tokenId, address _approved) internal { PuppyIndexToApproved[_tokenId] = _approved; } /// @notice Returns the number of puppies owned by a specific address. /// @param _owner The owner address to check. /// @dev Required for ERC-721 compliance function balanceOf(address _owner) public view returns (uint256 count) { return ownershipTokenCount[_owner]; } /// @notice Transfers a Puppy to another address. If transferring to a smart /// contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or /// CryptoPuppies specifically) or your Puppy may be lost forever. Seriously. /// @param _to The address of the recipient, can be a user or contract. /// @param _tokenId The ID of the Puppy to transfer. /// @dev Required for ERC-721 compliance. function transfer( address _to, uint256 _tokenId ) external whenNotPaused { // Safety check to prevent against an unexpected 0x0 default. require(_to != address(0)); // Disallow transfers to this contract to prevent accidental misuse. // The contract should never own any puppies (except very briefly // after a gen0 puppy is created and before it goes on auction). require(_to != address(this)); // Disallow transfers to the auction contracts to prevent accidental // misuse. Auction contracts should only take ownership of puppies // through the allow + transferFrom flow. require(_to != address(saleAuction)); require(_to != address(siringAuction)); // You can only send your own puppy. require(_owns(msg.sender, _tokenId)); // Reassign ownership, clear pending approvals, emit Transfer event. _transfer(msg.sender, _to, _tokenId); } /// @notice Grant another address the right to transfer a specific Puppy via /// transferFrom(). This is the preferred flow for transfering NFTs to contracts. /// @param _to The address to be granted transfer approval. Pass address(0) to /// clear all approvals. /// @param _tokenId The ID of the Puppy that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function approve( address _to, uint256 _tokenId ) external whenNotPaused { // Only an owner can grant transfer approval. require(_owns(msg.sender, _tokenId)); // Register the approval (replacing any previous approval). _approve(_tokenId, _to); // Emit approval event. Approval(msg.sender, _to, _tokenId); } /// @notice Transfer a Puppy owned by another address, for which the calling address /// has previously been granted transfer approval by the owner. /// @param _from The address that owns the Puppy to be transfered. /// @param _to The address that should take ownership of the Puppy. Can be any address, /// including the caller. /// @param _tokenId The ID of the Puppy to be transferred. /// @dev Required for ERC-721 compliance. function transferFrom( address _from, address _to, uint256 _tokenId ) external whenNotPaused { // Safety check to prevent against an unexpected 0x0 default. require(_to != address(0)); // Disallow transfers to this contract to prevent accidental misuse. // The contract should never own any puppies (except very briefly // after a gen0 puppy is created and before it goes on auction). require(_to != address(this)); // Check for approval and valid ownership require(_approvedFor(msg.sender, _tokenId)); require(_owns(_from, _tokenId)); // Reassign ownership (also clears pending approvals and emits Transfer event). _transfer(_from, _to, _tokenId); } /// @notice Returns the total number of puppies currently in existence. /// @dev Required for ERC-721 compliance. function totalSupply() public view returns (uint) { return puppies.length - 1; } /// @notice Returns the address currently assigned ownership of a given Puppy. /// @dev Required for ERC-721 compliance. function ownerOf(uint256 _tokenId) external view returns (address owner) { owner = PuppyIndexToOwner[_tokenId]; require(owner != address(0)); } /// @notice Returns a list of all Puppy IDs assigned to an address. /// @param _owner The owner whose puppies we are interested in. /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly /// expensive (it walks the entire Puppy array looking for puppys belonging to owner), /// but it also returns a dynamic array, which is only supported for web3 calls, and /// not contract-to-contract calls. function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalpuppys = totalSupply(); uint256 resultIndex = 0; // We count on the fact that all puppys have IDs starting at 1 and increasing // sequentially up to the totalpuppy count. uint256 puppyId; for (puppyId = 1; puppyId <= totalpuppys; puppyId++) { if (PuppyIndexToOwner[puppyId] == _owner) { result[resultIndex] = puppyId; resultIndex++; } } return result; } } /// @dev Adapted from memcpy() by @arachnid (Nick Johnson <arachnid@notdot.net>) /// This method is licenced under the Apache License. /// Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol function _memcpy(uint _dest, uint _src, uint _len) private view { // Copy word-length chunks while possible for(; _len >= 32; _len -= 32) { assembly { mstore(_dest, mload(_src)) } _dest += 32; _src += 32; } // Copy remaining bytes uint256 mask = 256 ** (32 - _len) - 1; assembly { let srcpart := and(mload(_src), not(mask)) let destpart := and(mload(_dest), mask) mstore(_dest, or(destpart, srcpart)) } } /// @dev Adapted from toString(slice) by @arachnid (Nick Johnson <arachnid@notdot.net>) /// This method is licenced under the Apache License. /// Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol function _toString(bytes32[4] _rawBytes, uint256 _stringLength) private view returns (string) { var outputString = new string(_stringLength); uint256 outputPtr; uint256 bytesPtr; assembly { outputPtr := add(outputString, 32) bytesPtr := _rawBytes } _memcpy(outputPtr, bytesPtr, _stringLength); return outputString; } /// @notice Returns a URI pointing to a metadata package for this token conforming to /// ERC-721 (https://github.com/ethereum/EIPs/issues/721) /// @param _tokenId The ID number of the Puppy whose metadata should be returned. function tokenMetadata(uint256 _tokenId, string _preferredTransport) external view returns (string infoUrl) { require(erc721Metadata != address(0)); bytes32[4] memory buffer; uint256 count; (buffer, count) = erc721Metadata.getMetadata(_tokenId, _preferredTransport); return _toString(buffer, count); } } /// @title A facet of PuppiesCore that manages Puppy siring, gestation, and birth. /// @author Axiom Zen (https://www.axiomzen.co) /// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged. contract PuppyBreeding is PuppyOwnership { /// @dev The Pregnant event is fired when two puppys successfully breed and the pregnancy /// timer begins for the matron. event Pregnant(address owner, uint256 matronId, uint256 sireId, uint256 cooldownEndBlock); /// @notice The minimum payment required to use breedWithAuto(). This fee goes towards /// the gas cost paid by whatever calls giveBirth(), and can be dynamically updated by /// the COO role as the gas price changes. uint256 public autoBirthFee = 8 finney; // Keeps track of number of pregnant puppies. uint256 public pregnantpuppies; uint256 public minChildCount = 2; uint256 public maxChildCount = 14; uint randNonce = 0; /// @dev The address of the sibling contract that is used to implement the sooper-sekret /// genetic combination algorithm. GeneScience public geneScience; PuppySports public puppySports; function setMinChildCount(uint256 _minChildCount) onlyCOO whenNotPaused { require(_minChildCount >= 2); minChildCount = _minChildCount; } function setMaxChildCount(uint256 _maxChildCount) onlyCOO whenNotPaused { require(_maxChildCount > minChildCount); maxChildCount = _maxChildCount; } function setGeneScienceAddress(address _address) external onlyCEO { GeneScience candidateContract = GeneScience(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117 require(candidateContract.isGeneScience()); // Set the new contract address geneScience = candidateContract; } function setPuppySports(address _address) external onlyCEO { PuppySports candidateContract = PuppySports(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117 require(candidateContract.isPuppySports()); // Set the new contract address puppySports = candidateContract; } /// @dev Checks that a given puppy is able to breed. Requires that the /// current cooldown is finished (for sires) and also checks that there is /// no pending pregnancy. function _isReadyToBreed(Puppy _pup) internal view returns (bool) { // In addition to checking the cooldownEndBlock, we also need to check to see if // the puppy has a pending birth; there can be some period of time between the end // of the pregnacy timer and the birth event. uint256 numberOfAllowedChild = maxChildCount - _pup.generation * 2; if (numberOfAllowedChild < minChildCount) { numberOfAllowedChild = minChildCount; } bool isChildLimitNotReached = _pup.childNumber < numberOfAllowedChild; return (_pup.siringWithId == 0) && (_pup.cooldownEndBlock <= uint64(block.number)) && isChildLimitNotReached; } /// @dev Check if a sire has authorized breeding with this matron. True if both sire /// and matron have the same owner, or if the sire has given siring permission to /// the matron's owner (via approveSiring()). function _isSiringPermitted(uint256 _sireId, uint256 _matronId) internal view returns (bool) { address matronOwner = PuppyIndexToOwner[_matronId]; address sireOwner = PuppyIndexToOwner[_sireId]; // Siring is okay if they have same owner, or if the matron's owner was given // permission to breed with this sire. return (matronOwner == sireOwner || sireAllowedToAddress[_sireId] == matronOwner); } /// @dev Set the cooldownEndTime for the given Puppy, based on its current cooldownIndex. /// Also increments the cooldownIndex (unless it has hit the cap). /// @param _puppy A reference to the Puppy in storage which needs its timer started. function _triggerCooldown(Puppy storage _puppy) internal { // Compute an estimation of the cooldown time in blocks (based on current cooldownIndex). _puppy.cooldownEndBlock = uint64((cooldowns[_puppy.cooldownIndex]/secondsPerBlock) + block.number); // Increment the breeding count, clamping it at 13, which is the length of the // cooldowns array. We could check the array size dynamically, but hard-coding // this as a constant saves gas. Yay, Solidity! if (_puppy.cooldownIndex < 13) { _puppy.cooldownIndex += 1; } } /// @dev Set the cooldownEndTime for the given Puppy, based on its current cooldownIndex. /// Also increments the cooldownIndex (unless it has hit the cap). /// @param _puppy A reference to the Puppy in storage which needs its timer started. function _triggerChildCount(Puppy storage _puppy) internal { // Increment the child count _puppy.childNumber += 1; } /// @notice Grants approval to another user to sire with one of your puppies. /// @param _addr The address that will be able to sire with your Puppy. Set to /// address(0) to clear all siring approvals for this Puppy. /// @param _sireId A Puppy that you own that _addr will now be able to sire with. function approveSiring(address _addr, uint256 _sireId) external whenNotPaused { require(_owns(msg.sender, _sireId)); sireAllowedToAddress[_sireId] = _addr; } /// @dev Updates the minimum payment required for calling giveBirthAuto(). Can only /// be called by the COO address. (This fee is used to offset the gas cost incurred /// by the autobirth daemon). function setAutoBirthFee(uint256 val) external onlyCOO { autoBirthFee = val; } /// @dev Checks to see if a given Puppy is pregnant and (if so) if the gestation /// period has passed. function _isReadyToGiveBirth(Puppy _matron) private view returns (bool) { return (_matron.siringWithId != 0) && (_matron.cooldownEndBlock <= uint64(block.number)); } /// @notice Checks that a given puppy is able to breed (i.e. it is not pregnant or /// in the middle of a siring cooldown). /// @param _puppyId reference the id of the puppy, any user can inquire about it function isReadyToBreed(uint256 _puppyId) public view returns (bool) { require(_puppyId > 0); Puppy storage pup = puppies[_puppyId]; return _isReadyToBreed(pup); } /// @dev Checks whether a Puppy is currently pregnant. /// @param _puppyId reference the id of the puppy, any user can inquire about it function isPregnant(uint256 _puppyId) public view returns (bool) { require(_puppyId > 0); // A Puppy is pregnant if and only if this field is set return puppies[_puppyId].siringWithId != 0; } /// @dev Internal check to see if a given sire and matron are a valid mating pair. DOES NOT /// check ownership permissions (that is up to the caller). /// @param _matron A reference to the Puppy struct of the potential matron. /// @param _matronId The matron's ID. /// @param _sire A reference to the Puppy struct of the potential sire. /// @param _sireId The sire's ID function _isValidMatingPair( Puppy storage _matron, uint256 _matronId, Puppy storage _sire, uint256 _sireId ) private view returns(bool) { // A Puppy can't breed with itself! if (_matronId == _sireId) { return false; } // puppies can't breed with their parents. if (_matron.matronId == _sireId || _matron.sireId == _sireId) { return false; } if (_sire.matronId == _matronId || _sire.sireId == _matronId) { return false; } // We can short circuit the sibling check (below) if either puppy is // gen zero (has a matron ID of zero). if (_sire.matronId == 0 || _matron.matronId == 0) { return true; } // puppies can't breed with full or half siblings. if (_sire.matronId == _matron.matronId || _sire.matronId == _matron.sireId) { return false; } if (_sire.sireId == _matron.matronId || _sire.sireId == _matron.sireId) { return false; } // Everything seems cool! Let's get DTF. return true; } /// @dev Internal check to see if a given sire and matron are a valid mating pair for /// breeding via auction (i.e. skips ownership and siring approval checks). function _canBreedWithViaAuction(uint256 _matronId, uint256 _sireId) internal view returns (bool) { Puppy storage matron = puppies[_matronId]; Puppy storage sire = puppies[_sireId]; return _isValidMatingPair(matron, _matronId, sire, _sireId); } /// @notice Checks to see if two puppys can breed together, including checks for /// ownership and siring approvals. Does NOT check that both puppys are ready for /// breeding (i.e. breedWith could still fail until the cooldowns are finished). /// TODO: Shouldn't this check pregnancy and cooldowns?!? /// @param _matronId The ID of the proposed matron. /// @param _sireId The ID of the proposed sire. function canBreedWith(uint256 _matronId, uint256 _sireId) external view returns(bool) { require(_matronId > 0); require(_sireId > 0); Puppy storage matron = puppies[_matronId]; Puppy storage sire = puppies[_sireId]; return _isValidMatingPair(matron, _matronId, sire, _sireId) && _isSiringPermitted(_sireId, _matronId); } /// @dev Internal utility function to initiate breeding, assumes that all breeding /// requirements have been checked. function _breedWith(uint256 _matronId, uint256 _sireId) internal { // Grab a reference to the puppies from storage. Puppy storage sire = puppies[_sireId]; Puppy storage matron = puppies[_matronId]; // Mark the matron as pregnant, keeping track of who the sire is. matron.siringWithId = uint32(_sireId); // Trigger the cooldown for both parents. _triggerCooldown(sire); _triggerCooldown(matron); _triggerChildCount(sire); _triggerChildCount(matron); // Clear siring permission for both parents. This may not be strictly necessary // but it's likely to avoid confusion! delete sireAllowedToAddress[_matronId]; delete sireAllowedToAddress[_sireId]; // Every time a Puppy gets pregnant, counter is incremented. pregnantpuppies++; // Emit the pregnancy event. Pregnant(PuppyIndexToOwner[_matronId], _matronId, _sireId, matron.cooldownEndBlock); } /// @notice Breed a Puppy you own (as matron) with a sire that you own, or for which you /// have previously been given Siring approval. Will either make your puppy pregnant, or will /// fail entirely. Requires a pre-payment of the fee given out to the first caller of giveBirth() /// @param _matronId The ID of the Puppy acting as matron (will end up pregnant if successful) /// @param _sireId The ID of the Puppy acting as sire (will begin its siring cooldown if successful) function breedWithAuto(uint256 _matronId, uint256 _sireId) external payable whenNotPaused { // Checks for payment. require(msg.value >= autoBirthFee); // Caller must own the matron. require(_owns(msg.sender, _matronId)); // Neither sire nor matron are allowed to be on auction during a normal // breeding operation, but we don't need to check that explicitly. // For matron: The caller of this function can't be the owner of the matron // because the owner of a Puppy on auction is the auction house, and the // auction house will never call breedWith(). // For sire: Similarly, a sire on auction will be owned by the auction house // and the act of transferring ownership will have cleared any oustanding // siring approval. // Thus we don't need to spend gas explicitly checking to see if either puppy // is on auction. // Check that matron and sire are both owned by caller, or that the sire // has given siring permission to caller (i.e. matron's owner). // Will fail for _sireId = 0 require(_isSiringPermitted(_sireId, _matronId)); // Grab a reference to the potential matron Puppy storage matron = puppies[_matronId]; // Make sure matron isn't pregnant, or in the middle of a siring cooldown require(_isReadyToBreed(matron)); // Grab a reference to the potential sire Puppy storage sire = puppies[_sireId]; // Make sure sire isn't pregnant, or in the middle of a siring cooldown require(_isReadyToBreed(sire)); // Test that these puppys are a valid mating pair. require(_isValidMatingPair( matron, _matronId, sire, _sireId )); // All checks passed, Puppy gets pregnant! _breedWith(_matronId, _sireId); } function playGame(uint256 _puppyId, uint256 _gameId) external whenNotPaused returns(bool) { require(puppySports != address(0)); require(_owns(msg.sender, _puppyId)); return puppySports.playGame(_puppyId, _gameId, block.number); } /// @notice Have a pregnant Puppy give birth! /// @param _matronId A Puppy ready to give birth. /// @return The Puppy ID of the new puppy. /// @dev Looks at a given Puppy and, if pregnant and if the gestation period has passed, /// combines the genes of the two parents to create a new puppy. The new Puppy is assigned /// to the current owner of the matron. Upon successful completion, both the matron and the /// new puppy will be ready to breed again. Note that anyone can call this function (if they /// are willing to pay the gas!), but the new puppy always goes to the mother's owner. function giveBirth(uint256 _matronId) payable external whenNotPaused returns(uint256) { // Grab a reference to the matron in storage. Puppy storage matron = puppies[_matronId]; // Check that the matron is a valid puppy. require(matron.birthTime != 0); // Check that the matron is pregnant, and that its time has come! require(_isReadyToGiveBirth(matron)); // Grab a reference to the sire in storage. uint256 sireId = matron.siringWithId; Puppy storage sire = puppies[sireId]; // Determine the higher generation number of the two parents uint16 parentGen = matron.generation; if (sire.generation > matron.generation) { parentGen = sire.generation; } // Call the sooper-sekret gene mixing operation. //uint256 childGenes = _babyGenes; uint256 childGenes = geneScience.mixGenes(matron.genes, sire.genes, matron.cooldownEndBlock - 1); // Make the new puppy! address owner = PuppyIndexToOwner[_matronId]; // Add randomizer for attributes uint16 strength = uint16(random(_matronId)); uint16 agility = uint16(random(strength)); uint16 intelligence = uint16(random(agility)); uint16 speed = uint16(random(intelligence)); uint256 puppyId = _createPuppy(_matronId, matron.siringWithId, parentGen + 1, childGenes, owner, strength, agility, intelligence, speed); // Clear the reference to sire from the matron (REQUIRED! Having siringWithId // set is what marks a matron as being pregnant.) delete matron.siringWithId; // Every time a Puppy gives birth counter is decremented. pregnantpuppies--; // Send the balance fee to the person who made birth happen. msg.sender.send(autoBirthFee); // return the new puppy's ID return puppyId; } //random function random(uint256 seed) public view returns (uint8 randomNumber) { uint8 rnd = uint8(keccak256( seed, block.blockhash(block.number - 1), block.coinbase, block.difficulty )) % 100 + uint8(1); return rnd % 100 + 1; } } /// @title Auction Core /// @dev Contains models, variables, and internal methods for the auction. /// @notice We omit a fallback function to prevent accidental sends to this contract. contract ClockAuctionBase { // Represents an auction on an NFT struct Auction { // Current owner of NFT address seller; // Price (in wei) at beginning of auction uint128 startingPrice; // Price (in wei) at end of auction uint128 endingPrice; // Duration (in seconds) of auction uint64 duration; // Time when auction started // NOTE: 0 if this auction has been concluded uint64 startedAt; } // Reference to contract tracking NFT ownership ERC721 public nonFungibleContract; // Cut owner takes on each auction, measured in basis points (1/100 of a percent). // Values 0-10,000 map to 0%-100% uint256 public ownerCut; // Map from token ID to their corresponding auction. mapping (uint256 => Auction) tokenIdToAuction; event AuctionCreated(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner); event AuctionCancelled(uint256 tokenId); /// @dev Returns true if the claimant owns the token. /// @param _claimant - Address claiming to own the token. /// @param _tokenId - ID of token whose ownership to verify. function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } /// @dev Escrows the NFT, assigning ownership to this contract. /// Throws if the escrow fails. /// @param _owner - Current owner address of token to escrow. /// @param _tokenId - ID of token whose approval to verify. function _escrow(address _owner, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.transferFrom(_owner, this, _tokenId); } /// @dev Transfers an NFT owned by this contract to another address. /// Returns true if the transfer succeeds. /// @param _receiver - Address to transfer NFT to. /// @param _tokenId - ID of token to transfer. function _transfer(address _receiver, uint256 _tokenId) internal { // it will throw if transfer fails nonFungibleContract.transfer(_receiver, _tokenId); } /// @dev Adds an auction to the list of open auctions. Also fires the /// AuctionCreated event. /// @param _tokenId The ID of the token to be put on auction. /// @param _auction Auction to add. function _addAuction(uint256 _tokenId, Auction _auction) internal { // Require that all auctions have a duration of // at least one minute. (Keeps our math from getting hairy!) require(_auction.duration >= 1 minutes); tokenIdToAuction[_tokenId] = _auction; AuctionCreated( uint256(_tokenId), uint256(_auction.startingPrice), uint256(_auction.endingPrice), uint256(_auction.duration) ); } /// @dev Cancels an auction unconditionally. function _cancelAuction(uint256 _tokenId, address _seller) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); AuctionCancelled(_tokenId); } /// @dev Computes the price and transfers winnings. /// Does NOT transfer ownership of token. function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { // Get a reference to the auction struct Auction storage auction = tokenIdToAuction[_tokenId]; // Explicitly check that this auction is currently live. // (Because of how Ethereum mappings work, we can't just count // on the lookup above failing. An invalid _tokenId will just // return an auction object that is all zeros.) require(_isOnAuction(auction)); // Check that the bid is greater than or equal to the current price uint256 price = _currentPrice(auction); require(_bidAmount >= price); // Grab a reference to the seller before the auction struct // gets deleted. address seller = auction.seller; // The bid is good! Remove the auction before sending the fees // to the sender so we can't have a reentrancy attack. _removeAuction(_tokenId); // Transfer proceeds to seller (if there are any!) if (price > 0) { // Calculate the auctioneer's cut. // (NOTE: _computeCut() is guaranteed to return a // value <= price, so this subtraction can't go negative.) uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut; // NOTE: Doing a transfer() in the middle of a complex // method like this is generally discouraged because of // reentrancy attacks and DoS attacks if the seller is // a contract with an invalid fallback function. We explicitly // guard against reentrancy attacks by removing the auction // before calling transfer(), and the only thing the seller // can DoS is the sale of their own asset! (And if it's an // accident, they can call cancelAuction(). ) seller.transfer(sellerProceeds); } // Calculate any excess funds included with the bid. If the excess // is anything worth worrying about, transfer it back to bidder. // NOTE: We checked above that the bid amount is greater than or // equal to the price so this cannot underflow. uint256 bidExcess = _bidAmount - price; // Return the funds. Similar to the previous transfer, this is // not susceptible to a re-entry attack because the auction is // removed before any transfers occur. msg.sender.transfer(bidExcess); // Tell the world! AuctionSuccessful(_tokenId, price, msg.sender); return price; } /// @dev Removes an auction from the list of open auctions. /// @param _tokenId - ID of NFT on auction. function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } /// @dev Returns true if the NFT is on auction. /// @param _auction - Auction to check. function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } /// @dev Returns current price of an NFT on auction. Broken into two /// functions (this one, that computes the duration from the auction /// structure, and the other that does the price computation) so we /// can easily test that the price computation works correctly. function _currentPrice(Auction storage _auction) internal view returns (uint256) { uint256 secondsPassed = 0; // A bit of insurance against negative values (or wraparound). // Probably not necessary (since Ethereum guarnatees that the // now variable doesn't ever go backwards). if (now > _auction.startedAt) { secondsPassed = now - _auction.startedAt; } return _computeCurrentPrice( _auction.startingPrice, _auction.endingPrice, _auction.duration, secondsPassed ); } /// @dev Computes the current price of an auction. Factored out /// from _currentPrice so we can run extensive unit tests. /// When testing, make this function public and turn on /// `Current price computation` test suite. function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256) { // NOTE: We don't use SafeMath (or similar) in this function because // all of our public functions carefully cap the maximum values for // time (at 64-bits) and currency (at 128-bits). _duration is // also known to be non-zero (see the require() statement in // _addAuction()) if (_secondsPassed >= _duration) { // We've reached the end of the dynamic pricing portion // of the auction, just return the end price. return _endingPrice; } else { // Starting price can be higher than ending price (and often is!), so // this delta can be negative. int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice); // This multiplipuppyion can't overflow, _secondsPassed will easily fit within // 64-bits, and totalPriceChange will easily fit within 128-bits, their product // will always fit within 256-bits. int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); // currentPriceChange can be negative, but if so, will have a magnitude // less that _startingPrice. Thus, this result will always end up positive. int256 currentPrice = int256(_startingPrice) + currentPriceChange; return uint256(currentPrice); } } /// @dev Computes owner's cut of a sale. /// @param _price - Sale price of NFT. function _computeCut(uint256 _price) internal view returns (uint256) { // NOTE: We don't use SafeMath (or similar) in this function because // all of our entry functions carefully cap the maximum values for // currency (at 128-bits), and ownerCut <= 10000 (see the require() // statement in the ClockAuction constructor). The result of this // function is always guaranteed to be <= _price. return _price * ownerCut / 10000; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { require(!paused); _; } /** * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } /// @title Clock auction for non-fungible tokens. /// @notice We omit a fallback function to prevent accidental sends to this contract. contract ClockAuction is Pausable, ClockAuctionBase { /// @dev The ERC-165 interface signature for ERC-721. /// Ref: https://github.com/ethereum/EIPs/issues/165 /// Ref: https://github.com/ethereum/EIPs/issues/721 bytes4 constant InterfaceSignature_ERC721 = bytes4(0x9a20483d); /// @dev Constructor creates a reference to the NFT ownership contract /// and verifies the owner cut is in the valid range. /// @param _nftAddress - address of a deployed contract implementing /// the Nonfungible Interface. /// @param _cut - percent cut the owner takes on each auction, must be /// between 0-10,000. function ClockAuction(address _nftAddress, uint256 _cut) public { require(_cut <= 10000); ownerCut = _cut; ERC721 candidateContract = ERC721(_nftAddress); require(candidateContract.supportsInterface(InterfaceSignature_ERC721)); nonFungibleContract = candidateContract; } /// @dev Remove all Ether from the contract, which is the owner's cuts /// as well as any Ether sent directly to the contract address. /// Always transfers to the NFT contract, but can be called either by /// the owner or the NFT contract. function withdrawBalance() external { address nftAddress = address(nonFungibleContract); require( msg.sender == owner || msg.sender == nftAddress ); // We are using this boolean method to make sure that even if one fails it will still work bool res = nftAddress.send(this.balance); } /// @dev Creates and begins a new auction. /// @param _tokenId - ID of token to auction, sender must be owner. /// @param _startingPrice - Price of item (in wei) at beginning of auction. /// @param _endingPrice - Price of item (in wei) at end of auction. /// @param _duration - Length of time to move between starting /// price and ending price (in seconds). /// @param _seller - Seller, if not the message sender function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) external whenNotPaused { // Sanity check that no inputs overflow how many bits we've allopuppyed // to store them in the auction struct. require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(_owns(msg.sender, _tokenId)); _escrow(msg.sender, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } /// @dev Bids on an open auction, completing the auction and transferring /// ownership of the NFT if enough Ether is supplied. /// @param _tokenId - ID of token to bid on. function bid(uint256 _tokenId) external payable whenNotPaused { // _bid will throw if the bid or funds transfer fails _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); } /// @dev Cancels an auction that hasn't been won yet. /// Returns the NFT to original owner. /// @notice This is a state-modifying function that can /// be called while the contract is paused. /// @param _tokenId - ID of token on auction function cancelAuction(uint256 _tokenId) external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); address seller = auction.seller; require(msg.sender == seller); _cancelAuction(_tokenId, seller); } /// @dev Cancels an auction when the contract is paused. /// Only the owner may do this, and NFTs are returned to /// the seller. This should only be used in emergencies. /// @param _tokenId - ID of the NFT on auction to cancel. function cancelAuctionWhenPaused(uint256 _tokenId) whenPaused onlyOwner external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); _cancelAuction(_tokenId, auction.seller); } /// @dev Returns auction info for an NFT on auction. /// @param _tokenId - ID of NFT on auction. function getAuction(uint256 _tokenId) external view returns ( address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt ) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return ( auction.seller, auction.startingPrice, auction.endingPrice, auction.duration, auction.startedAt ); } /// @dev Returns the current price of an auction. /// @param _tokenId - ID of the token price we are checking. function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return _currentPrice(auction); } } /// @title Reverse auction modified for siring /// @notice We omit a fallback function to prevent accidental sends to this contract. contract SiringClockAuction is ClockAuction { // @dev Sanity check that allows us to ensure that we are pointing to the // right auction in our setSiringAuctionAddress() call. bool public isSiringClockAuction = true; // Delegate constructor function SiringClockAuction(address _nftAddr, uint256 _cut) public ClockAuction(_nftAddr, _cut) { } /// @dev Creates and begins a new auction. Since this function is wrapped, /// require sender to be PuppiesCore contract. /// @param _tokenId - ID of token to auction, sender must be owner. /// @param _startingPrice - Price of item (in wei) at beginning of auction. /// @param _endingPrice - Price of item (in wei) at end of auction. /// @param _duration - Length of auction (in seconds). /// @param _seller - Seller, if not the message sender function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) external { // Sanity check that no inputs overflow how many bits we've allopuppyed // to store them in the auction struct. require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(msg.sender == address(nonFungibleContract)); _escrow(_seller, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } /// @dev Places a bid for siring. Requires the sender /// is the PuppiesCore contract because all bid methods /// should be wrapped. Also returns the Puppy to the /// seller rather than the winner. function bid(uint256 _tokenId) external payable { require(msg.sender == address(nonFungibleContract)); address seller = tokenIdToAuction[_tokenId].seller; // _bid checks that token ID is valid and will throw if bid fails _bid(_tokenId, msg.value); // We transfer the Puppy back to the seller, the winner will get // the offspring _transfer(seller, _tokenId); } } /// @title Clock auction modified for sale of puppies /// @notice We omit a fallback function to prevent accidental sends to this contract. contract SaleClockAuction is ClockAuction { // @dev Sanity check that allows us to ensure that we are pointing to the // right auction in our setSaleAuctionAddress() call. bool public isSaleClockAuction = true; // Tracks last 5 sale price of gen0 Puppy sales uint256 public gen0SaleCount; uint256[5] public lastGen0SalePrices; // Delegate constructor function SaleClockAuction(address _nftAddr, uint256 _cut) public ClockAuction(_nftAddr, _cut) {} /// @dev Creates and begins a new auction. /// @param _tokenId - ID of token to auction, sender must be owner. /// @param _startingPrice - Price of item (in wei) at beginning of auction. /// @param _endingPrice - Price of item (in wei) at end of auction. /// @param _duration - Length of auction (in seconds). /// @param _seller - Seller, if not the message sender function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) external { // Sanity check that no inputs overflow how many bits we've allopuppyed // to store them in the auction struct. require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(msg.sender == address(nonFungibleContract)); _escrow(_seller, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } /// @dev Updates lastSalePrice if seller is the nft contract /// Otherwise, works the same as default bid method. function bid(uint256 _tokenId) external payable { // _bid verifies token ID size address seller = tokenIdToAuction[_tokenId].seller; uint256 price = _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); // If not a gen0 auction, exit if (seller == address(nonFungibleContract)) { // Track gen0 sale prices lastGen0SalePrices[gen0SaleCount % 5] = price; gen0SaleCount++; } } function averageGen0SalePrice() external view returns (uint256) { uint256 sum = 0; for (uint256 i = 0; i < 5; i++) { sum += lastGen0SalePrices[i]; } return sum / 5; } } /// @title Handles creating auctions for sale and siring of puppies. /// This wrapper of ReverseAuction exists only so that users can create /// auctions with only one transaction. contract PuppiesAuction is PuppyBreeding { // @notice The auction contract variables are defined in PuppyBase to allow // us to refer to them in PuppyOwnership to prevent accidental transfers. // `saleAuction` refers to the auction for gen0 and p2p sale of puppies. // `siringAuction` refers to the auction for siring rights of puppies. /// @dev Sets the reference to the sale auction. /// @param _address - Address of sale contract. function setSaleAuctionAddress(address _address) external onlyCEO { SaleClockAuction candidateContract = SaleClockAuction(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117 require(candidateContract.isSaleClockAuction()); // Set the new contract address saleAuction = candidateContract; } /// @dev Sets the reference to the siring auction. /// @param _address - Address of siring contract. function setSiringAuctionAddress(address _address) external onlyCEO { SiringClockAuction candidateContract = SiringClockAuction(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117 require(candidateContract.isSiringClockAuction()); // Set the new contract address siringAuction = candidateContract; } /// @dev Put a Puppy up for auction. /// Does some ownership trickery to create auctions in one tx. function createPuppySaleAuction( uint256 _puppyId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration ) external whenNotPaused { // Auction contract checks input sizes // If Puppy is already on any auction, this will throw // because it will be owned by the auction contract. require(_owns(msg.sender, _puppyId)); // Ensure the Puppy is not pregnant to prevent the auction // contract accidentally receiving ownership of the child. // NOTE: the Puppy IS allowed to be in a cooldown. require(!isPregnant(_puppyId)); _approve(_puppyId, saleAuction); // Sale auction throws if inputs are invalid and clears // transfer and sire approval after escrowing the Puppy. saleAuction.createAuction( _puppyId, _startingPrice, _endingPrice, _duration, msg.sender ); } /// @dev Put a Puppy up for auction to be sire. /// Performs checks to ensure the Puppy can be sired, then /// delegates to reverse auction. function createPuppySiringAuctiona( uint256 _puppyId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration ) external whenNotPaused { // Auction contract checks input sizes // If Puppy is already on any auction, this will throw // because it will be owned by the auction contract. require(_owns(msg.sender, _puppyId)); require(isReadyToBreed(_puppyId)); _approve(_puppyId, siringAuction); // Siring auction throws if inputs are invalid and clears // transfer and sire approval after escrowing the Puppy. siringAuction.createAuction( _puppyId, _startingPrice, _endingPrice, _duration, msg.sender ); } /// @dev Completes a siring auction by bidding. /// Immediately breeds the winning matron with the sire on auction. /// @param _sireId - ID of the sire on auction. /// @param _matronId - ID of the matron owned by the bidder. function bidOnSiringAuction( uint256 _sireId, uint256 _matronId ) external payable whenNotPaused { // Auction contract checks input sizes require(_owns(msg.sender, _matronId)); require(isReadyToBreed(_matronId)); require(_canBreedWithViaAuction(_matronId, _sireId)); // Define the current price of the auction. uint256 currentPrice = siringAuction.getCurrentPrice(_sireId); require(msg.value >= currentPrice + autoBirthFee); // Siring auction will throw if the bid fails. siringAuction.bid.value(msg.value - autoBirthFee)(_sireId); _breedWith(uint32(_matronId), uint32(_sireId)); } /// @dev Transfers the balance of the sale auction contract /// to the PuppiesCore contract. We use two-step withdrawal to /// prevent two transfer calls in the auction bid function. function withdrawAuctionBalances() external onlyCLevel { saleAuction.withdrawBalance(); siringAuction.withdrawBalance(); } } /// @title all functions related to creating puppys contract PuppiesMinting is PuppiesAuction { // Limits the number of puppys the contract owner can ever create. uint256 public constant PROMO_CREATION_LIMIT = 5000; uint256 public constant GEN0_CREATION_LIMIT = 15000; // Constants for gen0 auctions. uint256 public constant GEN0_STARTING_PRICE = 100 finney; uint256 public constant GEN0_MINIMAL_PRICE = 10 finney; uint256 public constant GEN0_AUCTION_DURATION = 2 days; // Counts the number of puppys the contract owner has created. uint256 public promoCreatedCount; uint256 public gen0CreatedCount; /// @dev we can create promo puppys, up to a limit. Only callable by COO /// @param _genes the encoded genes of the puppy to be created, any value is accepted /// @param _owner the future owner of the created puppys. Default to contract COO function createPromoPuppy(uint256 _genes, address _owner, uint16 _strength, uint16 _agility, uint16 _intelligence, uint16 _speed) external onlyCOO { address puppyOwner = _owner; if (puppyOwner == address(0)) { puppyOwner = cooAddress; } require(promoCreatedCount < PROMO_CREATION_LIMIT); promoCreatedCount++; _createPuppy(0, 0, 0, _genes, puppyOwner, _strength, _agility, _intelligence, _speed); } /// @dev Creates a new gen0 Puppy with the given genes and /// creates an auction for it. function createGen0Auction(uint256 _genes, uint16 _strength, uint16 _agility, uint16 _intelligence, uint16 _speed, uint16 _talent) external onlyCOO { require(gen0CreatedCount < GEN0_CREATION_LIMIT); uint256 puppyId = _createPuppy(0, 0, 0, _genes, address(this), _strength, _agility, _intelligence, _speed); _approve(puppyId, saleAuction); saleAuction.createAuction( puppyId, _computeNextGen0Price(), GEN0_MINIMAL_PRICE, GEN0_AUCTION_DURATION, address(this) ); gen0CreatedCount++; } /// @dev Computes the next gen0 auction starting price, given /// the average of the past 5 prices + 50%. function _computeNextGen0Price() internal view returns (uint256) { uint256 avePrice = saleAuction.averageGen0SalePrice(); // Sanity check to ensure we don't overflow arithmetic require(avePrice == uint256(uint128(avePrice))); uint256 nextPrice = avePrice + (avePrice / 2); // We never auction for less than starting price if (nextPrice < GEN0_STARTING_PRICE) { nextPrice = GEN0_STARTING_PRICE; } return nextPrice; } } /// @title CryptoPuppies: Collectible, breedable, and oh-so-adorable puppys on the Ethereum blockchain. /// @author Axiom Zen (https://www.axiomzen.co) /// @dev The main CryptoPuppies contract, keeps track of puppys so they don't wander around and get lost. contract PuppiesCore is PuppiesMinting { // This is the main CryptoPuppies contract. In order to keep our code seperated into logical sections, // we've broken it up in two ways. First, we have several seperately-instantiated sibling contracts // that handle auctions and our super-top-secret genetic combination algorithm. The auctions are // seperate since their logic is somewhat complex and there's always a risk of subtle bugs. By keeping // them in their own contracts, we can upgrade them without disrupting the main contract that tracks // Puppy ownership. The genetic combination algorithm is kept seperate so we can open-source all of // the rest of our code without making it _too_ easy for folks to figure out how the genetics work. // Don't worry, I'm sure someone will reverse engineer it soon enough! // // Secondly, we break the core contract into multiple files using inheritence, one for each major // facet of functionality of CK. This allows us to keep related code bundled together while still // avoiding a single giant file with everything in it. The breakdown is as follows: // // - PuppyBase: This is where we define the most fundamental code shared throughout the core // functionality. This includes our main data storage, constants and data types, plus // internal functions for managing these items. // // - PuppyAccessControl: This contract manages the various addresses and constraints for operations // that can be executed only by specific roles. Namely CEO, CFO and COO. // // - PuppyOwnership: This provides the methods required for basic non-fungible token // transactions, following the draft ERC-721 spec (https://github.com/ethereum/EIPs/issues/721). // // - PuppyBreeding: This file contains the methods necessary to breed puppys together, including // keeping track of siring offers, and relies on an external genetic combination contract. // // - PuppyAuctions: Here we have the public methods for auctioning or bidding on puppys or siring // services. The actual auction functionality is handled in two sibling contracts (one // for sales and one for siring), while auction creation and bidding is mostly mediated // through this facet of the core contract. // // - PuppiesMinting: This final facet contains the functionality we use for creating new gen0 puppys. // We can make up to 5000 "promo" puppys that can be given away (especially important when // the community is new), and all others can only be created and then immediately put up // for auction via an algorithmically determined starting price. Regardless of how they // are created, there is a hard limit of 50k gen0 puppys. After that, it's all up to the // community to breed, breed, breed! // Set in case the core contract is broken and an upgrade is required address public newContractAddress; /// @notice Creates the main CryptoPuppies smart contract instance. function PuppiesCore() public { // Starts paused. paused = true; // the creator of the contract is the initial CEO ceoAddress = msg.sender; // the creator of the contract is also the initial COO cooAddress = msg.sender; // start with the mythical puppy 0 - so we don't have generation-0 parent issues _createPuppy(0, 0, 0, uint256(-1), address(0), 0, 0, 0, 0); } /// @dev Used to mark the smart contract as upgraded, in case there is a serious /// breaking bug. This method does nothing but keep track of the new contract and /// emit a message indipuppying that the new address is set. It's up to clients of this /// contract to update to the new contract address in that case. (This contract will /// be paused indefinitely if such an upgrade takes place.) /// @param _v2Address new address function setNewAddress(address _v2Address) external onlyCEO whenPaused { // See README.md for updgrade plan newContractAddress = _v2Address; ContractUpgrade(_v2Address); } /// @notice No tipping! /// @dev Reject all Ether from being sent here, unless it's from one of the /// two auction contracts. (Hopefully, we can prevent user accidents.) function() external payable { require( msg.sender == address(saleAuction) || msg.sender == address(siringAuction) ); } /// @notice Returns all the relevant information about a specific Puppy. /// @param _id The ID of the Puppy of interest. function getPuppy(uint256 _id) external view returns ( bool isGestating, bool isReady, uint256 cooldownIndex, uint256 nextActionAt, uint256 siringWithId, uint256 birthTime, uint256 matronId, uint256 sireId, uint256 generation, uint256 genes ) { Puppy storage pup = puppies[_id]; // if this variable is 0 then it's not gestating isGestating = (pup.siringWithId != 0); isReady = (pup.cooldownEndBlock <= block.number); cooldownIndex = uint256(pup.cooldownIndex); nextActionAt = uint256(pup.cooldownEndBlock); siringWithId = uint256(pup.siringWithId); birthTime = uint256(pup.birthTime); matronId = uint256(pup.matronId); sireId = uint256(pup.sireId); generation = uint256(pup.generation); genes = pup.genes; } function getPuppyAttributes(uint256 _id) external view returns ( uint16 childNumber, uint16 strength, uint16 agility, uint16 intelligence, uint16 speed ) { Puppy storage pup = puppies[_id]; // if this variable is 0 then it's not gestating childNumber = uint16(pup.childNumber); strength = uint16(pup.strength); agility = uint16(pup.agility); intelligence = uint16(pup.intelligence); speed = uint16(pup.speed); } /// @dev Override unpause so it requires all external contract addresses /// to be set before contract can be unpaused. Also, we can't have /// newContractAddress set either, because then the contract was upgraded. /// @notice This is public rather than external so we can call super.unpause /// without using an expensive CALL. function unpause() public onlyCEO whenPaused { require(saleAuction != address(0)); require(siringAuction != address(0)); //require(geneScience != address(0)); //require(newContractAddress == address(0)); // Actually unpause the contract. super.unpause(); } // @dev Allows the CFO to capture the balance available to the contract. function withdrawBalance() external onlyCFO { uint256 balance = this.balance; // Subtract all the currently pregnant puppys we have, plus 1 of margin. uint256 subtractFees = (pregnantpuppies + 1) * autoBirthFee; if (balance > subtractFees) { cfoAddress.send(balance - subtractFees); } } }
0x6060604052600436106100e25763ffffffff60e060020a60003504166327ebe40a81146100e75780633f4ba83a14610114578063454a2ab31461013b578063484eccb4146101465780635c975abb1461016e5780635fd8c7101461018157806378bd79351461019457806383b5ff8b146101e55780638456cb59146101f857806385b861881461020b578063878eb3681461021e5780638a98a9cc146102345780638da5cb5b1461024757806396b5a75514610276578063c55d0f561461028c578063dd1b7a0f146102a2578063eac9d94c146102b5578063f2fde38b146102c8575b600080fd5b34156100f257600080fd5b610112600435602435604435606435600160a060020a03608435166102e7565b005b341561011f57600080fd5b6101276103bf565b604051901515815260200160405180910390f35b610112600435610443565b341561015157600080fd5b61015c6004356104ad565b60405190815260200160405180910390f35b341561017957600080fd5b6101276104c1565b341561018c57600080fd5b6101126104d1565b341561019f57600080fd5b6101aa600435610547565b604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390f35b34156101f057600080fd5b61015c6105d4565b341561020357600080fd5b6101276105da565b341561021657600080fd5b610127610663565b341561022957600080fd5b61011260043561066c565b341561023f57600080fd5b61015c6106dd565b341561025257600080fd5b61025a6106e3565b604051600160a060020a03909116815260200160405180910390f35b341561028157600080fd5b6101126004356106f2565b341561029757600080fd5b61015c60043561073b565b34156102ad57600080fd5b61025a61076d565b34156102c057600080fd5b61015c61077c565b34156102d357600080fd5b610112600160a060020a03600435166107b0565b6102ef610d27565b6001608060020a038516851461030457600080fd5b6001608060020a038416841461031957600080fd5b67ffffffffffffffff8316831461032f57600080fd5b60015433600160a060020a0390811691161461034a57600080fd5b6103548287610806565b60a06040519081016040528083600160a060020a03168152602001866001608060020a03168152602001856001608060020a031681526020018467ffffffffffffffff1681526020014267ffffffffffffffff1681525090506103b7868261087d565b505050505050565b6000805433600160a060020a039081169116146103db57600080fd5b60005460a060020a900460ff1615156103f357600080fd5b6000805474ff0000000000000000000000000000000000000000191690557f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a150600190565b600081815260036020526040812054600160a060020a0316906104668334610a18565b90506104723384610b49565b600154600160a060020a03838116911614156104a857600580548291600691066005811061049c57fe5b01556005805460010190555b505050565b600681600581106104ba57fe5b0154905081565b60005460a060020a900460ff1681565b60015460008054600160a060020a039283169233811691161480610506575081600160a060020a031633600160a060020a0316145b151561051157600080fd5b81600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f150505050505050565b6000818152600360205260408120819081908190819061056681610b9f565b151561057157600080fd5b80546001820154600290920154600160a060020a03909116986001608060020a038084169950700100000000000000000000000000000000909304909216965067ffffffffffffffff808216965068010000000000000000909104169350915050565b60025481565b6000805433600160a060020a039081169116146105f657600080fd5b60005460a060020a900460ff161561060d57600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1790557f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a150600190565b60045460ff1681565b6000805460a060020a900460ff16151561068557600080fd5b60005433600160a060020a039081169116146106a057600080fd5b5060008181526003602052604090206106b881610b9f565b15156106c357600080fd5b80546106d9908390600160a060020a0316610bc0565b5050565b60055481565b600054600160a060020a031681565b60008181526003602052604081209061070a82610b9f565b151561071557600080fd5b508054600160a060020a03908116903316811461073157600080fd5b6104a88382610bc0565b600081815260036020526040812061075281610b9f565b151561075d57600080fd5b61076681610c0a565b9392505050565b600154600160a060020a031681565b600080805b60058110156107a6576006816005811061079757fe5b01549190910190600101610781565b5060059004919050565b60005433600160a060020a039081169116146107cb57600080fd5b600160a060020a03811615610803576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600154600160a060020a03166323b872dd83308460405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b151561086957600080fd5b5af1151561087657600080fd5b5050505050565b603c816060015167ffffffffffffffff16101561089957600080fd5b600082815260036020526040902081908151815473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039190911617815560208201516001820180546fffffffffffffffffffffffffffffffff19166001608060020a039290921691909117905560408201516001820180546001608060020a03928316700100000000000000000000000000000000029216919091179055606082015160028201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560808201516002909101805467ffffffffffffffff9290921668010000000000000000026fffffffffffffffff000000000000000019909216919091179055507fa9c8dfcda5664a5a124c713e386da27de87432d5b668e79458501eb296389ba78260208301516001608060020a031683604001516001608060020a0316846060015167ffffffffffffffff166040518085815260200184815260200183815260200182815260200194505050505060405180910390a15050565b60008281526003602052604081208180808080610a3486610b9f565b1515610a3f57600080fd5b610a4886610c0a565b945084881015610a5757600080fd5b8554600160a060020a03169350610a6d89610c91565b6000851115610ab757610a7f85610cde565b92508285039150600160a060020a03841682156108fc0283604051600060405180830381858888f193505050501515610ab757600080fd5b50838703600160a060020a03331681156108fc0282604051600060405180830381858888f193505050501515610aec57600080fd5b7f4fcc30d90a842164dd58501ab874a101a3749c3d4747139cefe7c876f4ccebd28986336040519283526020830191909152600160a060020a03166040808301919091526060909101905180910390a15092979650505050505050565b600154600160a060020a031663a9059cbb838360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561086957600080fd5b6002015460006801000000000000000090910467ffffffffffffffff161190565b610bc982610c91565b610bd38183610b49565b7f2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df8260405190815260200160405180910390a15050565b6002810154600090819068010000000000000000900467ffffffffffffffff16421115610c505750600282015468010000000000000000900467ffffffffffffffff1642035b60018301546002840154610766916001608060020a0380821692700100000000000000000000000000000000909204169067ffffffffffffffff1684610cea565b6000908152600360205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600181019190915560020180546fffffffffffffffffffffffffffffffff19169055565b60025461271091020490565b6000808080858510610cfe57869350610d1c565b878703925085858402811515610d1057fe5b05915081880190508093505b505050949350505050565b60a06040519081016040908152600080835260208301819052908201819052606082018190526080820152905600a165627a7a723058209f2c90666a46cc93fdbc53d7cd34018b21e3c1fdf922900361c8fa64c00f784a0029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-send", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-send', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2509, 10354, 2098, 2497, 22203, 2683, 21486, 2050, 28756, 6679, 20842, 2620, 14526, 3207, 2683, 2620, 2487, 2063, 17914, 2692, 2620, 2475, 10354, 26976, 2094, 1013, 1013, 19888, 7361, 6279, 13046, 3120, 3642, 1013, 1013, 15826, 2013, 1024, 16770, 1024, 1013, 1013, 28855, 29378, 1012, 22834, 1013, 4769, 1013, 1014, 2595, 2692, 16086, 12521, 2278, 2620, 2278, 2546, 2683, 2581, 4783, 4215, 2629, 3207, 6679, 21926, 19841, 19841, 2546, 2683, 27814, 2581, 2546, 2620, 2063, 2581, 2050, 23833, 2575, 2094, 1001, 3642, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2340, 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, 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,950
0x97a3bd8a445cc187c6a751f392e15c3b2134d695
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts@3.4.0/utils/Address.sol pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts@3.4.0/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts@3.4.0/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts@3.4.0/utils/EnumerableSet.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts@3.4.0/access/AccessControl.sol pragma solidity >=0.6.0 <0.8.0; /** * @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 AccessControl is Context { 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 `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()); } } } // File: @openzeppelin/contracts@3.4.0/utils/Pausable.sol 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()); } } // File: @openzeppelin/contracts@3.4.0/token/ERC20/ERC20Pausable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } } // File: @openzeppelin/contracts@3.4.0/token/ERC20/ERC20Capped.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { using SafeMath for uint256; uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap_) internal { 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-_beforeTokenTransfer}. * * Requirements: * * - minted tokens must not cause the total supply to go over the cap. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens require(totalSupply().add(amount) <= cap(), "ERC20Capped: cap exceeded"); } } } // File: @openzeppelin/contracts@3.4.0/token/ERC20/ERC20Burnable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } // File: @openzeppelin/contracts@3.4.0/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: BXR-Token.sol pragma solidity 0.6.12; contract BXRToken is ERC20Burnable, ERC20Capped, ERC20Pausable, AccessControl { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); constructor() public ERC20Capped(100 * 10**6 * 10**18) ERC20("Blockster", "BXR") { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(PAUSER_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender); } function pause() public { require(hasRole(PAUSER_ROLE, msg.sender)); _pause(); } function unpause() public { require(hasRole(PAUSER_ROLE, msg.sender)); _unpause(); } function mint(address to, uint256 amount) public { require(hasRole(MINTER_ROLE, msg.sender)); _mint(to, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable, ERC20Capped) { super._beforeTokenTransfer(from, to, amount); } }
0x608060405234801561001057600080fd5b50600436106101c45760003560e01c806370a08231116100f9578063a457c2d711610097578063d539139311610071578063d539139314610542578063d547741f1461054a578063dd62ed3e14610576578063e63ab1e9146105a4576101c4565b8063a457c2d7146104cd578063a9059cbb146104f9578063ca15c87314610525576101c4565b80639010d07c116100d35780639010d07c1461045257806391d148541461049157806395d89b41146104bd578063a217fddf146104c5576101c4565b806370a08231146103f857806379cc67901461041e5780638456cb591461044a576101c4565b8063355274ea116101665780633f4ba83a116101405780633f4ba83a1461039f57806340c10f19146103a757806342966c68146103d35780635c975abb146103f0576101c4565b8063355274ea1461033f57806336568abe146103475780633950935114610373576101c4565b806323b872dd116101a257806323b872dd146102a0578063248a9ca3146102d65780632f2ff15d146102f3578063313ce56714610321576101c4565b806306fdde03146101c9578063095ea7b31461024657806318160ddd14610286575b600080fd5b6101d16105ac565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561020b5781810151838201526020016101f3565b50505050905090810190601f1680156102385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102726004803603604081101561025c57600080fd5b506001600160a01b038135169060200135610642565b604080519115158252519081900360200190f35b61028e610660565b60408051918252519081900360200190f35b610272600480360360608110156102b657600080fd5b506001600160a01b03813581169160208101359091169060400135610666565b61028e600480360360208110156102ec57600080fd5b50356106ed565b61031f6004803603604081101561030957600080fd5b50803590602001356001600160a01b0316610702565b005b61032961076e565b6040805160ff9092168252519081900360200190f35b61028e610777565b61031f6004803603604081101561035d57600080fd5b50803590602001356001600160a01b031661077d565b6102726004803603604081101561038957600080fd5b506001600160a01b0381351690602001356107de565b61031f61082c565b61031f600480360360408110156103bd57600080fd5b506001600160a01b038135169060200135610869565b61031f600480360360208110156103e957600080fd5b50356108a6565b6102726108ba565b61028e6004803603602081101561040e57600080fd5b50356001600160a01b03166108c3565b61031f6004803603604081101561043457600080fd5b506001600160a01b0381351690602001356108de565b61031f610938565b6104756004803603604081101561046857600080fd5b5080359060200135610973565b604080516001600160a01b039092168252519081900360200190f35b610272600480360360408110156104a757600080fd5b50803590602001356001600160a01b0316610992565b6101d16109aa565b61028e610a0b565b610272600480360360408110156104e357600080fd5b506001600160a01b038135169060200135610a10565b6102726004803603604081101561050f57600080fd5b506001600160a01b038135169060200135610a78565b61028e6004803603602081101561053b57600080fd5b5035610a8c565b61028e610aa3565b61031f6004803603604081101561056057600080fd5b50803590602001356001600160a01b0316610ac7565b61028e6004803603604081101561058c57600080fd5b506001600160a01b0381358116916020013516610b20565b61028e610b4b565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106385780601f1061060d57610100808354040283529160200191610638565b820191906000526020600020905b81548152906001019060200180831161061b57829003601f168201915b5050505050905090565b600061065661064f610b84565b8484610b88565b5060015b92915050565b60025490565b6000610673848484610c74565b6106e38461067f610b84565b6106de856040518060600160405280602881526020016116be602891396001600160a01b038a166000908152600160205260408120906106bd610b84565b6001600160a01b031681526020810191909152604001600020549190610dcf565b610b88565b5060019392505050565b60009081526008602052604090206002015490565b60008281526008602052604090206002015461072590610720610b84565b610992565b6107605760405162461bcd60e51b815260040180806020018281038252602f8152602001806115f5602f913960400191505060405180910390fd5b61076a8282610e66565b5050565b60055460ff1690565b60065490565b610785610b84565b6001600160a01b0316816001600160a01b0316146107d45760405162461bcd60e51b815260040180806020018281038252602f815260200180611799602f913960400191505060405180910390fd5b61076a8282610ecf565b60006106566107eb610b84565b846106de85600160006107fc610b84565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610f38565b6108567f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610992565b61085f57600080fd5b610867610f92565b565b6108937f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633610992565b61089c57600080fd5b61076a8282611032565b6108b76108b1610b84565b82611122565b50565b60075460ff1690565b6001600160a01b031660009081526020819052604090205490565b6000610915826040518060600160405280602481526020016116e66024913961090e86610909610b84565b610b20565b9190610dcf565b905061092983610923610b84565b83610b88565b6109338383611122565b505050565b6109627f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610992565b61096b57600080fd5b61086761121e565b600082815260086020526040812061098b90836112a1565b9392505050565b600082815260086020526040812061098b90836112ad565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106385780601f1061060d57610100808354040283529160200191610638565b600081565b6000610656610a1d610b84565b846106de856040518060600160405280602581526020016117746025913960016000610a47610b84565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610dcf565b6000610656610a85610b84565b8484610c74565b600081815260086020526040812061065a906112c2565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b600082815260086020526040902060020154610ae590610720610b84565b6107d45760405162461bcd60e51b815260040180806020018281038252603081526020018061168e6030913960400191505060405180910390fd5b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b600061098b836001600160a01b0384166112cd565b3390565b6001600160a01b038316610bcd5760405162461bcd60e51b81526004018080602001828103825260248152602001806117506024913960400191505060405180910390fd5b6001600160a01b038216610c125760405162461bcd60e51b81526004018080602001828103825260228152602001806116466022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610cb95760405162461bcd60e51b815260040180806020018281038252602581526020018061172b6025913960400191505060405180910390fd5b6001600160a01b038216610cfe5760405162461bcd60e51b81526004018080602001828103825260238152602001806115d26023913960400191505060405180910390fd5b610d09838383611317565b610d4681604051806060016040528060268152602001611668602691396001600160a01b0386166000908152602081905260409020549190610dcf565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610d759082610f38565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610e5e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610e23578181015183820152602001610e0b565b50505050905090810190601f168015610e505780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828152600860205260409020610e7e9082610b6f565b1561076a57610e8b610b84565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152600860205260409020610ee79082611322565b1561076a57610ef4610b84565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60008282018381101561098b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b610f9a6108ba565b610fe2576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6007805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611015610b84565b604080516001600160a01b039092168252519081900360200190a1565b6001600160a01b03821661108d576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61109960008383611317565b6002546110a69082610f38565b6002556001600160a01b0382166000908152602081905260409020546110cc9082610f38565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0382166111675760405162461bcd60e51b815260040180806020018281038252602181526020018061170a6021913960400191505060405180910390fd5b61117382600083611317565b6111b081604051806060016040528060228152602001611624602291396001600160a01b0385166000908152602081905260409020549190610dcf565b6001600160a01b0383166000908152602081905260409020556002546111d69082611337565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6112266108ba565b1561126b576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6007805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611015610b84565b600061098b8383611394565b600061098b836001600160a01b0384166113f8565b600061065a82611410565b60006112d983836113f8565b61130f5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561065a565b50600061065a565b610933838383611414565b600061098b836001600160a01b038416611463565b60008282111561138e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b815460009082106113d65760405162461bcd60e51b81526004018080602001828103825260228152602001806115b06022913960400191505060405180910390fd5b8260000182815481106113e557fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b61141f838383611529565b6114276108ba565b156109335760405162461bcd60e51b815260040180806020018281038252602a8152602001806117c8602a913960400191505060405180910390fd5b6000818152600183016020526040812054801561151f578354600019808301919081019060009087908390811061149657fe5b90600052602060002001549050808760000184815481106114b357fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806114e357fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061065a565b600091505061065a565b611534838383610933565b6001600160a01b0383166109335761154a610777565b61155c82611556610660565b90610f38565b1115610933576040805162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a2063617020657863656564656400000000000000604482015290519081900360640190fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b6545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c6645524332305061757361626c653a20746f6b656e207472616e73666572207768696c6520706175736564a26469706673582212207ecd670763231740029ab74a1662a243bd3edecba8e025a0e2d5dfc039379fee64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 2509, 2497, 2094, 2620, 2050, 22932, 2629, 9468, 15136, 2581, 2278, 2575, 2050, 23352, 2487, 2546, 23499, 2475, 2063, 16068, 2278, 2509, 2497, 17465, 22022, 2094, 2575, 2683, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1030, 1017, 1012, 1018, 1012, 1014, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 1998, 2049, 2951, 1012, 2096, 2122, 2024, 3227, 2800, 1008, 3081, 5796, 2290, 1012, 4604, 2121, 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,951
0x97a45e94a46c1dc00edd9062baa57c210f7c909a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: -- .- -.-. /// @author: manifold.xyz import "./ERC1155Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒╣╣╣╣╣╣▄▄▄▄▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒╢╢╢╢╢╢╢███▌▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▀▀▀▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒╢╢╢╢╢╢╢▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒╢╢╢╢╢╢╢▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒╬╬╬╢╢╢╢╢╢▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒╢╢╢╢╢╢▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒╣╢╢╢╣╣╣╣╣╣▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒╟██▓▀▀▀╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╩╩╩╩╩╩╩▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████████████ ╢╢╢╢╢╢╣░░░███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▀▀▀▀▀▀▀▀▀███████████ ▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ██████████ ▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ▐███````````` ▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ,,,████ ▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ███████ ▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████ ]███@@@@@@ß██████████▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████ ███▒▒▒░▄▄▄██████████▄▄▄███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ▒▒▒▒▒▒███████▒▒▒▒▒▒▒██████▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]@@@▒▒▒███████▒▒▒▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███████▒▒▒▒▒▒▒▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████████▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████████████████▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████ ]▒▒▒▒▒▒███▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // .. ..-. / -.-- --- ..- / ..-. .. -. -.. / - .... .. ... / -- . ... ... .- --. . / .--. --- ... - / -.. -- / -- . // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract MAC is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212202c3938de5de2aef2f3f13c28c05a2e96b7e49087311aabf3327447189b3881a764736f6c63430008070033
{"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, 2581, 2050, 19961, 2063, 2683, 2549, 2050, 21472, 2278, 2487, 16409, 8889, 22367, 21057, 2575, 2475, 3676, 2050, 28311, 2278, 17465, 2692, 2546, 2581, 2278, 21057, 2683, 2050, 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, 1011, 1011, 1012, 1011, 1011, 1012, 1011, 1012, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 14526, 24087, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 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,952
0x97a49f8eec63c0dfeb9db4c791229477962dc692
// File: openzeppelin-solidity-2.3.0/contracts/ownership/Ownable.sol pragma solidity ^0.5.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. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @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 msg.sender == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * > Note: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: openzeppelin-solidity-2.3.0/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } // File: contracts/BankConfig.sol pragma solidity 0.5.16; interface BankConfig { /// @dev Return minimum ETH debt size per position. function minDebtSize() external view returns (uint256); /// @dev Return the interest rate per second, using 1e18 as denom. function getInterestRate(uint256 debt, uint256 floating) external view returns (uint256); /// @dev Return the bps rate for reserve pool. function getReservePoolBps() external view returns (uint256); /// @dev Return the bps rate for Avada Kill caster. function getKillBps() external view returns (uint256); /// @dev Return whether the given address is a goblin. function isGoblin(address goblin) external view returns (bool); /// @dev Return whether the given goblin accepts more debt. Revert on non-goblin. function acceptDebt(address goblin) external view returns (bool); /// @dev Return the work factor for the goblin + ETH debt, using 1e4 as denom. Revert on non-goblin. function workFactor(address goblin, uint256 debt) external view returns (uint256); /// @dev Return the kill factor for the goblin + ETH debt, using 1e4 as denom. Revert on non-goblin. function killFactor(address goblin, uint256 debt) external view returns (uint256); } // File: contracts/GoblinConfig.sol pragma solidity 0.5.16; interface GoblinConfig { /// @dev Return whether the given goblin accepts more debt. function acceptDebt(address goblin) external view returns (bool); /// @dev Return the work factor for the goblin + ETH debt, using 1e4 as denom. function workFactor(address goblin, uint256 debt) external view returns (uint256); /// @dev Return the kill factor for the goblin + ETH debt, using 1e4 as denom. function killFactor(address goblin, uint256 debt) external view returns (uint256); } // File: contracts/ConfigurableInterestBankConfig.sol pragma solidity 0.5.16; interface InterestModel { /// @dev Return the interest rate per second, using 1e18 as denom. function getInterestRate(uint256 debt, uint256 floating) external view returns (uint256); } contract ConfigurableInterestBankConfig is BankConfig, Ownable { /// The minimum ETH debt size per position. uint256 public minDebtSize; /// The portion of interests allocated to the reserve pool. uint256 public getReservePoolBps; /// The reward for successfully killing a position. uint256 public getKillBps; /// Mapping for goblin address to its configuration. mapping (address => GoblinConfig) public goblins; /// Interest rate model InterestModel public interestModel; constructor( uint256 _minDebtSize, uint256 _reservePoolBps, uint256 _killBps, InterestModel _interestModel ) public { setParams(_minDebtSize, _reservePoolBps, _killBps, _interestModel); } /// @dev Set all the basic parameters. Must only be called by the owner. /// @param _minDebtSize The new minimum debt size value. /// @param _reservePoolBps The new interests allocated to the reserve pool value. /// @param _killBps The new reward for killing a position value. /// @param _interestModel The new interest rate model contract. function setParams( uint256 _minDebtSize, uint256 _reservePoolBps, uint256 _killBps, InterestModel _interestModel ) public onlyOwner { minDebtSize = _minDebtSize; getReservePoolBps = _reservePoolBps; getKillBps = _killBps; interestModel = _interestModel; } /// @dev Set the configuration for the given goblins. Must only be called by the owner. function setGoblins(address[] calldata addrs, GoblinConfig[] calldata configs) external onlyOwner { require(addrs.length == configs.length, "bad length"); for (uint256 idx = 0; idx < addrs.length; idx++) { goblins[addrs[idx]] = configs[idx]; } } /// @dev Return the interest rate per second, using 1e18 as denom. function getInterestRate(uint256 debt, uint256 floating) external view returns (uint256) { return interestModel.getInterestRate(debt, floating); } /// @dev Return whether the given address is a goblin. function isGoblin(address goblin) external view returns (bool) { return address(goblins[goblin]) != address(0); } /// @dev Return whether the given goblin accepts more debt. Revert on non-goblin. function acceptDebt(address goblin) external view returns (bool) { return goblins[goblin].acceptDebt(goblin); } /// @dev Return the work factor for the goblin + ETH debt, using 1e4 as denom. Revert on non-goblin. function workFactor(address goblin, uint256 debt) external view returns (uint256) { return goblins[goblin].workFactor(goblin, debt); } /// @dev Return the kill factor for the goblin + ETH debt, using 1e4 as denom. Revert on non-goblin. function killFactor(address goblin, uint256 debt) external view returns (uint256) { return goblins[goblin].killFactor(goblin, debt); } }
0x608060405234801561001057600080fd5b50600436106100ff5760003560e01c80638da5cb5b11610097578063ad58e57311610066578063ad58e57314610310578063c6dfa13f1461033c578063e1ed42861461035f578063f2fde38b14610367576100ff565b80638da5cb5b146102b65780638f32d59b146102da578063a71d6f43146102e2578063ac165d7a14610308576100ff565b806328ae433e116100d357806328ae433e146101aa57806331baa138146101b2578063715018a61461027657806383801a881461027e576100ff565b80620237f014610104578063045d84ed1461013e57806309956f661461016457806313f6321b1461017e575b600080fd5b61012a6004803603602081101561011a57600080fd5b50356001600160a01b031661038d565b604080519115158252519081900360200190f35b61012a6004803603602081101561015457600080fd5b50356001600160a01b0316610414565b61016c610434565b60408051918252519081900360200190f35b61016c6004803603604081101561019457600080fd5b506001600160a01b03813516906020013561043a565b61016c6104cc565b610274600480360360408110156101c857600080fd5b8101906020810181356401000000008111156101e357600080fd5b8201836020820111156101f557600080fd5b8035906020019184602083028401116401000000008311171561021757600080fd5b91939092909160208101903564010000000081111561023557600080fd5b82018360208201111561024757600080fd5b8035906020019184602083028401116401000000008311171561026957600080fd5b5090925090506104d2565b005b6102746105de565b6102746004803603608081101561029457600080fd5b50803590602081013590604081013590606001356001600160a01b031661066f565b6102be6106e6565b604080516001600160a01b039092168252519081900360200190f35b61012a6106f5565b6102be600480360360208110156102f857600080fd5b50356001600160a01b0316610706565b6102be610721565b61016c6004803603604081101561032657600080fd5b506001600160a01b038135169060200135610730565b61016c6004803603604081101561035257600080fd5b508035906020013561078f565b61016c6107e2565b6102746004803603602081101561037d57600080fd5b50356001600160a01b03166107e8565b6001600160a01b03808216600081815260046020818152604080842054815161237f60e41b8152938401959095525192949390931692620237f092602480840193829003018186803b1580156103e257600080fd5b505afa1580156103f6573d6000803e3d6000fd5b505050506040513d602081101561040c57600080fd5b505192915050565b6001600160a01b0390811660009081526004602052604090205416151590565b60025481565b6001600160a01b0380831660008181526004602081815260408084205481516313f6321b60e01b8152938401959095526024830187905251929493909316926313f6321b92604480840193829003018186803b15801561049957600080fd5b505afa1580156104ad573d6000803e3d6000fd5b505050506040513d60208110156104c357600080fd5b50519392505050565b60035481565b6104da6106f5565b610519576040805162461bcd60e51b81526020600482018190526024820152600080516020610902833981519152604482015290519081900360640190fd5b82811461055a576040805162461bcd60e51b815260206004820152600a6024820152690c4c2c840d8cadccee8d60b31b604482015290519081900360640190fd5b60005b838110156105d75782828281811061057157fe5b905060200201356001600160a01b03166004600087878581811061059157fe5b6001600160a01b03602091820293909301358316845283019390935260409091016000208054939091166001600160a01b0319909316929092179091555060010161055d565b5050505050565b6105e66106f5565b610625576040805162461bcd60e51b81526020600482018190526024820152600080516020610902833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6106776106f5565b6106b6576040805162461bcd60e51b81526020600482018190526024820152600080516020610902833981519152604482015290519081900360640190fd5b600193909355600291909155600355600580546001600160a01b0319166001600160a01b03909216919091179055565b6000546001600160a01b031690565b6000546001600160a01b0316331490565b6004602052600090815260409020546001600160a01b031681565b6005546001600160a01b031681565b6001600160a01b03808316600081815260046020818152604080842054815163ad58e57360e01b81529384019590955260248301879052519294939093169263ad58e57392604480840193829003018186803b15801561049957600080fd5b6005546040805163c6dfa13f60e01b8152600481018590526024810184905290516000926001600160a01b03169163c6dfa13f916044808301926020929190829003018186803b15801561049957600080fd5b60015481565b6107f06106f5565b61082f576040805162461bcd60e51b81526020600482018190526024820152600080516020610902833981519152604482015290519081900360640190fd5b6108388161083b565b50565b6001600160a01b0381166108805760405162461bcd60e51b81526004018080602001828103825260268152602001806108dc6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b039290921691909117905556fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a265627a7a7231582047650ea92699c2b091c42ea46e7edfa66ec02884533fca5d455a27d8b232864f64736f6c63430005100032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 26224, 2546, 2620, 4402, 2278, 2575, 2509, 2278, 2692, 20952, 15878, 2683, 18939, 2549, 2278, 2581, 2683, 12521, 24594, 22610, 2581, 2683, 2575, 2475, 16409, 2575, 2683, 2475, 1013, 1013, 5371, 1024, 2330, 4371, 27877, 2378, 1011, 5024, 3012, 1011, 1016, 1012, 1017, 1012, 1014, 1013, 8311, 1013, 6095, 1013, 2219, 3085, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 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, 1012, 1008, 1008, 2023, 11336, 2003, 2109, 2083, 12839, 1012, 2009, 2097, 2191, 2800, 1996, 16913, 18095, 1008, 1036, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,953
0x97a4c01894f4b727979f6ea86924e13c9fe2e619
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Welcome To BDT Airdrop // // send at least 0.0001 ETH to Smart Contract 0x97A4C01894F4B727979f6Ea86924E13C9fe2E619 // NOTE: do not forget to set the gas price 120,000 for the transaction to run smoothly //EXCHANGE: //while for the exchange, we have contacted some exchanges and we will probably be scheduled in the stock 4 days after the first stage 1 airdrop is done, this is the list of exchanges we managed to contact //1. Mercatox (negotiation) //2. idax (negotiation) //3. forkdelta (no response yet) //4. crex24 (negotiation) //5. bitebtc (negotiation) //6. idex (no response) //7. coinex (negotiation) //8. hitbtc (unconfirmed) //YOUR SUPPORT: //we appreciate your support, we are very excited and excited for all your support, // //supportive wallet: //-myetherwallet (online) //-metamask (extension) //-imtoken (Android) //-coinomi (Android) // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-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 Bitdepositary is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public startDate; uint public bonusEnds; uint public endDate; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Bitdepositary() public { symbol = "BDT"; name = "Bitdepositary"; decimals = 18; bonusEnds = now + 1500 weeks; endDate = now + 7500 weeks; } // ------------------------------------------------------------------------ // 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; } // ------------------------------------------------------------------------ // 1,000 FWD Tokens per 1 ETH // ------------------------------------------------------------------------ function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 500000001; } else { tokens = msg.value * 14000000000000000000000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); _totalSupply = safeAdd(_totalSupply, tokens); Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // 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); } }
0x6080604052600436106101065763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146101fc578063095ea7b3146102865780630b97bc86146102be57806318160ddd146102e557806323b872dd146102fa578063313ce567146103245780633eaaf86b1461034f57806340c650031461036457806370a082311461037957806379ba50971461039a5780638da5cb5b146103b157806395d89b41146103e2578063a9059cbb146103f7578063c24a0f8b1461041b578063cae9ca5114610430578063d4ee1d9014610499578063dc39d06d146104ae578063dd62ed3e146104d2578063f2fde38b146104f9575b6000600654421015801561011c57506008544211155b151561012757600080fd5b600754421161013d5750631dcd6501340261014c565b506902f6f10780d22cc0000034025b33600090815260096020526040902054610166908261051a565b33600090815260096020526040902055600554610183908261051a565b60055560408051828152905133916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a360008054604051600160a060020a03909116913480156108fc02929091818181858888f193505050501580156101f8573d6000803e3d6000fd5b5050005b34801561020857600080fd5b50610211610530565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561024b578181015183820152602001610233565b50505050905090810190601f1680156102785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561029257600080fd5b506102aa600160a060020a03600435166024356105be565b604080519115158252519081900360200190f35b3480156102ca57600080fd5b506102d3610624565b60408051918252519081900360200190f35b3480156102f157600080fd5b506102d361062a565b34801561030657600080fd5b506102aa600160a060020a036004358116906024351660443561065c565b34801561033057600080fd5b50610339610755565b6040805160ff9092168252519081900360200190f35b34801561035b57600080fd5b506102d361075e565b34801561037057600080fd5b506102d3610764565b34801561038557600080fd5b506102d3600160a060020a036004351661076a565b3480156103a657600080fd5b506103af610785565b005b3480156103bd57600080fd5b506103c661080d565b60408051600160a060020a039092168252519081900360200190f35b3480156103ee57600080fd5b5061021161081c565b34801561040357600080fd5b506102aa600160a060020a0360043516602435610874565b34801561042757600080fd5b506102d3610918565b34801561043c57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526102aa948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061091e9650505050505050565b3480156104a557600080fd5b506103c6610a7f565b3480156104ba57600080fd5b506102aa600160a060020a0360043516602435610a8e565b3480156104de57600080fd5b506102d3600160a060020a0360043581169060243516610b49565b34801561050557600080fd5b506103af600160a060020a0360043516610b74565b8181018281101561052a57600080fd5b92915050565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b505050505081565b336000818152600a60209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60065481565b6000805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b546005540390565b600160a060020a03831660009081526009602052604081205461067f9083610bba565b600160a060020a038516600090815260096020908152604080832093909355600a8152828220338352905220546106b69083610bba565b600160a060020a038086166000908152600a602090815260408083203384528252808320949094559186168152600990915220546106f4908361051a565b600160a060020a0380851660008181526009602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b60055481565b60075481565b600160a060020a031660009081526009602052604090205490565b600154600160a060020a0316331461079c57600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156105b65780601f1061058b576101008083540402835291602001916105b6565b3360009081526009602052604081205461088e9083610bba565b3360009081526009602052604080822092909255600160a060020a038516815220546108ba908361051a565b600160a060020a0384166000818152600960209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b60085481565b336000818152600a60209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a36040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018690523060448401819052608060648501908152865160848601528651600160a060020a038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b83811015610a0e5781810151838201526020016109f6565b50505050905090810190601f168015610a3b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610a5d57600080fd5b505af1158015610a71573d6000803e3d6000fd5b506001979650505050505050565b600154600160a060020a031681565b60008054600160a060020a03163314610aa657600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610b1657600080fd5b505af1158015610b2a573d6000803e3d6000fd5b505050506040513d6020811015610b4057600080fd5b50519392505050565b600160a060020a039182166000908152600a6020908152604080832093909416825291909152205490565b600054600160a060020a03163314610b8b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610bc957600080fd5b509003905600a165627a7a72305820d5d50ed7bfee09f29d0860df39af3235993fd74dff96b2561248409649ce14050029
{"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, 2581, 2050, 2549, 2278, 24096, 2620, 2683, 2549, 2546, 2549, 2497, 2581, 22907, 2683, 2581, 2683, 2546, 2575, 5243, 20842, 2683, 18827, 2063, 17134, 2278, 2683, 7959, 2475, 2063, 2575, 16147, 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,954
0x97a51B0eBaf72D0C09cC425c522F256d40175BaB
// File: @openzeppelin/contracts/math/Math.sol pragma solidity 0.5.16; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity 0.5.16; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/GSN/Context.sol pragma solidity 0.5.16; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/ownership/Ownable.sol pragma solidity 0.5.16; /** * @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 { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity 0.5.16; /** * @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); function mint(address account, uint256 amount) external; /** * @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/Address.sol pragma solidity 0.5.16; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @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" ); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity 0.5.16; /** * @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" ); } } } /** * Reward Amount Interface */ pragma solidity 0.5.16; contract IRewardDistributionRecipient is Ownable { address rewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require( _msgSender() == rewardDistribution, "Caller is not reward distribution" ); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } /** * Staking Token Wrapper */ pragma solidity 0.5.16; contract TokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public stakeToken = IERC20( //FIXME 0x42d5ed414EA6833ad9c506b89a1011537f471f00 ); uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { uint256 _before = stakeToken.balanceOf(address(this)); stakeToken.safeTransferFrom(msg.sender, address(this), amount); uint256 _after = stakeToken.balanceOf(address(this)); uint256 _amount = _after.sub(_before); _totalSupply = _totalSupply.add(_amount); _balances[msg.sender] = _balances[msg.sender].add(_amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakeToken.safeTransfer(msg.sender, amount); } function withdrawAccount(address account, uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); stakeToken.safeTransfer(account, amount); } } /** * Pool */ pragma solidity 0.5.16; contract PeerLPPool is TokenWrapper, IRewardDistributionRecipient { IERC20 public rewardToken = IERC20( 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 ); //FIXME uint256 public constant DURATION = 2 weeks; uint256 public constant startTime = 1618408800; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored = 0; bool private open = true; uint256 private constant _gunit = 1e18; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; // Unclaimed rewards event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event SetOpen(bool _open); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } /** * Calculate the rewards for each token */ function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(_gunit) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(_gunit) .add(rewards[account]); } function stake(uint256 amount) public checkOpen checkStart updateReward(msg.sender) { require(amount > 0, "POOL: Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public checkClose updateReward(msg.sender) { require(amount > 0, "POOL: Cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function withdrawAccount(address account, uint256 amount) public checkStart onlyRewardDistribution updateReward(account) { require(amount > 0, "POOL: Cannot withdraw 0"); super.withdrawAccount(account, amount); emit Withdrawn(account, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public checkStart updateReward(msg.sender) { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; rewardToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } modifier checkStart() { require(block.timestamp > startTime, "POOL: Not start"); _; } modifier checkOpen() { require( open && block.timestamp < startTime + DURATION, "POOL: Pool is closed" ); _; } modifier checkClose() { require(block.timestamp > startTime + DURATION, "POOL: Pool is opened"); _; } function getPeriodFinish() external view returns (uint256) { return periodFinish; } function isOpen() external view returns (bool) { return open; } function setOpen(bool _open) external onlyOwner { open = _open; emit SetOpen(_open); } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution checkOpen updateReward(address(0)) { if (block.timestamp > startTime) { if (block.timestamp >= periodFinish) { uint256 period = block .timestamp .sub(startTime) .div(DURATION) .add(1); periodFinish = startTime.add(period.mul(DURATION)); rewardRate = reward.div(periodFinish.sub(block.timestamp)); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(remaining); } lastUpdateTime = block.timestamp; } else { uint256 b = rewardToken.balanceOf(address(this)); rewardRate = reward.add(b).div(DURATION); periodFinish = startTime.add(DURATION); lastUpdateTime = startTime; } rewardToken.safeTransferFrom(msg.sender, address(this), reward); emit RewardAdded(reward); // avoid overflow to lock assets _checkRewardRate(); } function _checkRewardRate() internal view returns (uint256) { return DURATION.mul(rewardRate).mul(_gunit); } }
0x608060405234801561001057600080fd5b50600436106101ce5760003560e01c806378e9792511610104578063c8f33c91116100a2578063e9fad8ee11610071578063e9fad8ee14610679578063ebe2b12b14610683578063f2fde38b146106a1578063f7c618c1146106e5576101ce565b8063c8f33c9114610601578063cb17d14f1461061f578063cd3daf9d1461063d578063df136d651461065b576101ce565b80638b876347116100de5780638b8763471461050f5780638da5cb5b146105675780638f32d59b146105b1578063a694fc3a146105d3576101ce565b806378e97925146104b55780637b0a47ee146104d357806380faa57d146104f1576101ce565b80633d18b91211610171578063631f509e1161014b578063631f509e146103d55780636fdca5e01461042357806370a0823114610453578063715018a6146104ab576101ce565b80633d18b9121461035f57806347535d7b1461036957806351ed6a301461038b576101ce565b806318160ddd116101ad57806318160ddd146102c75780631be05289146102e55780632e1a7d4d146103035780633c6b16ab14610331576101ce565b80628cc262146101d35780630700037d1461022b5780630d68b76114610283575b600080fd5b610215600480360360208110156101e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072f565b6040518082815260200191505060405180910390f35b61026d6004803603602081101561024157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610816565b6040518082815260200191505060405180910390f35b6102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061082e565b005b6102cf6108ec565b6040518082815260200191505060405180910390f35b6102ed6108f6565b6040518082815260200191505060405180910390f35b61032f6004803603602081101561031957600080fd5b81019080803590602001909291905050506108fd565b005b61035d6004803603602081101561034757600080fd5b8101908080359060200190929190505050610b30565b005b61036761104d565b005b6103716112a5565b604051808215151515815260200191505060405180910390f35b6103936112bc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610421600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112e1565b005b6104516004803603602081101561043957600080fd5b810190808035151590602001909291905050506115be565b005b6104956004803603602081101561046957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611690565b6040518082815260200191505060405180910390f35b6104b36116d9565b005b6104bd611814565b6040518082815260200191505060405180910390f35b6104db61181c565b6040518082815260200191505060405180910390f35b6104f9611822565b6040518082815260200191505060405180910390f35b6105516004803603602081101561052557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611835565b6040518082815260200191505060405180910390f35b61056f61184d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105b9611877565b604051808215151515815260200191505060405180910390f35b6105ff600480360360208110156105e957600080fd5b81019080803590602001909291905050506118d6565b005b610609611b9a565b6040518082815260200191505060405180910390f35b610627611ba0565b6040518082815260200191505060405180910390f35b610645611baa565b6040518082815260200191505060405180910390f35b610663611c42565b6040518082815260200191505060405180910390f35b610681611c48565b005b61068b611c63565b6040518082815260200191505060405180910390f35b6106e3600480360360208110156106b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c69565b005b6106ed611cef565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600061080f600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610801670de0b6b3a76400006107f36107dc600b60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546107ce611baa565b611d1590919063ffffffff16565b6107e588611690565b611d5f90919063ffffffff16565b611de590919063ffffffff16565b611e2f90919063ffffffff16565b9050919050565b600c6020528060005260406000206000915090505481565b610836611877565b6108a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600154905090565b6212750081565b62127500636076f56001421161097b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f504f4f4c3a20506f6f6c206973206f70656e656400000000000000000000000081525060200191505060405180910390fd5b33610984611baa565b600981905550610992611822565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a5f576109d58161072f565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008211610ad5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f504f4f4c3a2043616e6e6f74207769746864726177203000000000000000000081525060200191505060405180910390fd5b610ade82611eb7565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b71611fb6565b73ffffffffffffffffffffffffffffffffffffffff1614610bdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b666021913960400191505060405180910390fd5b600a60009054906101000a900460ff168015610c01575062127500636076f5600142105b610c73576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f504f4f4c3a20506f6f6c20697320636c6f73656400000000000000000000000081525060200191505060405180910390fd5b6000610c7d611baa565b600981905550610c8b611822565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610d5857610cce8161072f565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b636076f560421115610e81576006544210610e15576000610dae6001610da062127500610d92636076f56042611d1590919063ffffffff16565b611de590919063ffffffff16565b611e2f90919063ffffffff16565b9050610ddc610dc96212750083611d5f90919063ffffffff16565b636076f560611e2f90919063ffffffff16565b600681905550610e09610dfa42600654611d1590919063ffffffff16565b84611de590919063ffffffff16565b60078190555050610e75565b6000610e2c42600654611d1590919063ffffffff16565b90506000610e4560075483611d5f90919063ffffffff16565b9050610e6c82610e5e8387611e2f90919063ffffffff16565b611de590919063ffffffff16565b60078190555050505b42600881905550610fba565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610f2257600080fd5b505afa158015610f36573d6000803e3d6000fd5b505050506040513d6020811015610f4c57600080fd5b81019080805190602001909291905050509050610f8762127500610f798386611e2f90919063ffffffff16565b611de590919063ffffffff16565b600781905550610fa762127500636076f560611e2f90919063ffffffff16565b600681905550636076f560600881905550505b611009333084600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611fbe909392919063ffffffff16565b7fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a16110486120c4565b505050565b636076f56042116110c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f504f4f4c3a204e6f74207374617274000000000000000000000000000000000081525060200191505060405180910390fd5b336110cf611baa565b6009819055506110dd611822565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146111aa576111208161072f565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60006111b53361072f565b905060008111156112a1576000600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112523382600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120fd9092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b5050565b6000600a60009054906101000a900460ff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b636076f560421161135a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f504f4f4c3a204e6f74207374617274000000000000000000000000000000000081525060200191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661139b611fb6565b73ffffffffffffffffffffffffffffffffffffffff1614611407576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b666021913960400191505060405180910390fd5b81611410611baa565b60098190555061141e611822565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146114eb576114618161072f565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008211611561576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f504f4f4c3a2043616e6e6f74207769746864726177203000000000000000000081525060200191505060405180910390fd5b61156b83836121ce565b8273ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a2505050565b6115c6611877565b611638576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a60006101000a81548160ff0219169083151502179055507f294847065aeb5e8e788661acfc7dbcb26c7f0454406268fce96109d7136928af81604051808215151515815260200191505060405180910390a150565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6116e1611877565b611753576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b636076f56081565b60075481565b6000611830426006546122ce565b905090565b600b6020528060005260406000206000915090505481565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166118ba611fb6565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b600a60009054906101000a900460ff1680156118fa575062127500636076f5600142105b61196c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f504f4f4c3a20506f6f6c20697320636c6f73656400000000000000000000000081525060200191505060405180910390fd5b636076f56042116119e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f504f4f4c3a204e6f74207374617274000000000000000000000000000000000081525060200191505060405180910390fd5b336119ee611baa565b6009819055506119fc611822565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611ac957611a3f8161072f565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600954600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008211611b3f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f504f4f4c3a2043616e6e6f74207374616b65203000000000000000000000000081525060200191505060405180910390fd5b611b48826122e7565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d836040518082815260200191505060405180910390a25050565b60085481565b6000600654905090565b600080611bb56108ec565b1415611bc5576009549050611c3f565b611c3c611c2b611bd36108ec565b611c1d670de0b6b3a7640000611c0f600754611c01600854611bf3611822565b611d1590919063ffffffff16565b611d5f90919063ffffffff16565b611d5f90919063ffffffff16565b611de590919063ffffffff16565b600954611e2f90919063ffffffff16565b90505b90565b60095481565b611c59611c5433611690565b6108fd565b611c6161104d565b565b60065481565b611c71611877565b611ce3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611cec816125bc565b50565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611d5783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612702565b905092915050565b600080831415611d725760009050611ddf565b6000828402905082848281611d8357fe5b0414611dda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b456021913960400191505060405180910390fd5b809150505b92915050565b6000611e2783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506127c2565b905092915050565b600080828401905083811015611ead576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b611ecc81600154611d1590919063ffffffff16565b600181905550611f2481600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d1590919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fb333826000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120fd9092919063ffffffff16565b50565b600033905090565b6120be848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612888565b50505050565b60006120f8670de0b6b3a76400006120ea60075462127500611d5f90919063ffffffff16565b611d5f90919063ffffffff16565b905090565b6121c9838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612888565b505050565b6121e381600154611d1590919063ffffffff16565b60018190555061223b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d1590919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122ca82826000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120fd9092919063ffffffff16565b5050565b60008183106122dd57816122df565b825b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561238757600080fd5b505afa15801561239b573d6000803e3d6000fd5b505050506040513d60208110156123b157600080fd5b810190808051906020019092919050505090506124123330846000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611fbe909392919063ffffffff16565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156124b257600080fd5b505afa1580156124c6573d6000803e3d6000fd5b505050506040513d60208110156124dc57600080fd5b8101908080519060200190929190505050905060006125048383611d1590919063ffffffff16565b905061251b81600154611e2f90919063ffffffff16565b60018190555061257381600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e2f90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612642576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612b1f6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008383111582906127af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612774578082015181840152602081019050612759565b50505050905090810190601f1680156127a15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808311829061286e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612833578082015181840152602081019050612818565b50505050905090810190601f1680156128605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161287a57fe5b049050809150509392505050565b6128a78273ffffffffffffffffffffffffffffffffffffffff16612ad3565b612919576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106129685780518252602082019150602081019050602083039250612945565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146129ca576040519150601f19603f3d011682016040523d82523d6000602084013e6129cf565b606091505b509150915081612a47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115612acd57808060200190516020811015612a6657600080fd5b8101908080519060200190929190505050612acc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612b87602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b8214158015612b155750808214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820bf63a1c38642538749270413fc2327f66043a49f2d3e6d7062e14a3d2e43973464736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"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': '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, 2581, 2050, 22203, 2497, 2692, 15878, 10354, 2581, 2475, 2094, 2692, 2278, 2692, 2683, 9468, 20958, 2629, 2278, 25746, 2475, 2546, 17788, 2575, 2094, 12740, 16576, 2629, 3676, 2497, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 8785, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2385, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3115, 8785, 16548, 4394, 1999, 1996, 5024, 3012, 2653, 1012, 1008, 1013, 3075, 8785, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 2922, 1997, 2048, 3616, 1012, 1008, 1013, 3853, 4098, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2709, 1037, 1028, 1027, 1038, 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,955
0x97a527283C6C6E6b9D82fdC720496B8873EC86a0
// SPDX-License-Identifier: GPL-3.0-or-later // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) /** * @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; } } pragma solidity ^0.6.12; contract WSGov { /// @dev EIP-20 token name for this token string public constant name = "WhiteSwap"; /// @dev EIP-20 token symbol for this token string public constant symbol = "WSE"; /// @dev EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @dev Total number of tokens in circulation uint public totalSupply = 1_000_000_000e18; // 1 billion WSG /// @dev Address which may mint new tokens address public minter; /// @dev The timestamp after which minting may occur uint public mintingAllowedAfter; /// @dev Minimum time between mints uint32 public constant minimumTimeBetweenMints = 1 days * 365; /// @dev Cap on the percentage of totalSupply that can be minted at each mint uint8 public constant mintCap = 2; /// @dev Allowance amounts on behalf of others mapping (address => mapping (address => uint96)) internal allowances; /// @dev Official record of token balances for each account mapping (address => uint96) internal balances; /// @dev A record of each accounts delegate mapping (address => address) public delegates; /// @dev A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @dev A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @dev The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @dev The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @dev 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)"); /// @dev The EIP-712 typehash for the permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /// @dev A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @dev An event thats emitted when the minter address is changed event MinterChanged(address minter, address newMinter); /// @dev An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @dev An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @dev The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @dev The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @dev Construct a new WSG token * @param account The initial account to grant all the tokens */ constructor(address account, address minter_, uint mintingAllowedAfter_) public { require(mintingAllowedAfter_ >= block.timestamp, "WSG::constructor: minting can only begin after deployment"); balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); minter = minter_; emit MinterChanged(address(0), minter); mintingAllowedAfter = mintingAllowedAfter_; } /** * @dev Change the minter address * @param minter_ The address of the new minter */ function setMinter(address minter_) external { require(msg.sender == minter, "WSG::setMinter: only the minter can change the minter address"); emit MinterChanged(minter, minter_); minter = minter_; } /** * @dev Mint new tokens * @param dst The address of the destination account * @param rawAmount The number of tokens to be minted */ function mint(address dst, uint rawAmount) external { require(msg.sender == minter, "WSG::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "WSG::mint: minting not allowed yet"); require(dst != address(0), "WSG::mint: cannot transfer to the zero address"); // record the mint mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); // mint the amount uint96 amount = safe96(rawAmount, "WSG::mint: amount exceeds 96 bits"); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "WSG::mint: exceeded mint cap"); totalSupply = safe96(SafeMath.add(totalSupply, amount), "WSG::mint: totalSupply exceeds 96 bits"); // transfer the amount to the recipient balances[dst] = add96(balances[dst], amount, "WSG::mint: transfer amount overflows"); emit Transfer(address(0), dst, amount); // move delegates _moveDelegates(address(0), delegates[dst], amount); } /** * @dev Get the number of tokens `spender` is approved to spend on behalf of `account` * @param account The address of the account holding the funds * @param spender The address of the account spending the funds * @return The number of tokens approved */ function allowance(address account, address spender) external view returns (uint) { return allowances[account][spender]; } /** * @dev Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "WSG::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @dev Triggers an approval from owner to spends * @param owner The address to approve from * @param spender The address to be approved * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @param deadline 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 permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "WSG::permit: amount exceeds 96 bits"); } bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, rawAmount, nonces[owner]++, deadline)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "WSG::permit: invalid signature"); require(signatory == owner, "WSG::permit: unauthorized"); require(now <= deadline, "WSG::permit: signature expired"); allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Get the number of tokens held by the `account` * @param account The address of the account to get the balance of * @return The number of tokens held */ function balanceOf(address account) external view returns (uint) { return balances[account]; } /** * @dev Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, "WSG::transfer: amount exceeds 96 bits"); _transferTokens(msg.sender, dst, amount); return true; } /** * @dev Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint rawAmount) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "WSG::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != uint96(-1)) { uint96 newAllowance = sub96(spenderAllowance, amount, "WSG::transferFrom: transfer amount exceeds spender allowance"); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } /** * @dev Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { return _delegate(msg.sender, delegatee); } /** * @dev 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) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "WSG::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "WSG::delegateBySig: invalid nonce"); require(now <= expiry, "WSG::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @dev Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @dev 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) public view returns (uint96) { require(blockNumber < block.number, "WSG::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = balances[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _transferTokens(address src, address dst, uint96 amount) internal { require(src != address(0), "WSG::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "WSG::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "WSG::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "WSG::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); _moveDelegates(delegates[src], delegates[dst], amount); } function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "WSG::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "WSG::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "WSG::_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 safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
0x608060405234801561001057600080fd5b50600436106101b95760003560e01c80636fcfff45116100f9578063b4b5ea5711610097578063dd62ed3e11610071578063dd62ed3e1461062f578063e7a324dc1461066a578063f1127ed814610672578063fca3b5aa146106de576101b9565b8063b4b5ea571461054a578063c3cda5201461057d578063d505accf146105d1576101b9565b8063782d6fe1116100d3578063782d6fe11461047c5780637ecebe00146104d657806395d89b4114610509578063a9059cbb14610511576101b9565b80636fcfff451461040e57806370a082311461044157806376c71ca114610474576101b9565b806330adf81f1161016657806340c10f191161014057806340c10f191461034c578063587cde1e146103875780635c11d62f146103ba5780635c19a95c146103db576101b9565b806330adf81f1461031e57806330b36cef14610326578063313ce5671461032e576101b9565b806318160ddd1161019757806318160ddd146102b957806320606b70146102d357806323b872dd146102db576101b9565b806306fdde03146101be578063075461721461023b578063095ea7b31461026c575b600080fd5b6101c6610711565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102005781810151838201526020016101e8565b50505050905090810190601f16801561022d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024361074a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102a56004803603604081101561028257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610766565b604080519115158252519081900360200190f35b6102c161088a565b60408051918252519081900360200190f35b6102c1610890565b6102a5600480360360608110156102f157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356108b4565b6102c1610a54565b6102c1610a78565b610336610a7e565b6040805160ff9092168252519081900360200190f35b6103856004803603604081101561036257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610a83565b005b6102436004803603602081101561039d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610df5565b6103c2610e1d565b6040805163ffffffff9092168252519081900360200190f35b610385600480360360208110156103f157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e25565b6103c26004803603602081101561042457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e32565b6102c16004803603602081101561045757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610e4a565b610336610e80565b6104b56004803603604081101561049257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610e85565b604080516bffffffffffffffffffffffff9092168252519081900360200190f35b6102c1600480360360208110156104ec57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611186565b6101c6611198565b6102a56004803603604081101561052757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356111d1565b6104b56004803603602081101561056057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661120d565b610385600480360360c081101561059357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060208101359060408101359060ff6060820135169060808101359060a001356112bc565b610385600480360360e08110156105e757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611642565b6102c16004803603604081101561064557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611bbd565b6102c1611c03565b6106b16004803603604081101561068857600080fd5b50803573ffffffffffffffffffffffffffffffffffffffff16906020013563ffffffff16611c27565b6040805163ffffffff90931683526bffffffffffffffffffffffff90911660208301528051918290030190f35b610385600480360360208110156106f457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611c62565b6040518060400160405280600981526020017f576869746553776170000000000000000000000000000000000000000000000081525081565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8314156107b857507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6107dd565b6107da83604051806060016040528060248152602001612a7460249139611d6e565b90505b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168085529083529281902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff8716908117909155815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a360019150505b92915050565b60005481565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602090815260408083203380855290835281842054825160608101909352602480845291936bffffffffffffffffffffffff90911692859261091e9288929190612a7490830139611d6e565b90508673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561096a57506bffffffffffffffffffffffff82811614155b15610a3c57600061099483836040518060600160405280603c8152602001612a98603c9139611e2b565b73ffffffffffffffffffffffffffffffffffffffff8981166000818152600360209081526040808320948a168084529482529182902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff871690811790915582519081529151949550929391927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92592918290030190a3505b610a47878783611ebc565b5060019695505050505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60025481565b601281565b60015473ffffffffffffffffffffffffffffffffffffffff163314610af3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612c056023913960400191505060405180910390fd5b600254421015610b4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612d396022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610bba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180612ba8602e913960400191505060405180910390fd5b610bc8426301e1338061215d565b6002819055506000610bf282604051806060016040528060218152602001612cce60219139611d6e565b9050610c0e610c07600054600260ff166121d1565b6064612244565b816bffffffffffffffffffffffff161115610c8a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5753473a3a6d696e743a206578636565646564206d696e742063617000000000604482015290519081900360640190fd5b610cc5610ca7600054836bffffffffffffffffffffffff1661215d565b6040518060600160405280602681526020016129ec60269139611d6e565b6bffffffffffffffffffffffff908116600090815573ffffffffffffffffffffffffffffffffffffffff8516815260046020908152604091829020548251606081019093526024808452610d299491909116928592909190612caa90830139612286565b73ffffffffffffffffffffffffffffffffffffffff8416600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff9687161790558051948616855251929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a373ffffffffffffffffffffffffffffffffffffffff808416600090815260056020526040812054610df092168361230f565b505050565b60056020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6301e1338081565b610e2f3382612556565b50565b60076020526000908152604090205463ffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff166000908152600460205260409020546bffffffffffffffffffffffff1690565b600281565b6000438210610edf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612b616026913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526007602052604090205463ffffffff1680610f1a576000915050610884565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260066020908152604080832063ffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860181168552925290912054168310610ff25773ffffffffffffffffffffffffffffffffffffffff841660009081526006602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9490940163ffffffff168352929052205464010000000090046bffffffffffffffffffffffff169050610884565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260066020908152604080832083805290915290205463ffffffff1683101561103a576000915050610884565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82015b8163ffffffff168163ffffffff16111561112e57600282820363ffffffff1604810361108a612976565b5073ffffffffffffffffffffffffffffffffffffffff8716600090815260066020908152604080832063ffffffff8581168552908352928190208151808301909252549283168082526401000000009093046bffffffffffffffffffffffff169181019190915290871415611109576020015194506108849350505050565b805163ffffffff1687111561112057819350611127565b6001820392505b5050611060565b5073ffffffffffffffffffffffffffffffffffffffff8516600090815260066020908152604080832063ffffffff909416835292905220546bffffffffffffffffffffffff6401000000009091041691505092915050565b60086020526000908152604090205481565b6040518060400160405280600381526020017f575345000000000000000000000000000000000000000000000000000000000081525081565b6000806111f683604051806060016040528060258152602001612cef60259139611d6e565b9050611203338583611ebc565b5060019392505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604081205463ffffffff16806112455760006112b5565b73ffffffffffffffffffffffffffffffffffffffff831660009081526006602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff850163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b9392505050565b60408051808201909152600981527f576869746553776170000000000000000000000000000000000000000000000060209091015260007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8667f61703dc3790c56209e077e2cef46210302a1533403439bfe37f3f85237f86a1b61133d61260a565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c084015273ffffffffffffffffffffffffffffffffffffffff8b1660e084015261010083018a90526101208084018a905282518085039091018152610140840183528051908501207f19010000000000000000000000000000000000000000000000000000000000006101608501526101628401829052610182808501829052835180860390910181526101a285018085528151918701919091206000918290526101c2860180865281905260ff8b166101e287015261020286018a905261022286018990529351929650909492939092600192610242808401937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08301929081900390910190855afa1580156114b6573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661154d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612a4f6025913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020526040902080546001810190915589146115d2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b076021913960400191505060405180910390fd5b8742111561162b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612d146025913960400191505060405180910390fd5b611635818b612556565b505050505b505050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86141561169357507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6116b8565b6116b58660405180606001604052806023815260200161298e60239139611d6e565b90505b60408051808201909152600981527f576869746553776170000000000000000000000000000000000000000000000060209091015260007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8667f61703dc3790c56209e077e2cef46210302a1533403439bfe37f3f85237f86a1b61173961260a565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a08301825280519084012073ffffffffffffffffffffffffffffffffffffffff8d8116600081815260088752848120805460018082019092557f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960c089015260e0880193909352928f1661010087015261012086018e90526101408601919091526101608086018d905284518087039091018152610180860185528051908701207f19010000000000000000000000000000000000000000000000000000000000006101a08701526101a286018490526101c2808701829052855180880390910181526101e2870180875281519189019190912090839052610202870180875281905260ff8d1661022288015261024287018c905261026287018b905294519397509593949093919261028280830193927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08301929081900390910190855afa1580156118db573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661198857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f5753473a3a7065726d69743a20696e76616c6964207369676e61747572650000604482015290519081900360640190fd5b8b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611a2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5753473a3a7065726d69743a20756e617574686f72697a656400000000000000604482015290519081900360640190fd5b88421115611a9157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f5753473a3a7065726d69743a207369676e617475726520657870697265640000604482015290519081900360640190fd5b84600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508a73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258760405180826bffffffffffffffffffffffff16815260200191505060405180910390a3505050505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526003602090815260408083209390941682529190915220546bffffffffffffffffffffffff1690565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b600660209081526000928352604080842090915290825290205463ffffffff81169064010000000090046bffffffffffffffffffffffff1682565b60015473ffffffffffffffffffffffffffffffffffffffff163314611cd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180612a12603d913960400191505060405180910390fd5b6001546040805173ffffffffffffffffffffffffffffffffffffffff9283168152918316602083015280517f3b0007eb941cf645526cbb3a4fdaecda9d28ce4843167d9263b536a1f1edc0f69281900390910190a1600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000816c010000000000000000000000008410611e23576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611de8578181015183820152602001611dd0565b50505050905090810190601f168015611e155780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509192915050565b6000836bffffffffffffffffffffffff16836bffffffffffffffffffffffff1611158290611eb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315611de8578181015183820152602001611dd0565b505050900390565b73ffffffffffffffffffffffffffffffffffffffff8316611f28576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b8152602001806129b1603b913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216611f94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526039815260200180612b286039913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260046020908152604091829020548251606081019093526035808452611ff1936bffffffffffffffffffffffff9092169285929190612c2890830139611e2b565b73ffffffffffffffffffffffffffffffffffffffff848116600090815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff96871617905592861682529082902054825160608101909352602f8084526120839491909116928592909190612bd690830139612286565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526004602090815260409182902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff9687161790558151948616855290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a373ffffffffffffffffffffffffffffffffffffffff808416600090815260056020526040808220548584168352912054610df09291821691168361230f565b6000828201838110156112b557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826121e057506000610884565b828202828482816121ed57fe5b04146112b5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b876021913960400191505060405180910390fd5b60006112b583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061260e565b6000838301826bffffffffffffffffffffffff8087169083161015612306576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315611de8578181015183820152602001611dd0565b50949350505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561235957506000816bffffffffffffffffffffffff16115b15610df05773ffffffffffffffffffffffffffffffffffffffff83161561245c5773ffffffffffffffffffffffffffffffffffffffff831660009081526007602052604081205463ffffffff1690816123b3576000612423565b73ffffffffffffffffffffffffffffffffffffffff851660009081526006602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b9050600061244a8285604051806060016040528060278152602001612c5d60279139611e2b565b90506124588684848461268d565b5050505b73ffffffffffffffffffffffffffffffffffffffff821615610df05773ffffffffffffffffffffffffffffffffffffffff821660009081526007602052604081205463ffffffff1690816124b1576000612521565b73ffffffffffffffffffffffffffffffffffffffff841660009081526006602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b905060006125488285604051806060016040528060268152602001612c8460269139612286565b905061163a8584848461268d565b73ffffffffffffffffffffffffffffffffffffffff808316600081815260056020818152604080842080546004845282862054949093528787167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117909155905191909516946bffffffffffffffffffffffff9092169391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461260482848361230f565b50505050565b4690565b60008183612677576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315611de8578181015183820152602001611dd0565b50600083858161268357fe5b0495945050505050565b60006126b143604051806060016040528060338152602001612ad460339139612906565b905060008463ffffffff16118015612725575073ffffffffffffffffffffffffffffffffffffffff8516600090815260066020908152604080832063ffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8901811685529252909120548282169116145b156127c45773ffffffffffffffffffffffffffffffffffffffff851660009081526006602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff880163ffffffff168452909152902080547fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff166401000000006bffffffffffffffffffffffff8516021790556128a0565b60408051808201825263ffffffff80841682526bffffffffffffffffffffffff808616602080850191825273ffffffffffffffffffffffffffffffffffffffff8b166000818152600683528781208c871682528352878120965187549451909516640100000000027fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff9587167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000958616179590951694909417909555938252600790935292909220805460018801909316929091169190911790555b604080516bffffffffffffffffffffffff808616825284166020820152815173ffffffffffffffffffffffffffffffffffffffff8816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b6000816401000000008410611e23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315611de8578181015183820152602001611dd0565b60408051808201909152600080825260208201529056fe5753473a3a7065726d69743a20616d6f756e74206578636565647320393620626974735753473a3a5f7472616e73666572546f6b656e733a2063616e6e6f74207472616e736665722066726f6d20746865207a65726f20616464726573735753473a3a6d696e743a20746f74616c537570706c79206578636565647320393620626974735753473a3a7365744d696e7465723a206f6e6c7920746865206d696e7465722063616e206368616e676520746865206d696e74657220616464726573735753473a3a64656c656761746542795369673a20696e76616c6964207369676e61747572655753473a3a617070726f76653a20616d6f756e74206578636565647320393620626974735753473a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e63655753473a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206578636565647320333220626974735753473a3a64656c656761746542795369673a20696e76616c6964206e6f6e63655753473a3a5f7472616e73666572546f6b656e733a2063616e6e6f74207472616e7366657220746f20746865207a65726f20616464726573735753473a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775753473a3a6d696e743a2063616e6e6f74207472616e7366657220746f20746865207a65726f20616464726573735753473a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f77735753473a3a6d696e743a206f6e6c7920746865206d696e7465722063616e206d696e745753473a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e63655753473a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f77735753473a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77735753473a3a6d696e743a207472616e7366657220616d6f756e74206f766572666c6f77735753473a3a6d696e743a20616d6f756e74206578636565647320393620626974735753473a3a7472616e736665723a20616d6f756e74206578636565647320393620626974735753473a3a64656c656761746542795369673a207369676e617475726520657870697265645753473a3a6d696e743a206d696e74696e67206e6f7420616c6c6f77656420796574a2646970667358221220b3dd7024e65b7151bac9e9e8b5b74238ab80725494824aa56ce1d259197aef9364736f6c634300060c0033
{"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, 2581, 2050, 25746, 2581, 22407, 2509, 2278, 2575, 2278, 2575, 2063, 2575, 2497, 2683, 2094, 2620, 2475, 2546, 16409, 2581, 11387, 26224, 2575, 2497, 2620, 2620, 2581, 2509, 8586, 20842, 2050, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 1037, 3075, 2005, 4488, 2058, 12314, 1011, 3647, 8785, 1010, 14571, 1997, 4830, 9397, 6979, 2497, 1006, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 4830, 9397, 6979, 2497, 1013, 16233, 1011, 8785, 1007, 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, 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,956
0x97a578ed93c72421b63307874bd2e1c6398f1baf
pragma solidity ^0.4.20; contract owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { // 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); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function totalSupply() public view returns (uint256) { return totalSupply; } function balanceOf(address _who) public view returns (uint256) { return balanceOf[_who]; } /** * 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` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } } /******************************************/ /* Basic E-commerce Chain */ /******************************************/ contract BECToken is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen // LOCK COINS uint start = 1532964203; //address peAccount = 0xf28a2a16546110138F255cc3c2D76460B8517297; address fundAccount = 0xa61FDFb4b147Eb2b02790B779E6DfBe308394C98; //address bizAccount = 0xaeF0f5D901cb6b8FEF95C019612C80f040F76b24; address teamAccount = 0xF9367C4bE8e47f46827AdB2cFEBFd6b265C3C3B0; //address partnerAccount = 0x40fbcb153caC1299BDe8f880FE668e0DC07b1Fea; uint256 amount = _value; address sender = _from; uint256 balance = balanceOf[_from]; if (fundAccount == sender) { if (now < start + 365 * 1 days) { require((balance - amount) >= totalSupply * 3/20 * 3/4); } else if (now < start + (2*365+1) * 1 days){ require((balance - amount) >= totalSupply * 3/20 * 2/4); } else if (now < start + (3*365+1) * 1 days){ require((balance - amount) >= totalSupply * 3/20 * 1/4); } else { require((balance - amount) >= 0); } } else if (teamAccount == sender) { if (now < start + 365 * 1 days) { require((balance - amount) >= totalSupply/10 * 3/4); } else if (now < start + (2*365+1) * 1 days){ require((balance - amount) >= totalSupply/10 * 2/4); } else if (now < start + (3*365+1) * 1 days){ require((balance - amount) >= totalSupply/10 * 1/4); } else { require((balance - amount) >= 0); } } balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = this; require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
0x6080604052600436106101275763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305fefda7811461012c57806306fdde0314610149578063095ea7b3146101d357806318160ddd1461020b57806323b872dd14610232578063313ce5671461025c57806342966c68146102875780634b7503341461029f57806370a08231146102b457806379c65068146102d557806379cc6790146102f95780638620410b1461031d5780638da5cb5b1461033257806395d89b4114610363578063a6f2ae3a14610378578063a9059cbb14610380578063b414d4b6146103a4578063cae9ca51146103c5578063dd62ed3e1461042e578063e4849b3214610455578063e724529c1461046d578063f2fde38b14610493575b600080fd5b34801561013857600080fd5b506101476004356024356104b4565b005b34801561015557600080fd5b5061015e6104d6565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610198578181015183820152602001610180565b50505050905090810190601f1680156101c55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101df57600080fd5b506101f7600160a060020a0360043516602435610563565b604080519115158252519081900360200190f35b34801561021757600080fd5b506102206105c9565b60408051918252519081900360200190f35b34801561023e57600080fd5b506101f7600160a060020a03600435811690602435166044356105cf565b34801561026857600080fd5b5061027161063e565b6040805160ff9092168252519081900360200190f35b34801561029357600080fd5b506101f7600435610647565b3480156102ab57600080fd5b506102206106bf565b3480156102c057600080fd5b50610220600160a060020a03600435166106c5565b3480156102e157600080fd5b50610147600160a060020a03600435166024356106e0565b34801561030557600080fd5b506101f7600160a060020a0360043516602435610796565b34801561032957600080fd5b50610220610867565b34801561033e57600080fd5b5061034761086d565b60408051600160a060020a039092168252519081900360200190f35b34801561036f57600080fd5b5061015e61087c565b6101476108d4565b34801561038c57600080fd5b506101f7600160a060020a03600435166024356108f4565b3480156103b057600080fd5b506101f7600160a060020a036004351661090a565b3480156103d157600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101f7948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061091f9650505050505050565b34801561043a57600080fd5b50610220600160a060020a0360043581169060243516610a38565b34801561046157600080fd5b50610147600435610a55565b34801561047957600080fd5b50610147600160a060020a03600435166024351515610aa9565b34801561049f57600080fd5b50610147600160a060020a0360043516610b24565b600054600160a060020a031633146104cb57600080fd5b600791909155600855565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561055b5780601f106105305761010080835404028352916020019161055b565b820191906000526020600020905b81548152906001019060200180831161053e57829003601f168201915b505050505081565b336000818152600660209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60045490565b600160a060020a03831660009081526006602090815260408083203384529091528120548211156105ff57600080fd5b600160a060020a0384166000908152600660209081526040808320338452909152902080548390039055610634848484610b6a565b5060019392505050565b60035460ff1681565b3360009081526005602052604081205482111561066357600080fd5b3360008181526005602090815260409182902080548690039055600480548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a2506001919050565b60075481565b600160a060020a031660009081526005602052604090205490565b600054600160a060020a031633146106f757600080fd5b600160a060020a03821660009081526005602090815260408083208054850190556004805485019055805184815290513093927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928290030190a3604080518281529051600160a060020a0384169130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600160a060020a0382166000908152600560205260408120548211156107bb57600080fd5b600160a060020a03831660009081526006602090815260408083203384529091529020548211156107eb57600080fd5b600160a060020a0383166000818152600560209081526040808320805487900390556006825280832033845282529182902080548690039055600480548690039055815185815291517fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59281900390910190a250600192915050565b60085481565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561055b5780601f106105305761010080835404028352916020019161055b565b6000600854348115156108e357fe5b0490506108f1303383610b6a565b50565b6000610901338484610b6a565b50600192915050565b60096020526000908152604090205460ff1681565b60008361092c8185610563565b15610a30576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018790523060448401819052608060648501908152875160848601528751600160a060020a03871695638f4ffcb195948b94938b939192909160a490910190602085019080838360005b838110156109c45781810151838201526020016109ac565b50505050905090810190601f1680156109f15780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610a1357600080fd5b505af1158015610a27573d6000803e3d6000fd5b50505050600191505b509392505050565b600660209081526000928352604080842090915290825290205481565b6007543090820281311015610a6957600080fd5b610a74333084610b6a565b6007546040513391840280156108fc02916000818181858888f19350505050158015610aa4573d6000803e3d6000fd5b505050565b600054600160a060020a03163314610ac057600080fd5b600160a060020a038216600081815260096020908152604091829020805460ff191685151590811790915582519384529083015280517f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a59281900390910190a15050565b600054600160a060020a03163314610b3b57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008080808080600160a060020a0388161515610b8657600080fd5b600160a060020a038916600090815260056020526040902054871115610bab57600080fd5b600160a060020a0388166000908152600560205260409020548781011015610bd257600080fd5b600160a060020a03891660009081526009602052604090205460ff1615610bf857600080fd5b600160a060020a03881660009081526009602052604090205460ff1615610c1e57600080fd5b50505050600160a060020a038516600081815260056020526040902054635b5f2d6b935073a61fdfb4b147eb2b02790b779e6dfbe308394c98925073f9367c4be8e47f46827adb2cfebfd6b265c3c3b09185918891851415610d0357856301e1338001421015610caa57600480546014600391820204025b048382031015610ca557600080fd5b610cfe565b856303c3b88001421015610ccf576004805460149060030204600202811515610c9657fe5b856305a4ec0001421015610cee57600480546014600390910204610c96565b60008382031015610cfe57600080fd5b610d8f565b81600160a060020a031684600160a060020a03161415610d8f57856301e1338001421015610d465760048054600a90046003025b048382031015610cfe57600080fd5b856303c3b88001421015610d645760048054600a9004600202610d37565b856305a4ec0001421015610d7f5760048054600a9004610d37565b60008382031015610d8f57600080fd5b600160a060020a03808a16600081815260056020908152604080832080548d90039055938c168083529184902080548c01905583518b8152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050505050505050505600a165627a7a72305820ca7d5764e460d32fd027050b8bc2e8405143a127febfda1648dd3d1921d090ac0029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 28311, 2620, 2098, 2683, 2509, 2278, 2581, 18827, 17465, 2497, 2575, 22394, 2692, 2581, 2620, 2581, 2549, 2497, 2094, 2475, 2063, 2487, 2278, 2575, 23499, 2620, 2546, 2487, 3676, 2546, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2322, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 9570, 2953, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 16913, 18095, 2069, 12384, 2121, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 3853, 4651, 12384, 2545, 5605, 1006, 4769, 2047, 12384, 2121, 1007, 2069, 12384, 2121, 2270, 1063, 3954, 1027, 2047, 12384, 2121, 1025, 1065, 1065, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 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,957
0x97a64e9e7a2d4a2c3e810c41d8842d673d32537e
pragma solidity ^0.4.21; /* * Abstract Token Smart Contract. Copyright © 2017 by ABDK Consulting. * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com> */ /** * ERC-20 standard token interface, as defined * <a href="http://github.com/ethereum/EIPs/issues/20">here</a>. */ contract Token { /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply () public constant returns (uint256 supply); /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf (address _owner) public constant returns (uint256 balance); /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer (address _to, uint256 _value) public returns (bool success); /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom (address _from, address _to, uint256 _value) public returns (bool success); /** * Allow given spender to transfer given number of tokens from message sender. * * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success); /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance (address _owner, address _spender) constant public returns (uint256 remaining); /** * Logged when tokens were transferred from one owner to another. * * @param _from address of the owner, tokens were transferred from * @param _to address of the owner, tokens were transferred to * @param _value number of tokens transferred */ event Transfer (address indexed _from, address indexed _to, uint256 _value); /** * Logged when owner approved his tokens to be transferred by some spender. * * @param _owner owner who approved his tokens to be transferred * @param _spender spender who were allowed to transfer the tokens belonging * to the owner * @param _value number of tokens belonging to the owner, approved to be * transferred by the spender */ event Approval ( address indexed _owner, address indexed _spender, uint256 _value); } /* * Safe Math Smart Contract. Copyright © 2016–2017 by ABDK Consulting. * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com> */ /** * Provides methods to safely add, subtract and multiply uint256 numbers. */ contract SafeMath { uint256 constant private MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Add two uint256 values, throw in case of overflow. * * @param x first value to add * @param y second value to add * @return x + y */ function safeAdd (uint256 x, uint256 y) pure internal returns (uint256 z) { assert (x <= MAX_UINT256 - y); return x + y; } /** * Subtract one uint256 value from another, throw in case of underflow. * * @param x value to subtract from * @param y value to subtract * @return x - y */ function safeSub (uint256 x, uint256 y) pure internal returns (uint256 z) { assert (x >= y); return x - y; } /** * Multiply two uint256 values, throw in case of overflow. * * @param x first value to multiply * @param y second value to multiply * @return x * y */ function safeMul (uint256 x, uint256 y) pure internal returns (uint256 z) { if (y == 0) return 0; // Prevent division by zero at the next line assert (x <= MAX_UINT256 / y); return x * y; } } /** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */ contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ function AbstractToken () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf (address _owner) public constant returns (uint256 balance) { return accounts [_owner]; } /** * Get number of tokens currently belonging to given owner and available for transfer. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function transferrableBalanceOf (address _owner) public constant returns (uint256 balance) { if (holds[_owner] > accounts[_owner]) { return 0; } else { return safeSub(accounts[_owner], holds[_owner]); } } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer (address _to, uint256 _value) public returns (bool success) { require (transferrableBalanceOf(msg.sender) >= _value); if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); if (!hasAccount[_to]) { hasAccount[_to] = true; accountList.push(_to); } accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom (address _from, address _to, uint256 _value) public returns (bool success) { require (allowances [_from][msg.sender] >= _value); require (transferrableBalanceOf(_from) >= _value); allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); if (_value > 0 && _from != _to) { accounts [_from] = safeSub (accounts [_from], _value); if (!hasAccount[_to]) { hasAccount[_to] = true; accountList.push(_to); } accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance (address _owner, address _spender) public constant returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from address of token holders to a boolean to indicate if they have * already been added to the system. */ mapping (address => bool) internal hasAccount; /** * List of available accounts. */ address [] internal accountList; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; /** * Mapping from addresses of token holds which cannot be spent until released. */ mapping (address => uint256) internal holds; } /** * Ponder token smart contract. */ contract PonderAirdropToken is AbstractToken { /** * Address of the owner of this smart contract. */ mapping (address => bool) private owners; /** * Address of the account which holds the supply */ address private supplyOwner; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new Ponder token smart contract, with given number of tokens issued * and given to msg.sender, and make msg.sender the owner of this smart * contract. */ function PonderAirdropToken () public { supplyOwner = msg.sender; owners[supplyOwner] = true; accounts [supplyOwner] = totalSupply(); hasAccount [supplyOwner] = true; accountList.push(supplyOwner); } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply () public constant returns (uint256 supply) { return 480000000 * (uint256(10) ** decimals()); } /** * Get name of this token. * * @return name of this token */ function name () public pure returns (string result) { return "Ponder Airdrop Token"; } /** * Get symbol of this token. * * @return symbol of this token */ function symbol () public pure returns (string result) { return "PONA"; } /** * Get number of decimals for this token. * * @return number of decimals for this token */ function decimals () public pure returns (uint8 result) { return 18; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer (address _to, uint256 _value) public returns (bool success) { if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom (address _from, address _to, uint256 _value) public returns (bool success) { if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, this method * receives assumed current allowance value as an argument. If actual * allowance differs from an assumed one, this method just returns false. * * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _currentValue assumed number of tokens currently allowed to be * transferred * @param _newValue number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _currentValue, uint256 _newValue) public returns (bool success) { if (allowance (msg.sender, _spender) == _currentValue) return approve (_spender, _newValue); else return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _address of new or existing owner of the smart contract * @param _value boolean stating if the _address should be an owner or not */ function setOwner (address _address, bool _value) public { require (owners[msg.sender]); // if removing the _address from owners list, make sure owner is not // removing himself (which could lead to an ownerless contract). require (_value == true || _address != msg.sender); owners[_address] = _value; } /** * Initialize the token holders by contract owner * * @param _to addresses to allocate token for * @param _value number of tokens to be allocated */ function initAccounts (address [] _to, uint256 [] _value) public { require (owners[msg.sender]); require (_to.length == _value.length); for (uint256 i=0; i < _to.length; i++){ uint256 amountToAdd; uint256 amountToSub; if (_value[i] > accounts[_to[i]]){ amountToAdd = safeSub(_value[i], accounts[_to[i]]); }else{ amountToSub = safeSub(accounts[_to[i]], _value[i]); } accounts [supplyOwner] = safeAdd (accounts [supplyOwner], amountToSub); accounts [supplyOwner] = safeSub (accounts [supplyOwner], amountToAdd); if (!hasAccount[_to[i]]) { hasAccount[_to[i]] = true; accountList.push(_to[i]); } accounts [_to[i]] = _value[i]; if (amountToAdd > 0){ emit Transfer (supplyOwner, _to[i], amountToAdd); } } } /** * Initialize the token holders and hold amounts by contract owner * * @param _to addresses to allocate token for * @param _value number of tokens to be allocated * @param _holds number of tokens to hold from transferring */ function initAccounts (address [] _to, uint256 [] _value, uint256 [] _holds) public { setHolds(_to, _holds); initAccounts(_to, _value); } /** * Set the number of tokens to hold from transferring for a list of * token holders. * * @param _account list of account holders * @param _value list of token amounts to hold */ function setHolds (address [] _account, uint256 [] _value) public { require (owners[msg.sender]); require (_account.length == _value.length); for (uint256 i=0; i < _account.length; i++){ holds[_account[i]] = _value[i]; } } /** * Get the number of account holders (for owner use) * * @return uint256 */ function getNumAccounts () public constant returns (uint256 count) { require (owners[msg.sender]); return accountList.length; } /** * Get a list of account holder eth addresses (for owner use) * * @param _start index of the account holder list * @param _count of items to return * @return array of addresses */ function getAccounts (uint256 _start, uint256 _count) public constant returns (address [] addresses){ require (owners[msg.sender]); require (_start >= 0 && _count >= 1); if (_start == 0 && _count >= accountList.length) { return accountList; } address [] memory _slice = new address[](_count); for (uint256 i=0; i < _count; i++){ _slice[i] = accountList[i + _start]; } return _slice; } /** * Freeze token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (owners[msg.sender]); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (owners[msg.sender]); if (frozen) { frozen = false; emit Unfreeze (); } } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Kill the token. */ function kill() public { if (owners[msg.sender]) selfdestruct(msg.sender); } }
0x
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "suicidal", "impact": "High", "confidence": "High"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'suicidal', 'impact': 'High', 'confidence': 'High'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 21084, 2063, 2683, 2063, 2581, 2050, 2475, 2094, 2549, 2050, 2475, 2278, 2509, 2063, 2620, 10790, 2278, 23632, 2094, 2620, 2620, 20958, 2094, 2575, 2581, 29097, 16703, 22275, 2581, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 10061, 19204, 6047, 3206, 1012, 9385, 1075, 2418, 2011, 19935, 2243, 10552, 1012, 1008, 3166, 1024, 11318, 8748, 4492, 1026, 11318, 1012, 8748, 4492, 1030, 20917, 4014, 1012, 4012, 1028, 1008, 1013, 1013, 1008, 1008, 1008, 9413, 2278, 1011, 2322, 3115, 19204, 8278, 1010, 2004, 4225, 1008, 1026, 1037, 17850, 12879, 1027, 1000, 8299, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 2322, 1000, 1028, 2182, 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,958
0x97a65a781fd23e3d180d99b8c78c3d2bf4a06d4f
/* Copyright 2021 Popcorn Network https://popcorn.network/ */ pragma solidity ^0.8.9; // SPDX-License-Identifier: MIT interface ERC20 { 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 ); } interface ERC20Metadata is ERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { _setOwner(msg.sender); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } 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); } } interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IpancakePair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IpancakeRouter01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } interface IpancakeRouter02 is IpancakeRouter01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } // Bep20 standards for token creation by bloctechsolutions.com contract Popcorn is Context, ERC20, ERC20Metadata, Ownable { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromMaxTx; IpancakeRouter02 public pancakeRouter; address public pancakePair; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; bool public _antiwhale = false; //once switched on, can never be switched off. uint256 public _maxTxAmount; constructor() { _name = "Popcorn Network"; _symbol = "POPCORN"; _decimals = 18; _totalSupply = 1000000000 * 1e18; _balances[owner()] = _totalSupply; _maxTxAmount = _totalSupply.mul(100).div(100); IpancakeRouter02 _pancakeRouter = IpancakeRouter02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D // UniswapV2Router02 ); // Create a uniswap pair for this new token pancakePair = IUniswapV2Factory(_pancakeRouter.factory()).createPair( address(this), _pancakeRouter.WETH() ); // set the rest of the contract variables pancakeRouter = _pancakeRouter; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _totalSupply); } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return _decimals; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } 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 AntiWhale() external onlyOwner { _antiwhale = true; } 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, "WE: transfer amount exceeds allowance" ); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } // for 1% input 1 function setMaxTxPercent(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = _totalSupply.mul(maxTxAmount).div(100); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require( currentAllowance >= subtractedValue, "WE: decreased allowance below zero" ); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "WE: transfer from the zero address"); require(recipient != address(0), "WE: transfer to the zero address"); require(amount > 0, "WE: Transfer amount must be greater than zero"); if(_isExcludedFromMaxTx[sender] == false && _isExcludedFromMaxTx[recipient] == false // by default false ){ require(amount <= _maxTxAmount,"amount exceed max limit"); if (!_antiwhale && sender != owner() && recipient != owner()) { require(recipient != pancakePair, " WE:antuwhale is not enabled"); } } _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "WE: transfer amount exceeds balance" ); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c8063715018a6116100b8578063a9059cbb1161007c578063a9059cbb1461026e578063b8c9d25c14610281578063c21ebd0714610294578063d543dbeb146102a7578063dd62ed3e146102ba578063f2fde38b146102f357600080fd5b8063715018a61461021d5780637d1db4a5146102255780638da5cb5b1461022e57806395d89b4114610253578063a457c2d71461025b57600080fd5b806339509351116100ff57806339509351146101b75780634ce4898f146101ca5780635b89029c146101d75780636adeb40d146101ec57806370a08231146101f457600080fd5b806306fdde031461013c578063095ea7b31461015a57806318160ddd1461017d57806323b872dd1461018f578063313ce567146101a2575b600080fd5b610144610306565b6040516101519190610cc5565b60405180910390f35b61016d610168366004610d36565b610398565b6040519015158152602001610151565b6009545b604051908152602001610151565b61016d61019d366004610d60565b6103af565b60085460405160ff9091168152602001610151565b61016d6101c5366004610d36565b61045b565b600a5461016d9060ff1681565b6101ea6101e5366004610d9c565b610497565b005b6101ea6104ec565b610181610202366004610dd8565b6001600160a01b031660009081526001602052604090205490565b6101ea610525565b610181600b5481565b6000546001600160a01b03165b6040516001600160a01b039091168152602001610151565b61014461055b565b61016d610269366004610d36565b61056a565b61016d61027c366004610d36565b610600565b60055461023b906001600160a01b031681565b60045461023b906001600160a01b031681565b6101ea6102b5366004610df3565b61060d565b6101816102c8366004610e0c565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101ea610301366004610dd8565b61065d565b60606006805461031590610e3f565b80601f016020809104026020016040519081016040528092919081815260200182805461034190610e3f565b801561038e5780601f106103635761010080835404028352916020019161038e565b820191906000526020600020905b81548152906001019060200180831161037157829003601f168201915b5050505050905090565b60006103a53384846107c0565b5060015b92915050565b60006103bc8484846108e4565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156104435760405162461bcd60e51b815260206004820152602560248201527f57453a207472616e7366657220616d6f756e74206578636565647320616c6c6f60448201526477616e636560d81b60648201526084015b60405180910390fd5b61045085338584036107c0565b506001949350505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916103a5918590610492908690610e90565b6107c0565b6000546001600160a01b031633146104c15760405162461bcd60e51b815260040161043a90610ea8565b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146105165760405162461bcd60e51b815260040161043a90610ea8565b600a805460ff19166001179055565b6000546001600160a01b0316331461054f5760405162461bcd60e51b815260040161043a90610ea8565b6105596000610c3e565b565b60606007805461031590610e3f565b3360009081526002602090815260408083206001600160a01b0386168452909152812054828110156105e95760405162461bcd60e51b815260206004820152602260248201527f57453a2064656372656173656420616c6c6f77616e63652062656c6f77207a65604482015261726f60f01b606482015260840161043a565b6105f633858584036107c0565b5060019392505050565b60006103a53384846108e4565b6000546001600160a01b031633146106375760405162461bcd60e51b815260040161043a90610ea8565b6106576064610651836009546106f890919063ffffffff16565b9061077e565b600b5550565b6000546001600160a01b031633146106875760405162461bcd60e51b815260040161043a90610ea8565b6001600160a01b0381166106ec5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161043a565b6106f581610c3e565b50565b600082610707575060006103a9565b60006107138385610edd565b9050826107208583610efc565b146107775760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161043a565b9392505050565b600061077783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610c8e565b6001600160a01b0383166108225760405162461bcd60e51b8152602060048201526024808201527f42455032303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161043a565b6001600160a01b0382166108835760405162461bcd60e51b815260206004820152602260248201527f42455032303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161043a565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166109455760405162461bcd60e51b815260206004820152602260248201527f57453a207472616e736665722066726f6d20746865207a65726f206164647265604482015261737360f01b606482015260840161043a565b6001600160a01b03821661099b5760405162461bcd60e51b815260206004820181905260248201527f57453a207472616e7366657220746f20746865207a65726f2061646472657373604482015260640161043a565b60008111610a015760405162461bcd60e51b815260206004820152602d60248201527f57453a205472616e7366657220616d6f756e74206d757374206265206772656160448201526c746572207468616e207a65726f60981b606482015260840161043a565b6001600160a01b03831660009081526003602052604090205460ff16158015610a4357506001600160a01b03821660009081526003602052604090205460ff16155b15610b3857600b54811115610a9a5760405162461bcd60e51b815260206004820152601760248201527f616d6f756e7420657863656564206d6178206c696d6974000000000000000000604482015260640161043a565b600a5460ff16158015610abb57506000546001600160a01b03848116911614155b8015610ad557506000546001600160a01b03838116911614155b15610b38576005546001600160a01b0383811691161415610b385760405162461bcd60e51b815260206004820152601c60248201527f2057453a616e74757768616c65206973206e6f7420656e61626c656400000000604482015260640161043a565b6001600160a01b03831660009081526001602052604090205481811015610bad5760405162461bcd60e51b815260206004820152602360248201527f57453a207472616e7366657220616d6f756e7420657863656564732062616c616044820152626e636560e81b606482015260840161043a565b6001600160a01b03808516600090815260016020526040808220858503905591851681529081208054849290610be4908490610e90565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c3091815260200190565b60405180910390a350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008183610caf5760405162461bcd60e51b815260040161043a9190610cc5565b506000610cbc8486610efc565b95945050505050565b600060208083528351808285015260005b81811015610cf257858101830151858201604001528201610cd6565b81811115610d04576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610d3157600080fd5b919050565b60008060408385031215610d4957600080fd5b610d5283610d1a565b946020939093013593505050565b600080600060608486031215610d7557600080fd5b610d7e84610d1a565b9250610d8c60208501610d1a565b9150604084013590509250925092565b60008060408385031215610daf57600080fd5b610db883610d1a565b915060208301358015158114610dcd57600080fd5b809150509250929050565b600060208284031215610dea57600080fd5b61077782610d1a565b600060208284031215610e0557600080fd5b5035919050565b60008060408385031215610e1f57600080fd5b610e2883610d1a565b9150610e3660208401610d1a565b90509250929050565b600181811c90821680610e5357607f821691505b60208210811415610e7457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610ea357610ea3610e7a565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000816000190483118215151615610ef757610ef7610e7a565b500290565b600082610f1957634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220c6a6d1ac50b97789852a15563761b134d11ce4baa50ebe6bfaaea7310b8bd8f064736f6c634300080a0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 26187, 2050, 2581, 2620, 2487, 2546, 2094, 21926, 2063, 29097, 15136, 2692, 2094, 2683, 2683, 2497, 2620, 2278, 2581, 2620, 2278, 29097, 2475, 29292, 2549, 2050, 2692, 2575, 2094, 2549, 2546, 1013, 1008, 9385, 25682, 24593, 2897, 16770, 1024, 1013, 1013, 24593, 1012, 2897, 1013, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1023, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 8278, 9413, 2278, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 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,959
0x97a7194136126CAC8F879b995973082B6F9a3123
pragma solidity ^0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenBEP20 is BEP20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "BLESS"; name = "Bless america "; decimals = 0; _totalSupply = 1000000000000000; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } contract BLESSAMERICA is TokenBEP20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } }
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a914610570578063cae9ca5114610587578063d4ee1d9014610691578063dd62ed3e146106e8578063f2fde38b1461076d576100fe565b806381f4f399146103c55780638da5cb5b1461041657806395d89b411461046d578063a9059cbb146104fd576100fe565b806323b872dd116100d157806323b872dd14610285578063313ce5671461031857806370a082311461034957806379ba5097146103ae576100fe565b806306fdde0314610100578063095ea7b31461019057806318160ddd146102035780631ee59f201461022e575b005b34801561010c57600080fd5b506101156107be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015557808201518184015260208101905061013a565b50505050905090810190601f1680156101825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019c57600080fd5b506101e9600480360360408110156101b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085c565b604051808215151515815260200191505060405180910390f35b34801561020f57600080fd5b5061021861094e565b6040518082815260200191505060405180910390f35b34801561023a57600080fd5b506102436109a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029157600080fd5b506102fe600480360360608110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561032457600080fd5b5061032d610e14565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e27565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e70565b005b3480156103d157600080fd5b50610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061100d565b005b34801561042257600080fd5b5061042b6110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047957600080fd5b506104826110cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c25780820151818401526020810190506104a7565b50505050905090810190601f1680156104ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105856113cc565b005b34801561059357600080fd5b50610677600480360360608110156105aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611474565b604051808215151515815260200191505060405180910390f35b34801561069d57600080fd5b506106a66116a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f457600080fd5b506107576004803603604081101561070b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116cd565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107bc6004803603602081101561079057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611754565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108545780601f1061082957610100808354040283529160200191610854565b820191906000526020600020905b81548152906001019060200180831161083757829003601f168201915b505050505081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006109a4600760008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546005546117f190919063ffffffff16565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610a5b5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15610aa65782600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b6b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b610bbd82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8f82600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6182600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eca57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106657600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111655780601f1061113a57610100808354040283529160200191611165565b820191906000526020600020905b81548152906001019060200180831161114857829003601f168201915b505050505081565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b61128582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061131a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461142557600080fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611470573d6000803e3d6000fd5b5050565b600082600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561163557808201518184015260208101905061161a565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117ad57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561180057600080fd5b818303905092915050565b600081830190508281101561181f57600080fd5b9291505056fea265627a7a72315820bcc1466719e622f1d1708a0688938027f7b2b109e6a5b8b2cd701094f904bacf64736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 2581, 16147, 23632, 21619, 12521, 2575, 3540, 2278, 2620, 2546, 2620, 2581, 2683, 2497, 2683, 2683, 28154, 2581, 14142, 2620, 2475, 2497, 2575, 2546, 2683, 2050, 21486, 21926, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 5587, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 1039, 1007, 1063, 1039, 1027, 1037, 1009, 1038, 1025, 5478, 1006, 1039, 1028, 1027, 1037, 1007, 1025, 1065, 3853, 4942, 1006, 21318, 3372, 1037, 1010, 21318, 3372, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 1039, 1007, 1063, 5478, 1006, 1038, 1026, 1027, 1037, 1007, 1025, 1039, 1027, 1037, 1011, 1038, 1025, 1065, 3853, 14163, 2140, 1006, 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,960
0x97a8956bc9e74b13e3e153f890699dae3dfae772
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract MyAdvancedToken is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => uint) public lockAmount; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function MyAdvancedToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } function lock(address ownerAddress,uint Amount) public onlyOwner { require(Amount>0); require(balanceOf[ownerAddress]>=Amount); balanceOf[ownerAddress]-=Amount; lockAmount[ownerAddress]+=Amount; } function unlock(address ownerAddress,uint unlockAmount) public onlyOwner { require(unlockAmount>0); require(lockAmount[ownerAddress]>=unlockAmount); balanceOf[ownerAddress]+=unlockAmount; lockAmount[ownerAddress]-=unlockAmount; } function rename(string newtokenName,string newtokenSymbol) onlyOwner public { name=newtokenName; symbol=newtokenSymbol; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value *(10**18)/ buyPrice; // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers if(!owner.send(msg.value)){ revert(); } } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = this; require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
0x6060604052600436106101535763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305fefda7811461015857806306fdde0314610173578063095ea7b3146101fd57806318160ddd1461023357806323b872dd14610258578063282d3fdf14610280578063313ce567146102a257806342966c68146102cb5780634b750334146102e157806370a08231146102f457806379c650681461031357806379cc6790146103355780637eee288d146103575780638620410b146103795780638da5cb5b1461038c57806395bc3bd0146103bb57806395d89b41146103da5780639c7c722b146103ed578063a6f2ae3a14610480578063a9059cbb14610488578063b414d4b6146104aa578063cae9ca51146104c9578063dd62ed3e1461052e578063e4849b3214610553578063e724529c14610569578063f2fde38b1461058d575b600080fd5b341561016357600080fd5b6101716004356024356105ac565b005b341561017e57600080fd5b6101866105d2565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101c25780820151838201526020016101aa565b50505050905090810190601f1680156101ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561020857600080fd5b61021f600160a060020a0360043516602435610670565b604051901515815260200160405180910390f35b341561023e57600080fd5b6102466106a0565b60405190815260200160405180910390f35b341561026357600080fd5b61021f600160a060020a03600435811690602435166044356106a6565b341561028b57600080fd5b610171600160a060020a036004351660243561071d565b34156102ad57600080fd5b6102b561079e565b60405160ff909116815260200160405180910390f35b34156102d657600080fd5b61021f6004356107a7565b34156102ec57600080fd5b610246610832565b34156102ff57600080fd5b610246600160a060020a0360043516610838565b341561031e57600080fd5b610171600160a060020a036004351660243561084a565b341561034057600080fd5b61021f600160a060020a0360043516602435610910565b341561036257600080fd5b610171600160a060020a03600435166024356109ec565b341561038457600080fd5b610246610a6d565b341561039757600080fd5b61039f610a73565b604051600160a060020a03909116815260200160405180910390f35b34156103c657600080fd5b610246600160a060020a0360043516610a82565b34156103e557600080fd5b610186610a94565b34156103f857600080fd5b61017160046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650610aff95505050505050565b610171610b46565b341561049357600080fd5b61021f600160a060020a0360043516602435610ba4565b34156104b557600080fd5b61021f600160a060020a0360043516610bba565b34156104d457600080fd5b61021f60048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610bcf95505050505050565b341561053957600080fd5b610246600160a060020a0360043581169060243516610cfd565b341561055e57600080fd5b610171600435610d1a565b341561057457600080fd5b610171600160a060020a03600435166024351515610d7d565b341561059857600080fd5b610171600160a060020a0360043516610e09565b60005433600160a060020a039081169116146105c757600080fd5b600791909155600855565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106685780601f1061063d57610100808354040283529160200191610668565b820191906000526020600020905b81548152906001019060200180831161064b57829003601f168201915b505050505081565b600160a060020a033381166000908152600660209081526040808320938616835292905220819055600192915050565b60045481565b600160a060020a038084166000908152600660209081526040808320339094168352929052908120548211156106db57600080fd5b600160a060020a0380851660009081526006602090815260408083203390941683529290522080548390039055610713848484610e53565b5060019392505050565b60005433600160a060020a0390811691161461073857600080fd5b6000811161074557600080fd5b600160a060020a0382166000908152600560205260409020548190101561076b57600080fd5b600160a060020a039091166000908152600560209081526040808320805485900390556009909152902080549091019055565b60035460ff1681565b600160a060020a033316600090815260056020526040812054829010156107cd57600080fd5b600160a060020a03331660008181526005602052604090819020805485900390556004805485900390557fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a2506001919050565b60075481565b60056020526000908152604090205481565b60005433600160a060020a0390811691161461086557600080fd5b600160a060020a03808316600090815260056020526040808220805485019055600480548501905530909216917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a381600160a060020a031630600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a35050565b600160a060020a0382166000908152600560205260408120548290101561093657600080fd5b600160a060020a038084166000908152600660209081526040808320339094168352929052205482111561096957600080fd5b600160a060020a038084166000818152600560209081526040808320805488900390556006825280832033909516835293905282902080548590039055600480548590039055907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a250600192915050565b60005433600160a060020a03908116911614610a0757600080fd5b60008111610a1457600080fd5b600160a060020a03821660009081526009602052604090205481901015610a3a57600080fd5b600160a060020a039091166000908152600560209081526040808320805485019055600990915290208054919091039055565b60085481565b600054600160a060020a031681565b60096020526000908152604090205481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106685780601f1061063d57610100808354040283529160200191610668565b60005433600160a060020a03908116911614610b1a57600080fd5b6001828051610b2d929160200190610f6b565b506002818051610b41929160200190610f6b565b505050565b600060085434670de0b6b3a764000002811515610b5f57fe5b049050610b6d303383610e53565b600054600160a060020a03163480156108fc0290604051600060405180830381858888f193505050501515610ba157600080fd5b50565b6000610bb1338484610e53565b50600192915050565b600a6020526000908152604090205460ff1681565b600083610bdc8185610670565b15610cf55780600160a060020a0316638f4ffcb1338630876040518563ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610c92578082015183820152602001610c7a565b50505050905090810190601f168015610cbf5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610ce057600080fd5b5af11515610ced57600080fd5b505050600191505b509392505050565b600660209081526000928352604080842090915290825290205481565b60075430908202600160a060020a038216311015610d3757600080fd5b610d42333084610e53565b33600160a060020a03166108fc60075484029081150290604051600060405180830381858888f193505050501515610d7957600080fd5b5050565b60005433600160a060020a03908116911614610d9857600080fd5b600160a060020a0382166000908152600a602052604090819020805460ff19168315151790557f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a5908390839051600160a060020a039092168252151560208201526040908101905180910390a15050565b60005433600160a060020a03908116911614610e2457600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a0382161515610e6857600080fd5b600160a060020a03831660009081526005602052604090205481901015610e8e57600080fd5b600160a060020a0382166000908152600560205260409020548181011015610eb557600080fd5b600160a060020a0383166000908152600a602052604090205460ff1615610edb57600080fd5b600160a060020a0382166000908152600a602052604090205460ff1615610f0157600080fd5b600160a060020a038084166000818152600560205260408082208054869003905592851680825290839020805485019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a3505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610fac57805160ff1916838001178555610fd9565b82800160010185558215610fd9579182015b82811115610fd9578251825591602001919060010190610fbe565b50610fe5929150610fe9565b5090565b61100391905b80821115610fe55760008155600101610fef565b905600a165627a7a723058205b5dab352b4045b49ddd1e2f64b73dc51cbad26f0729d0c493576cb845a17b5a0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2050, 2620, 2683, 26976, 9818, 2683, 2063, 2581, 2549, 2497, 17134, 2063, 2509, 2063, 16068, 2509, 2546, 2620, 21057, 2575, 2683, 2683, 6858, 29097, 7011, 2063, 2581, 2581, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2385, 1025, 3206, 3079, 1063, 4769, 2270, 3954, 1025, 3853, 3079, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 16913, 18095, 2069, 12384, 2121, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1007, 1025, 1035, 1025, 1065, 3853, 4651, 12384, 2545, 5605, 1006, 4769, 2047, 12384, 2121, 1007, 2069, 12384, 2121, 2270, 1063, 3954, 1027, 2047, 12384, 2121, 1025, 1065, 1065, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,961
0x97a89a0286a673ac8cdabbc42e5b2aaae74b09e5
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // /$$$$$$ /$$$$$$$ /$$ // /$$$_ $$ | $$__ $$ |__/ // | $$$$\ $$ /$$ /$$| $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$$$$$$ // | $$ $$ $$| $$ /$$/| $$ | $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$_____/ /$$__ $$| $$| $$__ $$ // | $$\ $$$$ \ $$$$/ | $$ | $$| $$ \ $$| $$ \ $$| $$$$$$$$| $$ | $$ \ $$| $$| $$ \ $$ // | $$ \ $$$ >$$ $$ | $$ | $$| $$ | $$| $$ | $$| $$_____/| $$ | $$ | $$| $$| $$ | $$ // | $$$$$$/ /$$/\ $$| $$$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$| $$$$$$$| $$$$$$/| $$| $$ | $$ // \______/ |__/ \__/|_______/ \______/ \____ $$ \_______/ \_______/ \______/ |__/|__/ |__/ // /$$ \ $$ // | $$$$$$/ // \______/ // // Official OxDogecoin website: http://0xdogecoin.com // '0xDogecoin' contract // Mineable ERC20 Token using Proof Of Work // // Symbol : 0xDoge // Name : 0xDogecoin // Total supply: 1 000 000 000 (1 Billion) // Decimals : 8 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } library ExtendedMath { //return the smaller of the two inputs (a or b) function limitLessThan(uint a, uint b) internal pure returns (uint c) { if(a > b) return b; return a; } } // ---------------------------------------------------------------------------- // 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); } } interface EIP918Interface { function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success); function getChallengeNumber() public constant returns (bytes32); function getMiningDifficulty() public constant returns (uint); function getMiningTarget() public constant returns (uint); function getMiningReward() public constant returns (uint); event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber); } // ---------------------------------------------------------------------------- // Mineable ERC918 / ERC20 Token // ---------------------------------------------------------------------------- contract _0xDogecoin is ERC20Interface, Owned, EIP918Interface { using SafeMath for uint; using ExtendedMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public latestDifficultyPeriodStarted; uint public epochCount; //number of 'blocks' mined uint public _BLOCKS_PER_READJUSTMENT = 512; //a little number and a big number uint public _MINIMUM_TARGET = 2**16; uint public _MAXIMUM_TARGET = 2**234; uint public miningTarget; bytes32 public challengeNumber; //generate a new one when a new reward is minted uint public rewardEra; uint public maxSupplyForEra; address public lastRewardTo; uint public lastRewardAmount; uint public lastRewardEthBlockNumber; bool locked = false; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function _0xDogecoin() public onlyOwner{ symbol = "0xDoge"; name = "0xDogecoin"; decimals = 8; _totalSupply = 1000000000 * 10**uint(decimals); if(locked) revert(); locked = true; tokensMinted = 0; rewardEra = 0; maxSupplyForEra = _totalSupply.div(2); miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.number; _startNewMiningEpoch(); } function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) { //the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender's address to prevent MITM attacks bytes32 digest = keccak256(challengeNumber, msg.sender, nonce ); //the challenge digest must match the expected if (digest != challenge_digest) revert(); //the digest must be smaller than the target if(uint256(digest) > miningTarget) revert(); //only allow one reward for each challenge bytes32 solution = solutionForChallenge[challengeNumber]; solutionForChallenge[challengeNumber] = digest; if(solution != 0x0) revert(); //prevent the same answer from awarding twice uint reward_amount = getMiningReward(); balances[msg.sender] = balances[msg.sender].add(reward_amount); tokensMinted = tokensMinted.add(reward_amount); //Cannot mint more tokens than there are assert(tokensMinted <= maxSupplyForEra); //set readonly diagnostics data lastRewardTo = msg.sender; lastRewardAmount = reward_amount; lastRewardEthBlockNumber = block.number; _startNewMiningEpoch(); Mint(msg.sender, reward_amount, epochCount, challengeNumber ); return true; } //a new 'block' to be mined function _startNewMiningEpoch() internal { //if max supply for the era will be exceeded next reward round then enter the new era before that happens //40 is the final reward era, almost all tokens minted //once the final era is reached, more tokens will not be given out because the assert function if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39) { rewardEra = rewardEra + 1; } //set the next minted supply at which the era will change // total supply is 100000000000000000 because of 8 decimal places maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = block.blockhash(block.number - 1); } //readjust the target by 5 percent function _reAdjustDifficulty() internal { uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted; //assume 360 ethereum blocks per hour //we want miners to spend 2 minutes to mine each 'block', about 12 ethereum blocks = one 0xDoge epoch uint epochsMined = _BLOCKS_PER_READJUSTMENT; uint targetEthBlocksPerDiffPeriod = epochsMined * 12; //should be 12 times slower than ethereum //if there were less eth blocks passed in time than expected if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod ) { uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod ); uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000); // If there were 5% more blocks mined than expected then this is 5. If there were 100% more blocks mined than expected then this is 100. //make it harder miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); //by up to 50 % }else{ uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod ); uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); //always between 0 and 1000 //make it easier miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); //by up to 50 % } latestDifficultyPeriodStarted = block.number; if(miningTarget < _MINIMUM_TARGET) //very difficult { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) //very easy { miningTarget = _MAXIMUM_TARGET; } } //this is a recent ethereum block hash, used to prevent pre-mining future blocks function getChallengeNumber() public constant returns (bytes32) { return challengeNumber; } //the number of zeroes the digest of the PoW solution requires. Auto adjusts function getMiningDifficulty() public constant returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public constant returns (uint) { return miningTarget; } //reward is cut in half every reward era (as tokens are mined) function getMiningReward() public constant returns (uint) { //every reward era, the reward amount halves. return (5000 * 10**uint(decimals) ).div( 2**rewardEra ) ; } //help debug mining software function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); return digest; } //help debug mining software function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } // ------------------------------------------------------------------------ // 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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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); } }
0x6060604052600436106101c2576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146101c7578063095ea7b314610255578063163aa00d146102af57806317da485f146102d85780631801fbe51461030157806318160ddd1461034957806323b872dd146103725780632d38bf7a146103eb578063313ce5671461041457806332e99708146104435780633eaaf86b1461046c578063490203a7146104955780634ef37628146104be5780634fa972e1146104ef5780636de9f32b146105185780636fd396d61461054157806370a082311461059657806379ba5097146105e357806381269a56146105f8578063829965cc1461065657806387a2a9d61461067f5780638a769d35146106a85780638ae0368b146106d15780638da5cb5b1461070257806395d89b411461075757806397566aa0146107e5578063a9059cbb1461083e578063b5ade81b14610898578063bafedcaa146108c1578063cae9ca51146108ea578063cb9ae70714610987578063d4ee1d90146109b0578063dc39d06d14610a05578063dc6e9cf914610a5f578063dd62ed3e14610a88578063f2fde38b14610af4575b600080fd5b34156101d257600080fd5b6101da610b2d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561021a5780820151818401526020810190506101ff565b50505050905090810190601f1680156102475780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026057600080fd5b610295600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610bcb565b604051808215151515815260200191505060405180910390f35b34156102ba57600080fd5b6102c2610cbd565b6040518082815260200191505060405180910390f35b34156102e357600080fd5b6102eb610cc3565b6040518082815260200191505060405180910390f35b341561030c57600080fd5b61032f600480803590602001909190803560001916906020019091905050610ce1565b604051808215151515815260200191505060405180910390f35b341561035457600080fd5b61035c610f71565b6040518082815260200191505060405180910390f35b341561037d57600080fd5b6103d1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610fbc565b604051808215151515815260200191505060405180910390f35b34156103f657600080fd5b6103fe611267565b6040518082815260200191505060405180910390f35b341561041f57600080fd5b61042761126d565b604051808260ff1660ff16815260200191505060405180910390f35b341561044e57600080fd5b610456611280565b6040518082815260200191505060405180910390f35b341561047757600080fd5b61047f61128a565b6040518082815260200191505060405180910390f35b34156104a057600080fd5b6104a8611290565b6040518082815260200191505060405180910390f35b34156104c957600080fd5b6104d16112c8565b60405180826000191660001916815260200191505060405180910390f35b34156104fa57600080fd5b6105026112d2565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61052b6112d8565b6040518082815260200191505060405180910390f35b341561054c57600080fd5b6105546112de565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156105a157600080fd5b6105cd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611304565b6040518082815260200191505060405180910390f35b34156105ee57600080fd5b6105f661134d565b005b341561060357600080fd5b61063c600480803590602001909190803560001916906020019091908035600019169060200190919080359060200190919050506114ec565b604051808215151515815260200191505060405180910390f35b341561066157600080fd5b610669611581565b6040518082815260200191505060405180910390f35b341561068a57600080fd5b610692611587565b6040518082815260200191505060405180910390f35b34156106b357600080fd5b6106bb61158d565b6040518082815260200191505060405180910390f35b34156106dc57600080fd5b6106e4611593565b60405180826000191660001916815260200191505060405180910390f35b341561070d57600080fd5b610715611599565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561076257600080fd5b61076a6115be565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107aa57808201518184015260208101905061078f565b50505050905090810190601f1680156107d75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156107f057600080fd5b6108206004808035906020019091908035600019169060200190919080356000191690602001909190505061165c565b60405180826000191660001916815260200191505060405180910390f35b341561084957600080fd5b61087e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506116d5565b604051808215151515815260200191505060405180910390f35b34156108a357600080fd5b6108ab611870565b6040518082815260200191505060405180910390f35b34156108cc57600080fd5b6108d4611876565b6040518082815260200191505060405180910390f35b34156108f557600080fd5b61096d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061187c565b604051808215151515815260200191505060405180910390f35b341561099257600080fd5b61099a611ac6565b6040518082815260200191505060405180910390f35b34156109bb57600080fd5b6109c3611acc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3415610a1057600080fd5b610a45600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611af2565b604051808215151515815260200191505060405180910390f35b3415610a6a57600080fd5b610a72611c3e565b6040518082815260200191505060405180910390f35b3415610a9357600080fd5b610ade600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c44565b6040518082815260200191505060405180910390f35b3415610aff57600080fd5b610b2b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611ccb565b005b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bc35780601f10610b9857610100808354040283529160200191610bc3565b820191906000526020600020905b815481529060010190602001808311610ba657829003601f168201915b505050505081565b600081601660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60115481565b6000610cdc600b54600a54611d6a90919063ffffffff16565b905090565b600080600080600c5433876040518084600019166000191681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200193505050506040518091039020925084600019168360001916141515610d6a57600080fd5b600b5483600190041115610d7d57600080fd5b60136000600c54600019166000191681526020019081526020016000205491508260136000600c5460001916600019168152602001908152602001600020816000191690555060006001028260001916141515610dd957600080fd5b610de1611290565b9050610e3581601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8e90919063ffffffff16565b601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e8d81601454611d8e90919063ffffffff16565b601481905550600e5460145411151515610ea357fe5b33600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060108190555043601181905550610efa611daa565b3373ffffffffffffffffffffffffffffffffffffffff167fcf6fbb9dcea7d07263ab4f5c3a92f53af33dffc421d9d121e1c74b307e68189d82600754600c54604051808481526020018381526020018260001916600019168152602001935050505060405180910390a26001935050505092915050565b6000601560008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b600061101082601560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e5f90919063ffffffff16565b601560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110e282601660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e5f90919063ffffffff16565b601660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111b482601560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8e90919063ffffffff16565b601560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600d5481565b600460009054906101000a900460ff1681565b6000600b54905090565b60055481565b60006112c3600d5460020a600460009054906101000a900460ff1660ff16600a0a61138802611d6a90919063ffffffff16565b905090565b6000600c54905090565b600e5481565b60145481565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000601560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113a957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000808333876040518084600019166000191681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401828152602001935050505060405180910390209050828160019004111561156b57600080fd5b8460001916816000191614915050949350505050565b60075481565b600a5481565b600b5481565b600c5481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116545780601f1061162957610100808354040283529160200191611654565b820191906000526020600020905b81548152906001019060200180831161163757829003601f168201915b505050505081565b6000808233866040518084600019166000191681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401828152602001935050505060405180910390209050809150509392505050565b600061172982601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e5f90919063ffffffff16565b601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117be82601560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8e90919063ffffffff16565b601560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60085481565b60105481565b600082601660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611a59578082015181840152602081019050611a3e565b50505050905090810190601f168015611a865780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515611aa757600080fd5b6102c65a03f11515611ab857600080fd5b505050600190509392505050565b60065481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611b4f57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515611c1b57600080fd5b6102c65a03f11515611c2c57600080fd5b50505060405180519050905092915050565b60095481565b6000601660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611d2657600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008082111515611d7a57600080fd5b8183811515611d8557fe5b04905092915050565b60008183019050828110151515611da457600080fd5b92915050565b600e54611dc9611db8611290565b601454611d8e90919063ffffffff16565b118015611dd857506027600d54105b15611dea576001600d5401600d819055505b611e076001600d540160020a600554611d6a90919063ffffffff16565b60055403600e81905550611e276001600754611d8e90919063ffffffff16565b6007819055506000600854600754811515611e3e57fe5b061415611e4e57611e4d611e7b565b5b6001430340600c8160001916905550565b6000828211151515611e7057600080fd5b818303905092915050565b6000806000806000806000600654430396506008549550600c8602945084871015611f3a57611ec687611eb860648861200c90919063ffffffff16565b611d6a90919063ffffffff16565b9350611ef06103e8611ee2606487611e5f90919063ffffffff16565b61203d90919063ffffffff16565b9250611f2f611f1e84611f106107d0600b54611d6a90919063ffffffff16565b61200c90919063ffffffff16565b600b54611e5f90919063ffffffff16565b600b81905550611fd0565b611f6085611f5260648a61200c90919063ffffffff16565b611d6a90919063ffffffff16565b9150611f8a6103e8611f7c606485611e5f90919063ffffffff16565b61203d90919063ffffffff16565b9050611fc9611fb882611faa6107d0600b54611d6a90919063ffffffff16565b61200c90919063ffffffff16565b600b54611d8e90919063ffffffff16565b600b819055505b43600681905550600954600b541015611fed57600954600b819055505b600a54600b54111561200357600a54600b819055505b50505050505050565b60008183029050600083148061202c575081838281151561202957fe5b04145b151561203757600080fd5b92915050565b60008183111561204f57819050612053565b8290505b929150505600a165627a7a72305820c236445cc5bfcb66c73d304938a0c127a93873e0ed4b54c2f0f38a450f2e7e070029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2620, 2683, 2050, 2692, 22407, 2575, 2050, 2575, 2581, 2509, 6305, 2620, 19797, 7875, 9818, 20958, 2063, 2629, 2497, 2475, 11057, 6679, 2581, 2549, 2497, 2692, 2683, 2063, 2629, 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,962
0x97a89ce35798841c586e2aff033c63a03bd238ae
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Decentralized ecosystem for financial product development // YDFI Finance // https://ydfi.finance //---------------------------------------------------------------------------- // 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 // ---------------------------------------------------------------------------- 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 // ---------------------------------------------------------------------------- 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 YDFIfinance 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 = "YDFI"; name = "YDFI Finance"; decimals = 18; _totalSupply = 10000000000000000000000; balances[0x0B8faD970D90ee541E2a005e510fbA2AeA046c2C] = _totalSupply; emit Transfer(address(0), 0x0B8faD970D90ee541E2a005e510fbA2AeA046c2C, _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 // ------------------------------------------------------------------------ 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); } } //--------------------------------------------- //All unsold tokens will be burned after the end of the ICO //--------------------------------------------
0x6080604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610116578063095ea7b3146101a057806318160ddd146101d857806323b872dd146101ff578063313ce567146102295780633eaaf86b1461025457806370a082311461026957806379ba50971461028a5780638da5cb5b146102a157806395d89b41146102d2578063a293d1e8146102e7578063a9059cbb14610302578063b5931f7c14610326578063cae9ca5114610341578063d05c78da146103aa578063d4ee1d90146103c5578063dc39d06d146103da578063dd62ed3e146103fe578063e6cb901314610425578063f2fde38b14610440575b600080fd5b34801561012257600080fd5b5061012b610461565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561016557818101518382015260200161014d565b50505050905090810190601f1680156101925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ac57600080fd5b506101c4600160a060020a03600435166024356104ef565b604080519115158252519081900360200190f35b3480156101e457600080fd5b506101ed610556565b60408051918252519081900360200190f35b34801561020b57600080fd5b506101c4600160a060020a0360043581169060243516604435610588565b34801561023557600080fd5b5061023e610681565b6040805160ff9092168252519081900360200190f35b34801561026057600080fd5b506101ed61068a565b34801561027557600080fd5b506101ed600160a060020a0360043516610690565b34801561029657600080fd5b5061029f6106ab565b005b3480156102ad57600080fd5b506102b6610733565b60408051600160a060020a039092168252519081900360200190f35b3480156102de57600080fd5b5061012b610742565b3480156102f357600080fd5b506101ed60043560243561079a565b34801561030e57600080fd5b506101c4600160a060020a03600435166024356107af565b34801561033257600080fd5b506101ed600435602435610853565b34801561034d57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101c4948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506108749650505050505050565b3480156103b657600080fd5b506101ed6004356024356109d5565b3480156103d157600080fd5b506102b66109fa565b3480156103e657600080fd5b506101c4600160a060020a0360043516602435610a09565b34801561040a57600080fd5b506101ed600160a060020a0360043581169060243516610ac4565b34801561043157600080fd5b506101ed600435602435610aef565b34801561044c57600080fd5b5061029f600160a060020a0360043516610aff565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b820191906000526020600020905b8154815290600101906020018083116104ca57829003601f168201915b505050505081565b336000818152600760209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105ab908361079a565b600160a060020a03851660009081526006602090815260408083209390935560078152828220338352905220546105e2908361079a565b600160a060020a0380861660009081526007602090815260408083203384528252808320949094559186168152600690915220546106209083610aef565b600160a060020a0380851660008181526006602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b600154600160a060020a031633146106c257600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b6000828211156107a957600080fd5b50900390565b336000908152600660205260408120546107c9908361079a565b3360009081526006602052604080822092909255600160a060020a038516815220546107f59083610aef565b600160a060020a0384166000818152600660209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161086157600080fd5b818381151561086c57fe5b049392505050565b336000818152600760209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a36040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018690523060448401819052608060648501908152865160848601528651600160a060020a038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b8381101561096457818101518382015260200161094c565b50505050905090810190601f1680156109915780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156109b357600080fd5b505af11580156109c7573d6000803e3d6000fd5b506001979650505050505050565b8181028215806109ef57508183828115156109ec57fe5b04145b151561055057600080fd5b600154600160a060020a031681565b60008054600160a060020a03163314610a2157600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610a9157600080fd5b505af1158015610aa5573d6000803e3d6000fd5b505050506040513d6020811015610abb57600080fd5b50519392505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561055057600080fd5b600054600160a060020a03163314610b1657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a723058202fc1bf67b848f276fd8ae9940d1c18cc90d39949851fb1a857dd6784de4516e10029
{"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, 2581, 2050, 2620, 2683, 3401, 19481, 2581, 2683, 2620, 2620, 23632, 2278, 27814, 2575, 2063, 2475, 10354, 2546, 2692, 22394, 2278, 2575, 2509, 2050, 2692, 2509, 2497, 2094, 21926, 2620, 6679, 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, 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,963
0x97a923ed35351a1382e6bcbb5239fc8d93360085
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; contract Champions is ERC721Enumerable, ReentrancyGuard, Ownable { string public _baseTokenURI; uint256 public _reserved = 150; uint256 public _maxChampPerWallet = 2; uint256 public _totalToBeMinted = 8888; uint256 public _price = 0.2 ether; bool public _paused = true; bytes32 public _merkleRoot; // team addresses address immutable _team; bool public _presale = true; uint256 public _presaleReserved = 0; constructor( string memory baseURI, address team, uint256 totalToBeMinted, uint256 reserved, uint256 presaleReserved, bytes32 merkleRoot ) ERC721("Champions", "CHAMPS") { setBaseURI(baseURI); _merkleRoot = merkleRoot; _team = team; _reserved = reserved; _totalToBeMinted = totalToBeMinted; _presaleReserved = presaleReserved; // team gets the first congressman for giveaway _safeMint(team, 0); } function summon(uint256 amount) external payable { require(!_paused, "Paused"); require(!_presale, "presale"); require( amount + balanceOf(msg.sender) <= _maxChampPerWallet && amount > 0, "!ChampsAmount" ); uint256 supply = totalSupply(); require(supply + amount <= _totalToBeMinted - _reserved, ">MaxSupply"); require(msg.value >= _price * amount, "!EthAmount"); for (uint256 i; i < amount; i++) { _safeMint(msg.sender, supply + i); } } // only accessible for whitelisted sender function whitelistSummon(uint256 amount, bytes32[] memory proof) external payable { require(!_paused, "Paused"); require(_presale, "!presale"); require(verify(proof, _merkleRoot), "!whitelist"); require( amount + balanceOf(msg.sender) <= _maxChampPerWallet && amount > 0, "!ChampsAmount" ); uint256 supply = totalSupply(); require( amount <= _presaleReserved && supply + amount <= _totalToBeMinted - _reserved, ">availableSupply" ); require(msg.value >= _price * amount, "!EthAmount"); for (uint256 i; i < amount; i++) { _safeMint(msg.sender, supply + i); } _presaleReserved -= amount; } function setPresalesParam( bytes32 merkleRootWhitelist, uint256 newAvailableAmount ) external onlyOwner { require(merkleRootWhitelist != bytes32(0), "!merkleRoot"); // we change the merkleroot to take into account the new whitelist _merkleRoot = merkleRootWhitelist; // we add the newly available nft to the presale reserve _presaleReserved = newAvailableAmount; } function setMaxChampPerWallet(uint256 _newMax) external onlyOwner { _maxChampPerWallet = _newMax; } // Just in case Eth does some crazy stuff function setPrice(uint256 _newPrice) external onlyOwner { _price = _newPrice; } function giveAway(address _to, uint256 _amount) external onlyOwner { require(_amount <= _reserved, ">reserved"); require(_amount > 0, "_amount==0"); require(_to != address(0), "_to==0"); uint256 supply = totalSupply(); for (uint256 i; i < _amount; i++) { _safeMint(_to, supply + i); } _reserved -= _amount; } function isWhitelisted(address account, bytes32[] memory proof) external view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(account)); return MerkleProof.verify(proof, _merkleRoot, leaf); } function setBaseURI(string memory baseURI) public onlyOwner { _baseTokenURI = baseURI; } 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 getPrice() public view returns (uint256) { return _price; } function getTeam() public view returns (address) { return _team; } function pause(bool val) public onlyOwner { _paused = val; } function withdrawAll() public payable onlyOwner { require(payable(_team).send(address(this).balance), "NoEth"); } function presale(bool val) public onlyOwner { _presale = val; } function verify(bytes32[] memory proof, bytes32 root) internal view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); return MerkleProof.verify(proof, root, leaf); } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } } // 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 "../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 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; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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 "../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 "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102515760003560e01c806370a082311161013957806398d5fdca116100b6578063ca8001441161007a578063ca80014414610693578063cfc86f7b146106b3578063e2a71ef8146106c8578063e985e9c5146106e2578063edc2fcfb1461072b578063f2fde38b1461074b57600080fd5b806398d5fdca1461060857806399a71de81461061d578063a22cb46514610633578063b88d4fde14610653578063c87b56dd1461067357600080fd5b806388a4aa08116100fd57806388a4aa081461056f5780638bce6edd146105825780638da5cb5b146105b557806391b7f5ed146105d357806395d89b41146105f357600080fd5b806370a08231146104fc578063715018a61461051c578063743511ed14610531578063818a484e14610547578063853828b61461056757600080fd5b806323b872dd116101d25780634f6ccce7116101965780634f6ccce71461044657806351f9b3611461046657806355f804b3146104865780635a23dd99146104a65780636352211e146104c65780636aaa571d146104e657600080fd5b806323b872dd146103a35780632f745c59146103c35780632fc37ab2146103e357806342842e0e146103f9578063438b63001461041957600080fd5b8063081812fc11610219578063081812fc14610306578063095ea7b31461033e57806316c61ccc1461035e57806318160ddd14610378578063235b6ea11461038d57600080fd5b806301ffc9a7146102565780630232723d1461028b57806302329a29146102af578063035d9f2a146102d157806306fdde03146102e4575b600080fd5b34801561026257600080fd5b5061027661027136600461261e565b61076b565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a1600f5481565b604051908152602001610282565b3480156102bb57600080fd5b506102cf6102ca3660046125e1565b610796565b005b6102cf6102df3660046126a1565b6107dc565b3480156102f057600080fd5b506102f9610996565b60405161028291906127c7565b34801561031257600080fd5b506103266103213660046126a1565b610a28565b6040516001600160a01b039091168152602001610282565b34801561034a57600080fd5b506102cf6103593660046125b7565b610abd565b34801561036a57600080fd5b506011546102769060ff1681565b34801561038457600080fd5b506008546102a1565b34801561039957600080fd5b506102a160105481565b3480156103af57600080fd5b506102cf6103be366004612487565b610bce565b3480156103cf57600080fd5b506102a16103de3660046125b7565b610bff565b3480156103ef57600080fd5b506102a160125481565b34801561040557600080fd5b506102cf610414366004612487565b610c95565b34801561042557600080fd5b50610439610434366004612439565b610cb0565b6040516102829190612783565b34801561045257600080fd5b506102a16104613660046126a1565b610d52565b34801561047257600080fd5b506102cf6104813660046126a1565b610de5565b34801561049257600080fd5b506102cf6104a1366004612658565b610e14565b3480156104b257600080fd5b506102766104c136600461253f565b610e55565b3480156104d257600080fd5b506103266104e13660046126a1565b610ea6565b3480156104f257600080fd5b506102a1600d5481565b34801561050857600080fd5b506102a1610517366004612439565b610f1d565b34801561052857600080fd5b506102cf610fa4565b34801561053d57600080fd5b506102a1600e5481565b34801561055357600080fd5b506102cf6105623660046125fc565b610fda565b6102cf61104a565b6102cf61057d3660046126ba565b6110ec565b34801561058e57600080fd5b507f0000000000000000000000001483a5ed4df06c6bbe85133eeb57289e0b2c6c98610326565b3480156105c157600080fd5b50600b546001600160a01b0316610326565b3480156105df57600080fd5b506102cf6105ee3660046126a1565b611312565b3480156105ff57600080fd5b506102f9611341565b34801561061457600080fd5b506010546102a1565b34801561062957600080fd5b506102a160145481565b34801561063f57600080fd5b506102cf61064e36600461258d565b611350565b34801561065f57600080fd5b506102cf61066e3660046124c3565b611415565b34801561067f57600080fd5b506102f961068e3660046126a1565b61144d565b34801561069f57600080fd5b506102cf6106ae3660046125b7565b611528565b3480156106bf57600080fd5b506102f9611657565b3480156106d457600080fd5b506013546102769060ff1681565b3480156106ee57600080fd5b506102766106fd366004612454565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561073757600080fd5b506102cf6107463660046125e1565b6116e5565b34801561075757600080fd5b506102cf610766366004612439565b611722565b60006001600160e01b0319821663780e9d6360e01b14806107905750610790826117c3565b92915050565b600b546001600160a01b031633146107c95760405162461bcd60e51b81526004016107c09061282c565b60405180910390fd5b6011805460ff1916911515919091179055565b60115460ff16156108185760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b60448201526064016107c0565b60135460ff16156108555760405162461bcd60e51b815260206004820152600760248201526670726573616c6560c81b60448201526064016107c0565b600e5461086133610f1d565b61086b90836128e3565b111580156108795750600081115b6108b55760405162461bcd60e51b815260206004820152600d60248201526c0850da185b5c1cd05b5bdd5b9d609a1b60448201526064016107c0565b60006108c060085490565b9050600d54600f546108d2919061292e565b6108dc83836128e3565b11156109175760405162461bcd60e51b815260206004820152600a6024820152693e4d6178537570706c7960b01b60448201526064016107c0565b81601054610925919061290f565b3410156109615760405162461bcd60e51b815260206004820152600a60248201526908515d1a105b5bdd5b9d60b21b60448201526064016107c0565b60005b828110156109915761097f3361097a83856128e3565b611813565b80610989816129ac565b915050610964565b505050565b6060600080546109a590612971565b80601f01602080910402602001604051908101604052809291908181526020018280546109d190612971565b8015610a1e5780601f106109f357610100808354040283529160200191610a1e565b820191906000526020600020905b815481529060010190602001808311610a0157829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610aa15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107c0565b506000908152600460205260409020546001600160a01b031690565b6000610ac882610ea6565b9050806001600160a01b0316836001600160a01b03161415610b365760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107c0565b336001600160a01b0382161480610b525750610b5281336106fd565b610bc45760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107c0565b610991838361182d565b610bd8338261189b565b610bf45760405162461bcd60e51b81526004016107c090612861565b61099183838361198e565b6000610c0a83610f1d565b8210610c6c5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016107c0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61099183838360405180602001604052806000815250611415565b60606000610cbd83610f1d565b905060008167ffffffffffffffff811115610cda57610cda612a33565b604051908082528060200260200182016040528015610d03578160200160208202803683370190505b50905060005b82811015610d4a57610d1b8582610bff565b828281518110610d2d57610d2d612a1d565b602090810291909101015280610d42816129ac565b915050610d09565b509392505050565b6000610d5d60085490565b8210610dc05760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016107c0565b60088281548110610dd357610dd3612a1d565b90600052602060002001549050919050565b600b546001600160a01b03163314610e0f5760405162461bcd60e51b81526004016107c09061282c565b600e55565b600b546001600160a01b03163314610e3e5760405162461bcd60e51b81526004016107c09061282c565b8051610e5190600c906020840190612296565b5050565b6040516bffffffffffffffffffffffff19606084901b1660208201526000908190603401604051602081830303815290604052805190602001209050610e9e8360125483611b39565b949350505050565b6000818152600260205260408120546001600160a01b0316806107905760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107c0565b60006001600160a01b038216610f885760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107c0565b506001600160a01b031660009081526003602052604090205490565b600b546001600160a01b03163314610fce5760405162461bcd60e51b81526004016107c09061282c565b610fd86000611be8565b565b600b546001600160a01b031633146110045760405162461bcd60e51b81526004016107c09061282c565b8161103f5760405162461bcd60e51b815260206004820152600b60248201526a085b595c9adb19549bdbdd60aa1b60448201526064016107c0565b601291909155601455565b600b546001600160a01b031633146110745760405162461bcd60e51b81526004016107c09061282c565b6040516001600160a01b037f0000000000000000000000001483a5ed4df06c6bbe85133eeb57289e0b2c6c9816904780156108fc02916000818181858888f19350505050610fd85760405162461bcd60e51b815260206004820152600560248201526409cde8ae8d60db1b60448201526064016107c0565b60115460ff16156111285760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b60448201526064016107c0565b60135460ff166111655760405162461bcd60e51b81526020600482015260086024820152672170726573616c6560c01b60448201526064016107c0565b61117181601254611c3a565b6111aa5760405162461bcd60e51b815260206004820152600a602482015269085dda1a5d195b1a5cdd60b21b60448201526064016107c0565b600e546111b633610f1d565b6111c090846128e3565b111580156111ce5750600082115b61120a5760405162461bcd60e51b815260206004820152600d60248201526c0850da185b5c1cd05b5bdd5b9d609a1b60448201526064016107c0565b600061121560085490565b905060145483111580156112415750600d54600f54611234919061292e565b61123e84836128e3565b11155b6112805760405162461bcd60e51b815260206004820152601060248201526f3e617661696c61626c65537570706c7960801b60448201526064016107c0565b8260105461128e919061290f565b3410156112ca5760405162461bcd60e51b815260206004820152600a60248201526908515d1a105b5bdd5b9d60b21b60448201526064016107c0565b60005b838110156112f5576112e33361097a83856128e3565b806112ed816129ac565b9150506112cd565b508260146000828254611308919061292e565b9091555050505050565b600b546001600160a01b0316331461133c5760405162461bcd60e51b81526004016107c09061282c565b601055565b6060600180546109a590612971565b6001600160a01b0382163314156113a95760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107c0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61141f338361189b565b61143b5760405162461bcd60e51b81526004016107c090612861565b61144784848484611c80565b50505050565b6000818152600260205260409020546060906001600160a01b03166114cc5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107c0565b60006114d6611cb3565b905060008151116114f65760405180602001604052806000815250611521565b8061150084611cc2565b604051602001611511929190612717565b6040516020818303038152906040525b9392505050565b600b546001600160a01b031633146115525760405162461bcd60e51b81526004016107c09061282c565b600d548111156115905760405162461bcd60e51b81526020600482015260096024820152680f9c995cd95c9d995960ba1b60448201526064016107c0565b600081116115cd5760405162461bcd60e51b815260206004820152600a60248201526905f616d6f756e743d3d360b41b60448201526064016107c0565b6001600160a01b03821661160c5760405162461bcd60e51b815260206004820152600660248201526505f746f3d3d360d41b60448201526064016107c0565b600061161760085490565b905060005b82811015611644576116328461097a83856128e3565b8061163c816129ac565b91505061161c565b5081600d6000828254611308919061292e565b600c805461166490612971565b80601f016020809104026020016040519081016040528092919081815260200182805461169090612971565b80156116dd5780601f106116b2576101008083540402835291602001916116dd565b820191906000526020600020905b8154815290600101906020018083116116c057829003601f168201915b505050505081565b600b546001600160a01b0316331461170f5760405162461bcd60e51b81526004016107c09061282c565b6013805460ff1916911515919091179055565b600b546001600160a01b0316331461174c5760405162461bcd60e51b81526004016107c09061282c565b6001600160a01b0381166117b15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107c0565b6117ba81611be8565b50565b3b151590565b60006001600160e01b031982166380ac58cd60e01b14806117f457506001600160e01b03198216635b5e139f60e01b145b8061079057506301ffc9a760e01b6001600160e01b0319831614610790565b610e51828260405180602001604052806000815250611dc0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061186282610ea6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166119145760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107c0565b600061191f83610ea6565b9050806001600160a01b0316846001600160a01b0316148061195a5750836001600160a01b031661194f84610a28565b6001600160a01b0316145b80610e9e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16610e9e565b826001600160a01b03166119a182610ea6565b6001600160a01b031614611a095760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107c0565b6001600160a01b038216611a6b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107c0565b611a76838383611df3565b611a8160008261182d565b6001600160a01b0383166000908152600360205260408120805460019290611aaa90849061292e565b90915550506001600160a01b0382166000908152600360205260408120805460019290611ad89084906128e3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600081815b8551811015611bdd576000868281518110611b5b57611b5b612a1d565b60200260200101519050808311611b9d576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611bca565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611bd5816129ac565b915050611b3e565b509092149392505050565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516bffffffffffffffffffffffff193360601b1660208201526000908190603401604051602081830303815290604052805190602001209050610e9e848483611b39565b611c8b84848461198e565b611c9784848484611eab565b6114475760405162461bcd60e51b81526004016107c0906127da565b6060600c80546109a590612971565b606081611ce65750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611d105780611cfa816129ac565b9150611d099050600a836128fb565b9150611cea565b60008167ffffffffffffffff811115611d2b57611d2b612a33565b6040519080825280601f01601f191660200182016040528015611d55576020820181803683370190505b5090505b8415610e9e57611d6a60018361292e565b9150611d77600a866129c7565b611d829060306128e3565b60f81b818381518110611d9757611d97612a1d565b60200101906001600160f81b031916908160001a905350611db9600a866128fb565b9450611d59565b611dca8383611fb8565b611dd76000848484611eab565b6109915760405162461bcd60e51b81526004016107c0906127da565b6001600160a01b038316611e4e57611e4981600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611e71565b816001600160a01b0316836001600160a01b031614611e7157611e718382612106565b6001600160a01b038216611e8857610991816121a3565b826001600160a01b0316826001600160a01b031614610991576109918282612252565b60006001600160a01b0384163b15611fad57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611eef903390899088908890600401612746565b602060405180830381600087803b158015611f0957600080fd5b505af1925050508015611f39575060408051601f3d908101601f19168201909252611f369181019061263b565b60015b611f93573d808015611f67576040519150601f19603f3d011682016040523d82523d6000602084013e611f6c565b606091505b508051611f8b5760405162461bcd60e51b81526004016107c0906127da565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610e9e565b506001949350505050565b6001600160a01b03821661200e5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107c0565b6000818152600260205260409020546001600160a01b0316156120735760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107c0565b61207f60008383611df3565b6001600160a01b03821660009081526003602052604081208054600192906120a89084906128e3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000600161211384610f1d565b61211d919061292e565b600083815260076020526040902054909150808214612170576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906121b59060019061292e565b600083815260096020526040812054600880549394509092849081106121dd576121dd612a1d565b9060005260206000200154905080600883815481106121fe576121fe612a1d565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061223657612236612a07565b6001900381819060005260206000200160009055905550505050565b600061225d83610f1d565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8280546122a290612971565b90600052602060002090601f0160209004810192826122c4576000855561230a565b82601f106122dd57805160ff191683800117855561230a565b8280016001018555821561230a579182015b8281111561230a5782518255916020019190600101906122ef565b5061231692915061231a565b5090565b5b80821115612316576000815560010161231b565b600067ffffffffffffffff83111561234957612349612a33565b61235c601f8401601f19166020016128b2565b905082815283838301111561237057600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461239e57600080fd5b919050565b600082601f8301126123b457600080fd5b8135602067ffffffffffffffff8211156123d0576123d0612a33565b8160051b6123df8282016128b2565b8381528281019086840183880185018910156123fa57600080fd5b600093505b8584101561241d5780358352600193909301929184019184016123ff565b50979650505050505050565b8035801515811461239e57600080fd5b60006020828403121561244b57600080fd5b61152182612387565b6000806040838503121561246757600080fd5b61247083612387565b915061247e60208401612387565b90509250929050565b60008060006060848603121561249c57600080fd5b6124a584612387565b92506124b360208501612387565b9150604084013590509250925092565b600080600080608085870312156124d957600080fd5b6124e285612387565b93506124f060208601612387565b925060408501359150606085013567ffffffffffffffff81111561251357600080fd5b8501601f8101871361252457600080fd5b6125338782356020840161232f565b91505092959194509250565b6000806040838503121561255257600080fd5b61255b83612387565b9150602083013567ffffffffffffffff81111561257757600080fd5b612583858286016123a3565b9150509250929050565b600080604083850312156125a057600080fd5b6125a983612387565b915061247e60208401612429565b600080604083850312156125ca57600080fd5b6125d383612387565b946020939093013593505050565b6000602082840312156125f357600080fd5b61152182612429565b6000806040838503121561260f57600080fd5b50508035926020909101359150565b60006020828403121561263057600080fd5b813561152181612a49565b60006020828403121561264d57600080fd5b815161152181612a49565b60006020828403121561266a57600080fd5b813567ffffffffffffffff81111561268157600080fd5b8201601f8101841361269257600080fd5b610e9e8482356020840161232f565b6000602082840312156126b357600080fd5b5035919050565b600080604083850312156126cd57600080fd5b82359150602083013567ffffffffffffffff81111561257757600080fd5b60008151808452612703816020860160208601612945565b601f01601f19169290920160200192915050565b60008351612729818460208801612945565b83519083019061273d818360208801612945565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612779908301846126eb565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156127bb5783518352928401929184019160010161279f565b50909695505050505050565b60208152600061152160208301846126eb565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156128db576128db612a33565b604052919050565b600082198211156128f6576128f66129db565b500190565b60008261290a5761290a6129f1565b500490565b6000816000190483118215151615612929576129296129db565b500290565b600082821015612940576129406129db565b500390565b60005b83811015612960578181015183820152602001612948565b838111156114475750506000910152565b600181811c9082168061298557607f821691505b602082108114156129a657634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156129c0576129c06129db565b5060010190565b6000826129d6576129d66129f1565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146117ba57600080fdfea264697066735822122089e97c47619ec648a48996a8e7db15887c409a20a722d25ceb8c809c90faf06664736f6c63430008060033
{"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, 2581, 2050, 2683, 21926, 2098, 19481, 19481, 2487, 27717, 22025, 2475, 2063, 2575, 9818, 10322, 25746, 23499, 11329, 2620, 2094, 2683, 22394, 16086, 2692, 27531, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1020, 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, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3036, 1013, 2128, 4765, 5521, 5666, 18405, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 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,964
0x97a97908748285a0d0856d0a61909bad572b2fd4
/** *Submitted for verification at Etherscan.io on 2020-09-25 */ // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol 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-ethereum-package/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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts-ethereum-package/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"); } } // File: @openzeppelin/contracts-ethereum-package/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 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"); } } } // File: @openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol 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)); } } // File: @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol 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; } // File: @openzeppelin/contracts-ethereum-package/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. */ 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; } // File: @openzeppelin/contracts-ethereum-package/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 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; } // File: contracts/INBUNIERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface INBUNIERC20 { /** * @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); event Log(string log); } // File: @nomiclabs/buidler/console.sol pragma solidity >= 0.4.22 <0.8.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 logByte(byte p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(byte)", 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)); } } // File: contracts/CoreVault.sol pragma solidity 0.6.12; // Core Vault distributes fees equally amongst staked pools // Have fun reading it. Hopefully it's bug-free. God bless. contract CoreVault is OwnableUpgradeSafe { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of COREs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accCorePerShare) - user.rewardDebt // // Whenever a user deposits or withdraws tokens to a pool. Here's what happens: // 1. The pool's `accCorePerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 token; // Address of token contract. uint256 allocPoint; // How many allocation points assigned to this pool. COREs to distribute per block. uint256 accCorePerShare; // Accumulated COREs per share, times 1e12. See below. bool withdrawable; // Is this pool withdrawable? mapping(address => mapping(address => uint256)) allowance; } // The CORE TOKEN! INBUNIERC20 public core; // Dev address. address public devaddr; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint; //// pending rewards awaiting anyone to massUpdate uint256 public pendingRewards; uint256 public contractStartBlock; uint256 public epochCalculationStartBlock; uint256 public cumulativeRewardsSinceStart; uint256 public rewardsInThisEpoch; uint public epoch; // Returns fees generated since start of this contract function averageFeesPerBlockSinceStart() external view returns (uint averagePerBlock) { averagePerBlock = cumulativeRewardsSinceStart.add(rewardsInThisEpoch).div(block.number.sub(contractStartBlock)); } // Returns averge fees in this epoch function averageFeesPerBlockEpoch() external view returns (uint256 averagePerBlock) { averagePerBlock = rewardsInThisEpoch.div(block.number.sub(epochCalculationStartBlock)); } // For easy graphing historical epoch rewards mapping(uint => uint256) public epochRewards; //Starts a new calculation epoch // Because averge since start will not be accurate function startNewEpoch() public { require(epochCalculationStartBlock + 50000 < block.number, "New epoch not ready yet"); // About a week epochRewards[epoch] = rewardsInThisEpoch; cumulativeRewardsSinceStart = cumulativeRewardsSinceStart.add(rewardsInThisEpoch); rewardsInThisEpoch = 0; epochCalculationStartBlock = block.number; ++epoch; } event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw( address indexed user, uint256 indexed pid, uint256 amount ); event Approval(address indexed owner, address indexed spender, uint256 _pid, uint256 value); function initialize( INBUNIERC20 _core, address _devaddr, address superAdmin ) public initializer { OwnableUpgradeSafe.__Ownable_init(); DEV_FEE = 724; core = _core; devaddr = _devaddr; contractStartBlock = block.number; _superAdmin = superAdmin; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new token pool. Can only be called by the owner. // Note contract owner is meant to be a governance contract allowing CORE governance consensus function add( uint256 _allocPoint, IERC20 _token, bool _withUpdate, bool _withdrawable ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { require(poolInfo[pid].token != _token,"Error pool already added"); } totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push( PoolInfo({ token: _token, allocPoint: _allocPoint, accCorePerShare: 0, withdrawable : _withdrawable }) ); } // Update the given pool's COREs allocation point. Can only be called by the owner. // Note contract owner is meant to be a governance contract allowing CORE governance consensus function set( uint256 _pid, uint256 _allocPoint, bool _withUpdate ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add( _allocPoint ); poolInfo[_pid].allocPoint = _allocPoint; } // Update the given pool's ability to withdraw tokens // Note contract owner is meant to be a governance contract allowing CORE governance consensus function setPoolWithdrawable( uint256 _pid, bool _withdrawable ) public onlyOwner { poolInfo[_pid].withdrawable = _withdrawable; } // Sets the dev fee for this contract // defaults at 7.24% // Note contract owner is meant to be a governance contract allowing CORE governance consensus uint16 DEV_FEE; function setDevFee(uint16 _DEV_FEE) public onlyOwner { require(_DEV_FEE <= 1000, 'Dev fee clamped at 10%'); DEV_FEE = _DEV_FEE; } uint256 pending_DEV_rewards; // View function to see pending COREs on frontend. function pendingCore(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCorePerShare = pool.accCorePerShare; return user.amount.mul(accCorePerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { console.log("Mass Updating Pools"); uint256 length = poolInfo.length; uint allRewards; for (uint256 pid = 0; pid < length; ++pid) { allRewards = allRewards.add(updatePool(pid)); } pendingRewards = pendingRewards.sub(allRewards); } // ---- // Function that adds pending rewards, called by the CORE token. // ---- uint256 private coreBalance; function addPendingRewards(uint256 _) public { uint256 newRewards = core.balanceOf(address(this)).sub(coreBalance); if(newRewards > 0) { coreBalance = core.balanceOf(address(this)); // If there is no change the balance didn't change pendingRewards = pendingRewards.add(newRewards); rewardsInThisEpoch = rewardsInThisEpoch.add(newRewards); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) internal returns (uint256 coreRewardWhole) { PoolInfo storage pool = poolInfo[_pid]; uint256 tokenSupply = pool.token.balanceOf(address(this)); if (tokenSupply == 0) { // avoids division by 0 errors return 0; } coreRewardWhole = pendingRewards // Multiplies pending rewards by allocation point of this pool and then total allocation .mul(pool.allocPoint) // getting the percent of total pending rewards this pool should get .div(totalAllocPoint); // we can do this because pools are only mass updated uint256 coreRewardFee = coreRewardWhole.mul(DEV_FEE).div(10000); uint256 coreRewardToDistribute = coreRewardWhole.sub(coreRewardFee); pending_DEV_rewards = pending_DEV_rewards.add(coreRewardFee); pool.accCorePerShare = pool.accCorePerShare.add( coreRewardToDistribute.mul(1e12).div(tokenSupply) ); } // Deposit tokens to CoreVault for CORE allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; massUpdatePools(); // Transfer pending tokens // to user updateAndPayOutPending(_pid, pool, user, msg.sender); //Transfer in the amounts from user // save gas if(_amount > 0) { pool.token.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.accCorePerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Test coverage // [x] Does user get the deposited amounts? // [x] Does user that its deposited for update correcty? // [x] Does the depositor get their tokens decreased function depositFor(address depositFor, uint256 _pid, uint256 _amount) public { // requires no allowances PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][depositFor]; massUpdatePools(); // Transfer pending tokens // to user updateAndPayOutPending(_pid, pool, user, depositFor); // Update the balances of person that amount is being deposited for if(_amount > 0) { pool.token.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); // This is depositedFor address } user.rewardDebt = user.amount.mul(pool.accCorePerShare).div(1e12); /// This is deposited for address emit Deposit(depositFor, _pid, _amount); } // Test coverage // [x] Does allowance update correctly? function setAllowanceForPoolToken(address spender, uint256 _pid, uint256 value) public { PoolInfo storage pool = poolInfo[_pid]; pool.allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, _pid, value); } // Test coverage // [x] Does allowance decrease? // [x] Do oyu need allowance // [x] Withdraws to correct address function withdrawFrom(address owner, uint256 _pid, uint256 _amount) public{ PoolInfo storage pool = poolInfo[_pid]; require(pool.allowance[owner][msg.sender] >= _amount, "withdraw: insufficient allowance"); pool.allowance[owner][msg.sender] = pool.allowance[owner][msg.sender].sub(_amount); _withdraw(_pid, _amount, owner, msg.sender); } // Withdraw tokens from CoreVault. function withdraw(uint256 _pid, uint256 _amount) public { _withdraw(_pid, _amount, msg.sender, msg.sender); } // Low level withdraw function function _withdraw(uint256 _pid, uint256 _amount, address from, address to) internal { PoolInfo storage pool = poolInfo[_pid]; require(pool.withdrawable, "Withdrawing from this pool is disabled"); UserInfo storage user = userInfo[_pid][from]; require(user.amount >= _amount, "withdraw: not good"); massUpdatePools(); updateAndPayOutPending(_pid, pool, user, from); // Update balances of from this is not withdrawal but claiming CORE farmed if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.token.safeTransfer(address(to), _amount); } user.rewardDebt = user.amount.mul(pool.accCorePerShare).div(1e12); emit Withdraw(to, _pid, _amount); } function updateAndPayOutPending(uint256 _pid, PoolInfo storage pool, UserInfo storage user, address from) internal { if(user.amount == 0) return; uint256 pending = user .amount .mul(pool.accCorePerShare) .div(1e12) .sub(user.rewardDebt); if(pending > 0) { safeCoreTransfer(from, pending); } } // function that lets owner/governance contract // approve allowance for any token inside this contract // This means all future UNI like airdrops are covered // And at the same time allows us to give allowance to strategy contracts. // Upcoming cYFI etc vaults strategy contracts will se this function to manage and farm yield on value locked function setStrategyContractOrDistributionContractAllowance(address tokenAddress, uint256 _amount, address contractAddress) public onlySuperAdmin { require(isContract(contractAddress), "Recipent is not a smart contract, BAD"); require(block.number > contractStartBlock.add(95_000), "Governance setup grace period not over"); // about 2weeks IERC20(tokenAddress).approve(contractAddress, _amount); } function isContract(address addr) public returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } // Withdraw without caring about rewards. EMERGENCY ONLY. // !Caution this will remove all your pending rewards! function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; require(pool.withdrawable, "Withdrawing from this pool is disabled"); UserInfo storage user = userInfo[_pid][msg.sender]; pool.token.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; // No mass update dont update pending rewards } // Safe core transfer function, just in case if rounding error causes pool to not have enough COREs. function safeCoreTransfer(address _to, uint256 _amount) internal { if(_amount == 0) return; uint256 coreBal = core.balanceOf(address(this)); if (_amount > coreBal) { console.log("transfering out for to person:", _amount); console.log("Balance of this address is :", coreBal); core.transfer(_to, coreBal); coreBalance = core.balanceOf(address(this)); } else { core.transfer(_to, _amount); coreBalance = core.balanceOf(address(this)); } if(pending_DEV_rewards > 0) { uint256 devSend = pending_DEV_rewards; // Avoid recursive loop pending_DEV_rewards = 0; safeCoreTransfer(devaddr, devSend); } } // Update dev address by the previous dev. // Note onlyOwner functions are meant for the governance contract // allowing CORE governance token holders to do this functions. function setDevFeeReciever(address _devaddr) public onlyOwner { devaddr = _devaddr; } address private _superAdmin; event SuperAdminTransfered(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the current super admin */ function superAdmin() public view returns (address) { return _superAdmin; } /** * @dev Throws if called by any account other than the superAdmin */ modifier onlySuperAdmin() { require(_superAdmin == _msgSender(), "Super admin : caller is not super admin."); _; } // Assisns super admint to address 0, making it unreachable forever function burnSuperAdmin() public virtual onlySuperAdmin { emit SuperAdminTransfered(_superAdmin, address(0)); _superAdmin = address(0); } // Super admin can transfer its powers to another address function newSuperAdmin(address newOwner) public virtual onlySuperAdmin { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit SuperAdminTransfered(_superAdmin, newOwner); _superAdmin = newOwner; } }
0x608060405234801561001057600080fd5b506004361061023d5760003560e01c806364482f791161013b578063c4014588116100b8578063e18cb4fe1161007c578063e18cb4fe146109e4578063e2bbb15814610a16578063eded3fda14610a4e578063f2f4eb2614610a6c578063f2fde38b14610aa05761023d565b8063c401458814610866578063c507aeaa146108d4578063c8ffb8731461093a578063d49e77cd14610958578063dbe0901f1461098c5761023d565b806393f1a40b116100ff57806393f1a40b146106b55780639dbc2d901461071e578063a4f00c821461073c578063a676860a1461079e578063c0c53b8b146107e25761023d565b806364482f791461060b578063715018a61461064f5780638da5cb5b14610659578063900cf0cf1461068d578063934eaa50146106ab5761023d565b8063423d6fa0116101c95780635207cc0d1161018d5780635207cc0d1461055d5780635312ea8e146105975780635d577c18146105c5578063608c8d3a146105e3578063630b5ba1146106015761023d565b8063423d6fa01461043f578063441a3e701461046d57806349c5468d146104a55780634cf5fbf5146104c35780634dc47d341461051b5761023d565b806317caf6f11161021057806317caf6f11461034757806329575f6a146103655780632d6754e5146103995780633a0967cd146103dd5780633aab0a62146104355761023d565b806303dec00914610242578063081e3eda146102605780631526fe271461027e57806316279055146102ed575b600080fd5b61024a610ae4565b6040518082815260200191505060405180910390f35b610268610b14565b6040518082815260200191505060405180910390f35b6102aa6004803603602081101561029457600080fd5b8101908080359060200190929190505050610b21565b604051808573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001838152602001821515815260200194505050505060405180910390f35b61032f6004803603602081101561030357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b8b565b60405180821515815260200191505060405180910390f35b61034f610b9e565b6040518082815260200191505060405180910390f35b61036d610ba4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103db600480360360208110156103af57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bce565b005b610433600480360360608110156103f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610cdc565b005b61043d610f14565b005b61046b6004803603602081101561045557600080fd5b8101908080359060200190929190505050610fe9565b005b6104a36004803603604081101561048357600080fd5b8101908080359060200190929190803590602001909291905050506111d3565b005b6104ad6111e3565b6040518082815260200191505060405180910390f35b610519600480360360608110156104d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291905050506111e9565b005b6105476004803603602081101561053157600080fd5b810190808035906020019092919050505061137a565b6040518082815260200191505060405180910390f35b6105956004803603604081101561057357600080fd5b8101908080359060200190929190803515159060200190929190505050611392565b005b6105c3600480360360208110156105ad57600080fd5b8101908080359060200190929190505050611496565b005b6105cd61162f565b6040518082815260200191505060405180910390f35b6105eb611635565b6040518082815260200191505060405180910390f35b61060961163b565b005b61064d6004803603606081101561062157600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506116db565b005b610657611827565b005b6106616119b2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106956119dc565b6040518082815260200191505060405180910390f35b6106b36119e2565b005b610701600480360360408110156106cb57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b50565b604051808381526020018281526020019250505060405180910390f35b610726611b81565b6040518082815260200191505060405180910390f35b6107886004803603604081101561075257600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bc5565b6040518082815260200191505060405180910390f35b6107e0600480360360208110156107b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c91565b005b610864600480360360608110156107f857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e84565b005b6108d26004803603606081101561087c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612076565b005b610938600480360360808110156108ea57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291908035151590602001909291905050506122a2565b005b610942612580565b6040518082815260200191505060405180910390f35b610960612586565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109e2600480360360608110156109a257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291905050506125ac565b005b610a14600480360360208110156109fa57600080fd5b81019080803561ffff1690602001909291905050506126c1565b005b610a4c60048036036040811015610a2c57600080fd5b810190808035906020019092919080359060200190929190505050612827565b005b610a566129b7565b6040518082815260200191505060405180910390f35b610a746129bd565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610ae260048036036020811015610ab657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506129e3565b005b6000610b0f610afe609e5443612bf390919063ffffffff16565b60a054612c3d90919063ffffffff16565b905090565b6000609980549050905090565b60998181548110610b2e57fe5b90600052602060002090600502016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030160009054906101000a900460ff16905084565b600080823b905060008111915050919050565b609b5481565b600060a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610bd6612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c98576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80609860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600060998381548110610ceb57fe5b90600052602060002090600502019050818160040160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610def576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f77697468647261773a20696e73756666696369656e7420616c6c6f77616e636581525060200191505060405180910390fd5b610e80828260040160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612bf390919063ffffffff16565b8160040160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f0e83838633612c8f565b50505050565b4361c350609e540110610f8f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f4e65772065706f6368206e6f742072656164792079657400000000000000000081525060200191505060405180910390fd5b60a05460a2600060a154815260200190815260200160002081905550610fc260a054609f54612f0090919063ffffffff16565b609f81905550600060a08190555043609e8190555060a16000815460010191905081905550565b60006110c360a554609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561107a57600080fd5b505afa15801561108e573d6000803e3d6000fd5b505050506040513d60208110156110a457600080fd5b8101908080519060200190929190505050612bf390919063ffffffff16565b905060008111156111cf57609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561115757600080fd5b505afa15801561116b573d6000803e3d6000fd5b505050506040513d602081101561118157600080fd5b810190808051906020019092919050505060a5819055506111ad81609c54612f0090919063ffffffff16565b609c819055506111c88160a054612f0090919063ffffffff16565b60a0819055505b5050565b6111df82823333612c8f565b5050565b609d5481565b6000609983815481106111f857fe5b906000526020600020906005020190506000609a600085815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061126461163b565b61127084838388612f88565b60008311156112ea576112ca3330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613002909392919063ffffffff16565b6112e1838260000154612f0090919063ffffffff16565b81600001819055505b61131c64e8d4a5100061130e846002015484600001546130c390919063ffffffff16565b612c3d90919063ffffffff16565b8160010181905550838573ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15856040518082815260200191505060405180910390a35050505050565b60a26020528060005260406000206000915090505481565b61139a612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461145c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b806099838154811061146a57fe5b906000526020600020906005020160030160006101000a81548160ff0219169083151502179055505050565b6000609982815481106114a557fe5b906000526020600020906005020190508060030160009054906101000a900460ff1661151c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806143946026913960400191505060405180910390fd5b6000609a600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506115c33382600001548460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166131499092919063ffffffff16565b823373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059583600001546040518082815260200191505060405180910390a36000816000018190555060008160010181905550505050565b609e5481565b60a05481565b6116796040518060400160405280601381526020017f4d617373205570646174696e6720506f6f6c73000000000000000000000000008152506131eb565b60006099805490509050600080600090505b828110156116bb576116ae61169f826132e9565b83612f0090919063ffffffff16565b915080600101905061168b565b506116d181609c54612bf390919063ffffffff16565b609c819055505050565b6116e3612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117a5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80156117b4576117b361163b565b5b6117f9826117eb609986815481106117c857fe5b906000526020600020906005020160010154609b54612bf390919063ffffffff16565b612f0090919063ffffffff16565b609b81905550816099848154811061180d57fe5b906000526020600020906005020160010181905550505050565b61182f612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146118f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60a15481565b6119ea612c87565b73ffffffffffffffffffffffffffffffffffffffff1660a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061431d6028913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff564c40f4f45e62a2c1e6c22e8bfb46501f0f71fa1c72e5358903fa1115a4b6460405160405180910390a3600060a660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b609a602052816000526040600020602052806000526040600020600091509150508060000154908060010154905082565b6000611bc0611b9b609d5443612bf390919063ffffffff16565b611bb260a054609f54612f0090919063ffffffff16565b612c3d90919063ffffffff16565b905090565b60008060998481548110611bd557fe5b906000526020600020906005020190506000609a600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600082600201549050611c868260010154611c7864e8d4a51000611c6a8587600001546130c390919063ffffffff16565b612c3d90919063ffffffff16565b612bf390919063ffffffff16565b935050505092915050565b611c99612c87565b73ffffffffffffffffffffffffffffffffffffffff1660a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d3e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061431d6028913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611dc4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806142d26026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff564c40f4f45e62a2c1e6c22e8bfb46501f0f71fa1c72e5358903fa1115a4b6460405160405180910390a38060a660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600060019054906101000a900460ff1680611ea35750611ea26134d9565b5b80611eb9575060008054906101000a900460ff16155b611f0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180614366602e913960400191505060405180910390fd5b60008060019054906101000a900460ff161590508015611f5e576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b611f666134f0565b6102d460a360006101000a81548161ffff021916908361ffff16021790555083609760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082609860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555043609d819055508160a660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080156120705760008060016101000a81548160ff0219169083151502179055505b50505050565b61207e612c87565b73ffffffffffffffffffffffffffffffffffffffff1660a660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612123576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061431d6028913960400191505060405180910390fd5b61212c81610b8b565b612181576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806142f86025913960400191505060405180910390fd5b61219962017318609d54612f0090919063ffffffff16565b43116121f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806143ba6026913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663095ea7b382846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561226157600080fd5b505af1158015612275573d6000803e3d6000fd5b505050506040513d602081101561228b57600080fd5b810190808051906020019092919050505050505050565b6122aa612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461236c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b811561237b5761237a61163b565b5b6000609980549050905060005b8181101561247b578473ffffffffffffffffffffffffffffffffffffffff16609982815481106123b457fe5b906000526020600020906005020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f4572726f7220706f6f6c20616c7265616479206164646564000000000000000081525060200191505060405180910390fd5b806001019050612388565b5061249185609b54612f0090919063ffffffff16565b609b81905550609960405180608001604052808673ffffffffffffffffffffffffffffffffffffffff16815260200187815260200160008152602001841515815250908060018154018082558091505060019003906000526020600020906005020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030160006101000a81548160ff02191690831515021790555050505050505050565b609f5481565b609860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000609983815481106125bb57fe5b90600052602060002090600502019050818160040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fb3fd5071835887567a0671151121894ddccc2842f1d10bedad13e0d17cace9a78585604051808381526020018281526020019250505060405180910390a350505050565b6126c9612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461278b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6103e88161ffff161115612807576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f4465762066656520636c616d706564206174203130250000000000000000000081525060200191505060405180910390fd5b8060a360006101000a81548161ffff021916908361ffff16021790555050565b60006099838154811061283657fe5b906000526020600020906005020190506000609a600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506128a261163b565b6128ae84838333612f88565b6000831115612928576129083330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613002909392919063ffffffff16565b61291f838260000154612f0090919063ffffffff16565b81600001819055505b61295a64e8d4a5100061294c846002015484600001546130c390919063ffffffff16565b612c3d90919063ffffffff16565b8160010181905550833373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15856040518082815260200191505060405180910390a350505050565b609c5481565b609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6129eb612c87565b73ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612aad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612b33576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806142d26026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000612c3583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506135fe565b905092915050565b6000612c7f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506136be565b905092915050565b600033905090565b600060998581548110612c9e57fe5b906000526020600020906005020190508060030160009054906101000a900460ff16612d15576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806143946026913960400191505060405180910390fd5b6000609a600087815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508481600001541015612de3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f77697468647261773a206e6f7420676f6f64000000000000000000000000000081525060200191505060405180910390fd5b612deb61163b565b612df786838387612f88565b6000851115612e6f57612e17858260000154612bf390919063ffffffff16565b8160000181905550612e6e83868460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166131499092919063ffffffff16565b5b612ea164e8d4a51000612e93846002015484600001546130c390919063ffffffff16565b612c3d90919063ffffffff16565b8160010181905550858373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568876040518082815260200191505060405180910390a3505050505050565b600080828401905083811015612f7e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600082600001541415612f9a57612ffc565b6000612fe48360010154612fd664e8d4a51000612fc8886002015488600001546130c390919063ffffffff16565b612c3d90919063ffffffff16565b612bf390919063ffffffff16565b90506000811115612ffa57612ff98282613784565b5b505b50505050565b6130bd846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613c66565b50505050565b6000808314156130d65760009050613143565b60008284029050828482816130e757fe5b041461313e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806143456021913960400191505060405180910390fd5b809150505b92915050565b6131e68363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613c66565b505050565b6132e6816040516024018080602001828103825283818151815260200191508051906020019080838360005b83811015613232578082015181840152602081019050613217565b50505050905090810190601f16801561325f5780820380516001836020036101000a031916815260200191505b50925050506040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613eb1565b50565b600080609983815481106132f957fe5b9060005260206000209060050201905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561339657600080fd5b505afa1580156133aa573d6000803e3d6000fd5b505050506040513d60208110156133c057600080fd5b8101908080519060200190929190505050905060008114156133e7576000925050506134d4565b613414609b546134068460010154609c546130c390919063ffffffff16565b612c3d90919063ffffffff16565b9250600061345361271061344560a360009054906101000a900461ffff1661ffff16876130c390919063ffffffff16565b612c3d90919063ffffffff16565b9050600061346a8286612bf390919063ffffffff16565b90506134818260a454612f0090919063ffffffff16565b60a4819055506134c76134b4846134a664e8d4a51000856130c390919063ffffffff16565b612c3d90919063ffffffff16565b8560020154612f0090919063ffffffff16565b8460020181905550505050505b919050565b6000803090506000813b9050600081149250505090565b600060019054906101000a900460ff168061350f575061350e6134d9565b5b80613525575060008054906101000a900460ff16155b61357a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180614366602e913960400191505060405180910390fd5b60008060019054906101000a900460ff1615905080156135ca576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b6135d2613eda565b6135da613fd8565b80156135fb5760008060016101000a81548160ff0219169083151502179055505b50565b60008383111582906136ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613670578082015181840152602081019050613655565b50505050905090810190601f16801561369d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808311829061376a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561372f578082015181840152602081019050613714565b50505050905090810190601f16801561375c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161377657fe5b049050809150509392505050565b600081141561379257613c62565b6000609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561381d57600080fd5b505afa158015613831573d6000803e3d6000fd5b505050506040513d602081101561384757600080fd5b8101908080519060200190929190505050905080821115613a7e576138a16040518060400160405280601e81526020017f7472616e73666572696e67206f757420666f7220746f20706572736f6e3a00008152508361417f565b6138e06040518060400160405280601c81526020017f42616c616e6365206f6620746869732061646472657373206973203a000000008152508261417f565b609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561397357600080fd5b505af1158015613987573d6000803e3d6000fd5b505050506040513d602081101561399d57600080fd5b810190808051906020019092919050505050609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015613a3857600080fd5b505afa158015613a4c573d6000803e3d6000fd5b505050506040513d6020811015613a6257600080fd5b810190808051906020019092919050505060a581905550613c18565b609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015613b1157600080fd5b505af1158015613b25573d6000803e3d6000fd5b505050506040513d6020811015613b3b57600080fd5b810190808051906020019092919050505050609760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015613bd657600080fd5b505afa158015613bea573d6000803e3d6000fd5b505050506040513d6020811015613c0057600080fd5b810190808051906020019092919050505060a5819055505b600060a4541115613c6057600060a4549050600060a481905550613c5e609860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682613784565b505b505b5050565b613c858273ffffffffffffffffffffffffffffffffffffffff16614286565b613cf7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310613d465780518252602082019150602081019050602083039250613d23565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613da8576040519150601f19603f3d011682016040523d82523d6000602084013e613dad565b606091505b509150915081613e25576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115613eab57808060200190516020811015613e4457600080fd5b8101908080519060200190929190505050613eaa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806143e0602a913960400191505060405180910390fd5b5b50505050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b600060019054906101000a900460ff1680613ef95750613ef86134d9565b5b80613f0f575060008054906101000a900460ff16155b613f64576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180614366602e913960400191505060405180910390fd5b60008060019054906101000a900460ff161590508015613fb4576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b8015613fd55760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff1680613ff75750613ff66134d9565b5b8061400d575060008054906101000a900460ff16155b614062576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180614366602e913960400191505060405180910390fd5b60008060019054906101000a900460ff1615905080156140b2576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b60006140bc612c87565b905080606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350801561417c5760008060016101000a81548160ff0219169083151502179055505b50565b61428282826040516024018080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156141cd5780820151818401526020810190506141b2565b50505050905090810190601f1680156141fa5780820380516001836020036101000a031916815260200191505b5093505050506040516020818303038152906040527f9710a9d0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613eb1565b5050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91508082141580156142c857506000801b8214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735265636970656e74206973206e6f74206120736d61727420636f6e74726163742c2042414453757065722061646d696e203a2063616c6c6572206973206e6f742073757065722061646d696e2e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645769746864726177696e672066726f6d207468697320706f6f6c2069732064697361626c6564476f7665726e616e636520736574757020677261636520706572696f64206e6f74206f7665725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212204c4b344ee87387be8eccc2b26231c8e1d541b3d417ec37a27b496e89b375220464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"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': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2683, 2581, 21057, 2620, 2581, 18139, 22407, 2629, 2050, 2692, 2094, 2692, 27531, 2575, 2094, 2692, 2050, 2575, 16147, 2692, 2683, 9024, 28311, 2475, 2497, 2475, 2546, 2094, 2549, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 12609, 1011, 5641, 1011, 2423, 1008, 1013, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 28855, 14820, 1011, 7427, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 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, 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,965
0x97a99c819544ad0617f48379840941efbe1bfae1
pragma solidity ^0.4.19; contract SupportedContract { // Members can call any contract that exposes a `theCyberMessage` method. function theCyberMessage(string) public; } contract ERC20 { // We want to be able to recover & donate any tokens sent to the contract. function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract theCyber { // theCyber is a decentralized club. It does not support equity memberships, // payment of dues, or payouts to the members. Instead, it is meant to enable // dapps that allow members to communicate with one another or that provide // arbitrary incentives or special access to the club's members. To become a // member of theCyber, you must be added by an existing member. Furthermore, // existing memberships can be revoked if a given member becomes inactive for // too long. Total membership is capped and unique addresses are required. event NewMember(uint8 indexed memberId, bytes32 memberName, address indexed memberAddress); event NewMemberName(uint8 indexed memberId, bytes32 newMemberName); event NewMemberKey(uint8 indexed memberId, string newMemberKey); event MembershipTransferred(uint8 indexed memberId, address newMemberAddress); event MemberProclaimedInactive(uint8 indexed memberId, uint8 indexed proclaimingMemberId); event MemberHeartbeated(uint8 indexed memberId); event MembershipRevoked(uint8 indexed memberId, uint8 indexed revokingMemberId); event BroadcastMessage(uint8 indexed memberId, string message); event DirectMessage(uint8 indexed memberId, uint8 indexed toMemberId, string message); event Call(uint8 indexed memberId, address indexed contractAddress, string message); event FundsDonated(uint8 indexed memberId, uint256 value); event TokensDonated(uint8 indexed memberId, address tokenContractAddress, uint256 value); // There can only be 256 members (member number 0 to 255) in theCyber. uint16 private constant MAXMEMBERS_ = 256; // A membership that has been marked as inactive for 90 days may be revoked. uint64 private constant INACTIVITYTIMEOUT_ = 90 days; // Set the ethereum tip jar (ethereumfoundation.eth) as the donation address. address private constant DONATIONADDRESS_ = 0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359; // A member has a name, a public key, a date they joined, and a date they were // marked as inactive (which is equial to 0 if they are currently active). struct Member { bool member; bytes32 name; string pubkey; uint64 memberSince; uint64 inactiveSince; } // Set up a fixed array of members indexed by member id. Member[MAXMEMBERS_] internal members_; // Map addresses to booleans designating that they control the membership. mapping (address => bool) internal addressIsMember_; // Map addresses to member ids. mapping (address => uint8) internal addressToMember_; // Map member ids to addresses that own the membership. mapping (uint => address) internal memberToAddress_; // Most methods of the contract, like adding new members or revoking existing // inactive members, can only be called by a valid member. modifier membersOnly() { // Only allow transactions originating from a designated member address. require(addressIsMember_[msg.sender]); _; } // In the constructor function, set up the contract creator as the first // member so that other new members can be added. function theCyber() public { // Log the addition of the first member (contract creator). NewMember(0, "", msg.sender); // Set up the member: status, name, key, member since & inactive since. members_[0] = Member(true, bytes32(""), "", uint64(now), 0); // Set up the address associated with the member. memberToAddress_[0] = msg.sender; // Point the address to member's id. addressToMember_[msg.sender] = 0; // Grant members-only access to the new member. addressIsMember_[msg.sender] = true; } // Existing members can designate new users by specifying an unused member id // and address. The new member's initial member name should also be supplied. function newMember(uint8 _memberId, bytes32 _memberName, address _memberAddress) public membersOnly { // Members need a non-null address. require(_memberAddress != address(0)); // Existing members (that have not fallen inactive) cannot be replaced. require (!members_[_memberId].member); // One address cannot hold more than one membership. require (!addressIsMember_[_memberAddress]); // Log the addition of a new member: (member id, name, address). NewMember(_memberId, _memberName, _memberAddress); // Set up the member: status, name, `member since` & `inactive since`. members_[_memberId] = Member(true, _memberName, "", uint64(now), 0); // Set up the address associated with the member id. memberToAddress_[_memberId] = _memberAddress; // Point the address to the member id. addressToMember_[_memberAddress] = _memberId; // Grant members-only access to the new member. addressIsMember_[_memberAddress] = true; } // Members can set a name (encoded as a hex value) that will be associated // with their membership. function changeName(bytes32 _newMemberName) public membersOnly { // Log the member's name change: (member id, new name). NewMemberName(addressToMember_[msg.sender], _newMemberName); // Change the member's name. members_[addressToMember_[msg.sender]].name = _newMemberName; } // Members can set a public key that will be used for verifying signed // messages from the member or encrypting messages intended for the member. function changeKey(string _newMemberKey) public membersOnly { // Log the member's key change: (member id, new member key). NewMemberKey(addressToMember_[msg.sender], _newMemberKey); // Change the member's public key. members_[addressToMember_[msg.sender]].pubkey = _newMemberKey; } // Members can transfer their membership to a new address; when they do, the // fields on the membership are all reset. function transferMembership(address _newMemberAddress) public membersOnly { // Members need a non-null address. require(_newMemberAddress != address(0)); // Memberships cannot be transferred to existing members. require (!addressIsMember_[_newMemberAddress]); // Log transfer of membership: (member id, new address). MembershipTransferred(addressToMember_[msg.sender], _newMemberAddress); // Revoke members-only access for the old member. delete addressIsMember_[msg.sender]; // Reset fields on the membership. members_[addressToMember_[msg.sender]].memberSince = uint64(now); members_[addressToMember_[msg.sender]].inactiveSince = 0; members_[addressToMember_[msg.sender]].name = bytes32(""); members_[addressToMember_[msg.sender]].pubkey = ""; // Replace the address associated with the member id. memberToAddress_[addressToMember_[msg.sender]] = _newMemberAddress; // Point the new address to the member id and clean up the old pointer. addressToMember_[_newMemberAddress] = addressToMember_[msg.sender]; delete addressToMember_[msg.sender]; // Grant members-only access to the new member. addressIsMember_[_newMemberAddress] = true; } // As a mechanism to remove members that are no longer active due to lost keys // or a lack of engagement, other members may proclaim them as inactive. function proclaimInactive(uint8 _memberId) public membersOnly { // Members must exist and be currently active to proclaim inactivity. require(members_[_memberId].member); require(memberIsActive(_memberId)); // Members cannot proclaim themselves as inactive (safety measure). require(addressToMember_[msg.sender] != _memberId); // Log proclamation of inactivity: (inactive member id, member id, time). MemberProclaimedInactive(_memberId, addressToMember_[msg.sender]); // Set the `inactiveSince` field on the inactive member. members_[_memberId].inactiveSince = uint64(now); } // Members that have erroneously been marked as inactive may send a heartbeat // to prove that they are still active, voiding the `inactiveSince` property. function heartbeat() public membersOnly { // Log that the member has heartbeated and is still active. MemberHeartbeated(addressToMember_[msg.sender]); // Designate member as active by voiding their `inactiveSince` field. members_[addressToMember_[msg.sender]].inactiveSince = 0; } // If a member has been marked inactive for the duration of the inactivity // timeout, another member may revoke their membership and delete them. function revokeMembership(uint8 _memberId) public membersOnly { // Members must exist in order to be revoked. require(members_[_memberId].member); // Members must be designated as inactive. require(!memberIsActive(_memberId)); // Members cannot revoke themselves (safety measure). require(addressToMember_[msg.sender] != _memberId); // Members must be inactive for the duration of the inactivity timeout. require(now >= members_[_memberId].inactiveSince + INACTIVITYTIMEOUT_); // Log that the membership has been revoked. MembershipRevoked(_memberId, addressToMember_[msg.sender]); // Revoke members-only access for the member. delete addressIsMember_[memberToAddress_[_memberId]]; // Delete the pointer linking the address to the member id. delete addressToMember_[memberToAddress_[_memberId]]; // Delete the address associated with the member id. delete memberToAddress_[_memberId]; // Finally, delete the member. delete members_[_memberId]; } // While most messaging is intended to occur off-chain using supplied keys, // members can also broadcast a message as an on-chain event. function broadcastMessage(string _message) public membersOnly { // Log the message. BroadcastMessage(addressToMember_[msg.sender], _message); } // In addition, members can send direct messagees as an on-chain event. These // messages are intended to be encrypted using the recipient's public key. function directMessage(uint8 _toMemberId, string _message) public membersOnly { // Log the message. DirectMessage(addressToMember_[msg.sender], _toMemberId, _message); } // Members can also pass a message to any contract that supports it (via the // `theCyberMessage(string)` function), designated by the contract address. function passMessage(address _contractAddress, string _message) public membersOnly { // Log that another contract has been called and passed a message. Call(addressToMember_[msg.sender], _contractAddress, _message); // call the method of the target contract and pass in the message. SupportedContract(_contractAddress).theCyberMessage(_message); } // The contract is not payable by design, but could end up with a balance as // a recipient of a selfdestruct / coinbase of a mined block. function donateFunds() public membersOnly { // Log the donation of any funds that have made their way into the contract. FundsDonated(addressToMember_[msg.sender], this.balance); // Send all available funds to the donation address. DONATIONADDRESS_.transfer(this.balance); } // We also want to be able to access any tokens that are sent to the contract. function donateTokens(address _tokenContractAddress) public membersOnly { // Make sure that we didn't pass in the current contract address by mistake. require(_tokenContractAddress != address(this)); // Log the donation of any tokens that have been sent into the contract. TokensDonated(addressToMember_[msg.sender], _tokenContractAddress, ERC20(_tokenContractAddress).balanceOf(this)); // Send all available tokens at the given contract to the donation address. ERC20(_tokenContractAddress).transfer(DONATIONADDRESS_, ERC20(_tokenContractAddress).balanceOf(this)); } function getMembershipStatus(address _memberAddress) public view returns (bool member, uint8 memberId) { return ( addressIsMember_[_memberAddress], addressToMember_[_memberAddress] ); } function getMemberInformation(uint8 _memberId) public view returns (bytes32 memberName, string memberKey, uint64 memberSince, uint64 inactiveSince, address memberAddress) { return ( members_[_memberId].name, members_[_memberId].pubkey, members_[_memberId].memberSince, members_[_memberId].inactiveSince, memberToAddress_[_memberId] ); } function maxMembers() public pure returns(uint16) { return MAXMEMBERS_; } function inactivityTimeout() public pure returns(uint64) { return INACTIVITYTIMEOUT_; } function donationAddress() public pure returns(address) { return DONATIONADDRESS_; } function memberIsActive(uint8 _memberId) internal view returns (bool) { return (members_[_memberId].inactiveSince == 0); } }
0x6060604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806308614362146100f6578063186690b01461012f5780631c14b3401461018c5780633defb962146102085780637150773d1461021d5780637bbb3a6014610232578063861080ae1461026f578063898855ed146102a85780638c9c2977146102cf578063a7f2f4e214610321578063aef3bc171461037f578063b10c7dc414610496578063bbbff571146104bc578063bf4386a014610519578063e8350fae1461054a578063e998db2a14610570578063ec034bed146105d9575b600080fd5b341561010157600080fd5b61012d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061062e565b005b341561013a57600080fd5b61018a600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506109d6565b005b341561019757600080fd5b610206600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610b1f565b005b341561021357600080fd5b61021b610d67565b005b341561022857600080fd5b610230610ecd565b005b341561023d57600080fd5b610245611032565b604051808267ffffffffffffffff1667ffffffffffffffff16815260200191505060405180910390f35b341561027a57600080fd5b6102a6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061103d565b005b34156102b357600080fd5b6102cd60048080356000191690602001909190505061163d565b005b34156102da57600080fd5b61031f600480803560ff169060200190919080356000191690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611799565b005b341561032c57600080fd5b610358600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611b3c565b60405180831515151581526020018260ff1660ff1681526020019250505060405180910390f35b341561038a57600080fd5b6103a3600480803560ff16906020019091905050611be4565b604051808660001916600019168152602001806020018567ffffffffffffffff1667ffffffffffffffff1681526020018467ffffffffffffffff1667ffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825286818151815260200191508051906020019080838360005b8381101561045757808201518184015260208101905061043c565b50505050905090810190601f1680156104845780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34156104a157600080fd5b6104ba600480803560ff16906020019091905050611d6c565b005b34156104c757600080fd5b610517600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050612103565b005b341561052457600080fd5b61052c6122c8565b604051808261ffff1661ffff16815260200191505060405180910390f35b341561055557600080fd5b61056e600480803560ff169060200190919050506122d2565b005b341561057b57600080fd5b6105d7600480803560ff1690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050612499565b005b34156105e457600080fd5b6105ec6125e7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561068757600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156106c257600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167fe17714fce01d3e4d9f27e8841abde3e84f571f5b89170ada4ab56a7db4408448828373ffffffffffffffffffffffffffffffffffffffff166370a08231306000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15156107d857600080fd5b6102c65a03f115156107e957600080fd5b50505060405180519050604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a28073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb73fb6916095ca1df60bb79ce92ce3ea74c37c5d3598373ffffffffffffffffffffffffffffffffffffffff166370a08231306000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561090f57600080fd5b6102c65a03f1151561092057600080fd5b505050604051805190506000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156109b757600080fd5b6102c65a03f115156109c857600080fd5b505050604051805190505050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610a2f57600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167fbd1d3d6b52ebc809e0b198b8a63b4327a187af395a374fa042b62e643d2b511b826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610ae2578082015181840152602081019050610ac7565b50505050905090810190601f168015610b0f5780820380516001836020036101000a031916815260200191505b509250505060405180910390a250565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b7857600080fd5b8173ffffffffffffffffffffffffffffffffffffffff1661040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167fca48db1ccaccd53c035af3bec289942356536760e217071cdd05e785d42af91f836040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c42578082015181840152602081019050610c27565b50505050905090810190601f168015610c6f5780820380516001836020036101000a031916815260200191505b509250505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff1663a82e0dcc826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d04578082015181840152602081019050610ce9565b50505050905090810190601f168015610d315780820380516001836020036101000a031916815260200191505b5092505050600060405180830381600087803b1515610d4f57600080fd5b6102c65a03f11515610d6057600080fd5b5050505050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610dc057600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f5d929f91f7700c4be753fc214ce808ba74177a3a40b7f63ee5f57d945a5c3e3f60405160405180910390a260008061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff1661010081101515610e9e57fe5b6004020160030160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610f2657600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f926420a40d9c871013b42548439f674fcef6bdfe74839211f1afa91a9c9675283073ffffffffffffffffffffffffffffffffffffffff16316040518082815260200191505060405180910390a273fb6916095ca1df60bb79ce92ce3ea74c37c5d35973ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561103057600080fd5b565b60006276a700905090565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561109657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156110d257600080fd5b61040060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561112c57600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f6bddff94deac5f5ad6ccd6454f19dd625357651ee478c45f69e0995ef7d7d0cf82604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a261040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905542600061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff166101008110151561129157fe5b6004020160030160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060008061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff166101008110151561131f57fe5b6004020160030160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060008061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff16610100811015156113ad57fe5b6004020160010181600019169055506020604051908101604052806000815250600061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff166101008110151561142d57fe5b600402016002019080519060200190611447929190612647565b5080610402600061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff16021790555061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff0219169055600161040060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561169657600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f3bdc0922624ccdf6d855a8f640372a3b5a4f9dc63bc15e69ed54e7a4eb9fd7f18260405180826000191660001916815260200191505060405180910390a280600061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff166101008110151561178757fe5b60040201600101816000191690555050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156117f257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561182e57600080fd5b60008360ff166101008110151561184157fe5b6004020160000160009054906101000a900460ff1615151561186257600080fd5b61040060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156118bc57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff168360ff167f1e4bbc2d61b87c3140634ece2082c7d76448cc04c72996f171ec2c67eeb538458460405180826000191660001916815260200191505060405180910390a360a06040519081016040528060011515815260200183600019168152602001602060405190810160405280600081525081526020014267ffffffffffffffff168152602001600067ffffffffffffffff1681525060008460ff166101008110151561197d57fe5b6004020160008201518160000160006101000a81548160ff0219169083151502179055506020820151816001019060001916905560408201518160020190805190602001906119cd9291906126c7565b5060608201518160030160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060808201518160030160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050508061040260008560ff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508261040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff160217905550600161040060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505050565b60008061040060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661040160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1691509150915091565b6000611bee612747565b6000806000808660ff1661010081101515611c0557fe5b600402016001015460008760ff1661010081101515611c2057fe5b6004020160020160008860ff1661010081101515611c3a57fe5b6004020160030160009054906101000a900467ffffffffffffffff1660008960ff1661010081101515611c6957fe5b6004020160030160089054906101000a900467ffffffffffffffff1661040260008b60ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16838054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611d525780601f10611d2757610100808354040283529160200191611d52565b820191906000526020600020905b815481529060010190602001808311611d3557829003601f168201915b505050505093509450945094509450945091939590929450565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611dc557600080fd5b60008160ff1661010081101515611dd857fe5b6004020160000160009054906101000a900460ff161515611df857600080fd5b611e0181612603565b151515611e0d57600080fd5b8060ff1661040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff1614151515611e6f57600080fd5b6276a70060008260ff1661010081101515611e8657fe5b6004020160030160089054906101000a900467ffffffffffffffff160167ffffffffffffffff164210151515611ebb57600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff168160ff167fed265f1a3332b13c6b4fb47a3837270d7431bcd0018ebbdfde5bb0047f3f0c9260405160405180910390a3610400600061040260008460ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff0219169055610401600061040260008460ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff021916905561040260008260ff16815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560008160ff166101008110151561209757fe5b60040201600080820160006101000a81549060ff021916905560018201600090556002820160006120c8919061275b565b6003820160006101000a81549067ffffffffffffffff02191690556003820160086101000a81549067ffffffffffffffff0219169055505050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561215c57600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f75b418fa6cc3f7cd8247ad205fe1d4268cc8e1e07c4a5e49208f27b9546df040826040518080602001828103825283818151815260200191508051906020019080838360005b8381101561220f5780820151818401526020810190506121f4565b50505050905090810190601f16801561223c5780820380516001836020036101000a031916815260200191505b509250505060405180910390a280600061040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff16610100811015156122aa57fe5b6004020160020190805190602001906122c4929190612647565b5050565b6000610100905090565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561232b57600080fd5b60008160ff166101008110151561233e57fe5b6004020160000160009054906101000a900460ff16151561235e57600080fd5b61236781612603565b151561237257600080fd5b8060ff1661040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff16141515156123d457600080fd5b61040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff168160ff167f61cccff609a8f0d83e0b144beae5df00c88b3f574482bb4a6adb1d08b0c60cab60405160405180910390a34260008260ff166101008110151561246957fe5b6004020160030160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555050565b61040060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156124f257600080fd5b8160ff1661040160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1660ff167f0ab1cbe2ec2a845c35b43420193fc9fae71ae2798c6ef6decfc85b87ee41450c836040518080602001828103825283818151815260200191508051906020019080838360005b838110156125a957808201518184015260208101905061258e565b50505050905090810190601f1680156125d65780820380516001836020036101000a031916815260200191505b509250505060405180910390a35050565b600073fb6916095ca1df60bb79ce92ce3ea74c37c5d359905090565b60008060008360ff166101008110151561261957fe5b6004020160030160089054906101000a900467ffffffffffffffff1667ffffffffffffffff16149050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061268857805160ff19168380011785556126b6565b828001600101855582156126b6579182015b828111156126b557825182559160200191906001019061269a565b5b5090506126c391906127a3565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061270857805160ff1916838001178555612736565b82800160010185558215612736579182015b8281111561273557825182559160200191906001019061271a565b5b50905061274391906127a3565b5090565b602060405190810160405280600081525090565b50805460018160011615610100020316600290046000825580601f1061278157506127a0565b601f01602090049060005260206000209081019061279f91906127a3565b5b50565b6127c591905b808211156127c15760008160009055506001016127a9565b5090565b905600a165627a7a72305820b8dd0934a8336cde74967073024baa3e108f790f55d91fb6710682c25cc660390029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2683, 2683, 2278, 2620, 16147, 27009, 2549, 4215, 2692, 2575, 16576, 2546, 18139, 24434, 2683, 2620, 12740, 2683, 23632, 12879, 4783, 2487, 29292, 6679, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2539, 1025, 3206, 3569, 8663, 6494, 6593, 1063, 1013, 1013, 2372, 2064, 2655, 2151, 3206, 2008, 14451, 2015, 1037, 1036, 1996, 5666, 5677, 7834, 3736, 3351, 1036, 4118, 1012, 3853, 1996, 5666, 5677, 7834, 3736, 3351, 1006, 5164, 1007, 2270, 1025, 1065, 3206, 9413, 2278, 11387, 1063, 1013, 1013, 2057, 2215, 2000, 2022, 2583, 2000, 8980, 1004, 21357, 2151, 19204, 2015, 2741, 2000, 1996, 3206, 1012, 3853, 5703, 11253, 1006, 4769, 1035, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 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,966
0x97a9bac06f90940bce9caec2b880ff17707519e4
/* * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.4.23; /** * @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); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @title 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; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title 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); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @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 ) hasMintPermission 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; } } contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // WISH masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, and(_release, 0xffffffffffffffff)) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } /** * @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); } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { /** * @dev Mint the specified amount of token to the specified address and freeze it until the specified date. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to mint and freeze. * @param _until Release date, must be in future. * @return A boolean that indicates if the operation was successful. */ function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Minato"; string public constant TOKEN_SYMBOL = "MNTO"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x4a7016c0B1edb6e3A28038b361cB59F1f0592D02; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { event Initialized(); bool public initialized = false; constructor() public { init(); transferOwnership(TARGET_USER); } function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } address[5] memory addresses = [address(0x3e2e9daf0444f09d0e6b72e3f543809b34624361),address(0xfa7061b085767d132c275cfc5e46595b21517a08),address(0xc8d7b847f4f75cfee8c4cfdd84b076d91644cb59),address(0x3a2c7011f55cc4e1d588b34bc4cb9182c85da02e),address(0x292c22615d231a4a812df78fdb8701b354781aed)]; uint[5] memory amounts = [uint(200000000000000000000000),uint(250000000000000000000000),uint(250000000000000000000000),uint(100000000000000000000000),uint(200000000000000000000000)]; uint64[5] memory freezes = [uint64(0),uint64(0),uint64(0),uint64(0),uint64(0)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { mint(addresses[i], amounts[i]); } else { mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } if (!CONTINUE_MINTING) { finishMinting(); } emit Initialized(); } }
0x6080604052600436106101d65763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416623fd35a81146101db57806302d6f7301461020457806305d2035b1461024c57806306fdde0314610261578063095ea7b3146102eb5780630bb2cd6b1461030f578063158ef93e1461034057806317a950ac1461035557806318160ddd14610388578063188214001461039d57806323b872dd146103b25780632a905318146103dc578063313ce567146103f15780633be1e9521461041c5780633f4ba83a1461044f57806340c10f191461046457806342966c681461048857806356780085146104a05780635b7f415c146104b55780635be7fde8146104ca5780635c975abb146104df57806366188463146104f457806366a92cda1461051857806370a082311461052d578063715018a61461054e578063726a431a146105635780637d64bcb4146105945780638456cb59146105a95780638da5cb5b146105be57806395d89b41146105d3578063a9059cbb146105e8578063a9aad58c146101db578063ca63b5b81461060c578063cf3b19671461062d578063d73dd62314610642578063d8aeedf514610666578063dd62ed3e14610687578063f2fde38b146106ae575b600080fd5b3480156101e757600080fd5b506101f06106cf565b604080519115158252519081900360200190f35b34801561021057600080fd5b50610228600160a060020a03600435166024356106d4565b6040805167ffffffffffffffff909316835260208301919091528051918290030190f35b34801561025857600080fd5b506101f0610761565b34801561026d57600080fd5b50610276610771565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102b0578181015183820152602001610298565b50505050905090810190601f1680156102dd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102f757600080fd5b506101f0600160a060020a03600435166024356107a8565b34801561031b57600080fd5b506101f0600160a060020a036004351660243567ffffffffffffffff6044351661080e565b34801561034c57600080fd5b506101f06109ac565b34801561036157600080fd5b50610376600160a060020a03600435166109cf565b60408051918252519081900360200190f35b34801561039457600080fd5b506103766109e0565b3480156103a957600080fd5b506102766109e6565b3480156103be57600080fd5b506101f0600160a060020a0360043581169060243516604435610a1d565b3480156103e857600080fd5b50610276610a4a565b3480156103fd57600080fd5b50610406610a81565b6040805160ff9092168252519081900360200190f35b34801561042857600080fd5b5061044d600160a060020a036004351660243567ffffffffffffffff60443516610a86565b005b34801561045b57600080fd5b5061044d610bfa565b34801561047057600080fd5b506101f0600160a060020a0360043516602435610c73565b34801561049457600080fd5b5061044d600435610d6b565b3480156104ac57600080fd5b50610376610d78565b3480156104c157600080fd5b50610376610d84565b3480156104d657600080fd5b50610376610d89565b3480156104eb57600080fd5b506101f0610dee565b34801561050057600080fd5b506101f0600160a060020a0360043516602435610dfe565b34801561052457600080fd5b5061044d610eee565b34801561053957600080fd5b50610376600160a060020a0360043516611091565b34801561055a57600080fd5b5061044d6110ba565b34801561056f57600080fd5b50610578611128565b60408051600160a060020a039092168252519081900360200190f35b3480156105a057600080fd5b506101f0611140565b3480156105b557600080fd5b5061044d6111c4565b3480156105ca57600080fd5b50610578611242565b3480156105df57600080fd5b50610276611251565b3480156105f457600080fd5b506101f0600160a060020a0360043516602435611288565b34801561061857600080fd5b50610376600160a060020a03600435166112b3565b34801561063957600080fd5b50610406610d84565b34801561064e57600080fd5b506101f0600160a060020a0360043516602435611339565b34801561067257600080fd5b50610376600160a060020a03600435166113d2565b34801561069357600080fd5b50610376600160a060020a03600435811690602435166113ed565b3480156106ba57600080fd5b5061044d600160a060020a0360043516611418565b600081565b600080805b8360010181101561072d57600360006106fc878667ffffffffffffffff16611438565b815260208101919091526040016000205467ffffffffffffffff16925082151561072557610759565b6001016106d9565b60046000610745878667ffffffffffffffff16611438565b815260208101919091526040016000205491505b509250929050565b60065460a060020a900460ff1681565b60408051808201909152600681527f4d696e61746f0000000000000000000000000000000000000000000000000000602082015290565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6006546000908190600160a060020a0316331461082a57600080fd5b60065460a060020a900460ff161561084157600080fd5b600154610854908563ffffffff61147616565b60015561086b8567ffffffffffffffff8516611438565b60008181526004602052604090205490915061088d908563ffffffff61147616565b600082815260046020908152604080832093909355600160a060020a03881682526005905220546108c4908563ffffffff61147616565b600160a060020a0386166000908152600560205260409020556108e78584611483565b604080518581529051600160a060020a038716917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885919081900360200190a26040805167ffffffffffffffff85168152602081018690528151600160a060020a038816927f2ecd071e4d10ed2221b04636ed0724cce66a873aa98c1a31b4bb0e6846d3aab4928290030190a2604080518581529051600160a060020a0387169133916000805160206119ec8339815191529181900360200190a3506001949350505050565b600654760100000000000000000000000000000000000000000000900460ff1681565b60006109da8261161d565b92915050565b60015490565b60408051808201909152600681527f4d696e61746f0000000000000000000000000000000000000000000000000000602082015281565b60065460009060a860020a900460ff1615610a3757600080fd5b610a42848484611638565b949350505050565b60408051808201909152600481527f4d4e544f00000000000000000000000000000000000000000000000000000000602082015281565b601290565b6000600160a060020a0384161515610a9d57600080fd5b33600090815260208190526040902054831115610ab957600080fd5b33600090815260208190526040902054610ad9908463ffffffff61179d16565b33600090815260208190526040902055610afd8467ffffffffffffffff8416611438565b600081815260046020526040902054909150610b1f908463ffffffff61147616565b600082815260046020908152604080832093909355600160a060020a0387168252600590522054610b56908463ffffffff61147616565b600160a060020a038516600090815260056020526040902055610b798483611483565b604080518481529051600160a060020a0386169133916000805160206119ec8339815191529181900360200190a36040805167ffffffffffffffff84168152602081018590528151600160a060020a038716927f2ecd071e4d10ed2221b04636ed0724cce66a873aa98c1a31b4bb0e6846d3aab4928290030190a250505050565b600654600160a060020a03163314610c1157600080fd5b60065460a860020a900460ff161515610c2957600080fd5b6006805475ff000000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600654600090600160a060020a03163314610c8d57600080fd5b60065460a060020a900460ff1615610ca457600080fd5b600154610cb7908363ffffffff61147616565b600155600160a060020a038316600090815260208190526040902054610ce3908363ffffffff61147616565b600160a060020a03841660008181526020818152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000916000805160206119ec8339815191529181900360200190a350600192915050565b610d7533826117af565b50565b670de0b6b3a764000081565b601281565b6000806000610d993360006106d4565b67ffffffffffffffff909116925090505b8115801590610db857508142115b15610de957610dc5610eee565b91820191610dd43360006106d4565b67ffffffffffffffff90911692509050610daa565b505090565b60065460a860020a900460ff1681565b336000908152600260209081526040808320600160a060020a038616845290915281205480831115610e5357336000908152600260209081526040808320600160a060020a0388168452909152812055610e88565b610e63818463ffffffff61179d16565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000806000806000610f01336000611438565b60008181526003602052604090205490955067ffffffffffffffff169350831515610f2b57600080fd5b8367ffffffffffffffff164267ffffffffffffffff16111515610f4d57600080fd5b610f61338567ffffffffffffffff16611438565b600081815260036020908152604080832054600483528184208054908590553385529284905292205492955067ffffffffffffffff90911693509150610fad908263ffffffff61147616565b3360009081526020818152604080832093909355600590522054610fd7908263ffffffff61179d16565b3360009081526005602052604090205567ffffffffffffffff8216151561101a576000858152600360205260409020805467ffffffffffffffff19169055611054565b600085815260036020526040808220805467ffffffffffffffff861667ffffffffffffffff19918216179091558583529120805490911690555b60408051828152905133917fb21fb52d5749b80f3182f8c6992236b5e5576681880914484d7f4c9b062e619e919081900360200190a25050505050565b600160a060020a0381166000908152600560205260408120546110b38361161d565b0192915050565b600654600160a060020a031633146110d157600080fd5b600654604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a26006805473ffffffffffffffffffffffffffffffffffffffff19169055565b734a7016c0b1edb6e3a28038b361cb59f1f0592d0281565b600654600090600160a060020a0316331461115a57600080fd5b60065460a060020a900460ff161561117157600080fd5b6006805474ff0000000000000000000000000000000000000000191660a060020a1790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b600654600160a060020a031633146111db57600080fd5b60065460a860020a900460ff16156111f257600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600654600160a060020a031681565b60408051808201909152600481527f4d4e544f00000000000000000000000000000000000000000000000000000000602082015290565b60065460009060a860020a900460ff16156112a257600080fd5b6112ac838361189e565b9392505050565b600080600360006112c5856000611438565b815260208101919091526040016000205467ffffffffffffffff1690505b67ffffffffffffffff81161561133357600190910190600360006113118567ffffffffffffffff8516611438565b815260208101919091526040016000205467ffffffffffffffff1690506112e3565b50919050565b336000908152600260209081526040808320600160a060020a038616845290915281205461136d908363ffffffff61147616565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a031660009081526005602052604090205490565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600654600160a060020a0316331461142f57600080fd5b610d758161196d565b67ffffffffffffffff166801000000000000000091909102177f57495348000000000000000000000000000000000000000000000000000000001790565b818101828110156109da57fe5b6000808080804267ffffffffffffffff87161161149f57600080fd5b6114b3878767ffffffffffffffff16611438565b94506114c0876000611438565b60008181526003602052604090205490945067ffffffffffffffff169250821515611513576000848152600360205260409020805467ffffffffffffffff191667ffffffffffffffff8816179055611614565b611527878467ffffffffffffffff16611438565b91505b67ffffffffffffffff83161580159061155657508267ffffffffffffffff168667ffffffffffffffff16115b1561158f575060008181526003602052604090205490925067ffffffffffffffff908116918391166115888784611438565b915061152a565b8267ffffffffffffffff168667ffffffffffffffff1614156115b057611614565b67ffffffffffffffff8316156115ea576000858152600360205260409020805467ffffffffffffffff191667ffffffffffffffff85161790555b6000848152600360205260409020805467ffffffffffffffff191667ffffffffffffffff88161790555b50505050505050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a038316151561164f57600080fd5b600160a060020a03841660009081526020819052604090205482111561167457600080fd5b600160a060020a03841660009081526002602090815260408083203384529091529020548211156116a457600080fd5b600160a060020a0384166000908152602081905260409020546116cd908363ffffffff61179d16565b600160a060020a038086166000908152602081905260408082209390935590851681522054611702908363ffffffff61147616565b600160a060020a03808516600090815260208181526040808320949094559187168152600282528281203382529091522054611744908363ffffffff61179d16565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391926000805160206119ec833981519152929181900390910190a35060019392505050565b6000828211156117a957fe5b50900390565b600160a060020a0382166000908152602081905260409020548111156117d457600080fd5b600160a060020a0382166000908152602081905260409020546117fd908263ffffffff61179d16565b600160a060020a038316600090815260208190526040902055600154611829908263ffffffff61179d16565b600155604080518281529051600160a060020a038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518281529051600091600160a060020a038516916000805160206119ec8339815191529181900360200190a35050565b6000600160a060020a03831615156118b557600080fd5b336000908152602081905260409020548211156118d157600080fd5b336000908152602081905260409020546118f1908363ffffffff61179d16565b3360009081526020819052604080822092909255600160a060020a03851681522054611923908363ffffffff61147616565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233926000805160206119ec8339815191529281900390910190a350600192915050565b600160a060020a038116151561198257600080fd5b600654604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058203cca1415befb88205524c2822e36f355875f4733797ce05f02b50a31742c7d7b0029
{"success": true, "error": null, "results": {"detectors": [{"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2683, 3676, 2278, 2692, 2575, 2546, 21057, 2683, 12740, 9818, 2063, 2683, 3540, 8586, 2475, 2497, 2620, 17914, 4246, 16576, 19841, 23352, 16147, 2063, 2549, 1013, 1008, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 8276, 2236, 2270, 6105, 2004, 2405, 2011, 1008, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, 2030, 1008, 1006, 2012, 2115, 5724, 1007, 2151, 2101, 2544, 1012, 1008, 1008, 2023, 2565, 2003, 5500, 1999, 1996, 3246, 2008, 2009, 2097, 2022, 6179, 1010, 1008, 2021, 2302, 2151, 10943, 2100, 1025, 2302, 2130, 1996, 13339, 10943, 2100, 1997, 1008, 6432, 8010, 2030, 10516, 2005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,967
0x97a9c4d7907c391e59f11dcd16a35726849183b3
pragma solidity 0.6.11; // SPDX-License-Identifier: BSD-3-Clause /** * @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 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)); } } /** * @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.3._ */ 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.3._ */ 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); } } } } /** * @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); } /** * @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"); } } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } interface IUniswapV2Router { 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 removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Pair { 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 token0() external view returns (address); function token1() external view returns (address); function sync() external; } interface StakingContract { function depositByContract(address account, uint amount, uint _amountOutMin_stakingReferralFee, uint deadline) external; } /** * @dev Staking Smart Contract * * - Users stake Uniswap LP Tokens to receive WETH and DYP Tokens as Rewards * * - Reward Tokens (DYP) are added to contract balance upon deployment by deployer * * - After Adding the DYP rewards, admin is supposed to transfer ownership to Governance contract * * - Users deposit Set (Predecided) Uniswap LP Tokens and get a share of the farm * * - The smart contract disburses `disburseAmount` DYP as rewards over `disburseDuration` * * - A swap is attempted periodically at atleast a set delay from last swap * * - The swap is attempted according to SWAP_PATH for difference deployments of this contract * * - For 4 different deployments of this contract, the SWAP_PATH will be: * - DYP-WETH * - DYP-WBTC-WETH (assumes appropriate liquidity is available in WBTC-WETH pair) * - DYP-USDT-WETH (assumes appropriate liquidity is available in USDT-WETH pair) * - DYP-USDC-WETH (assumes appropriate liquidity is available in USDC-WETH pair) * * - Any swap may not have a price impact on DYP price of more than approx ~2.49% for the related DYP pair * DYP-WETH swap may not have a price impact of more than ~2.49% on DYP price in DYP-WETH pair * DYP-WBTC-WETH swap may not have a price impact of more than ~2.49% on DYP price in DYP-WBTC pair * DYP-USDT-WETH swap may not have a price impact of more than ~2.49% on DYP price in DYP-USDT pair * DYP-USDC-WETH swap may not have a price impact of more than ~2.49% on DYP price in DYP-USDC pair * * - After the swap,converted WETH is distributed to stakers at pro-rata basis, according to their share of the staking pool * on the moment when the WETH distribution is done. And remaining DYP is added to the amount to be distributed or burnt. * The remaining DYP are also attempted to be swapped to WETH in the next swap if the price impact is ~2.49% or less * * - At a set delay from last execution, Governance contract (owner) may execute disburse or burn features * * - Burn feature should send the DYP tokens to set BURN_ADDRESS * * - Disburse feature should disburse the DYP * (which would have a max price impact ~2.49% if it were to be swapped, at disburse time * - remaining DYP are sent to BURN_ADDRESS) * to stakers at pro-rata basis according to their share of * the staking pool at the moment the disburse is done * * - Users may claim their pending WETH and DYP anytime * * - Pending rewards are auto-claimed on any deposit or withdraw * * - Users need to wait `cliffTime` duration since their last deposit before withdrawing any LP Tokens * * - Owner may not transfer out LP Tokens from this contract anytime * * - Owner may transfer out WETH and DYP Tokens from this contract once `adminClaimableTime` is reached * * - CONTRACT VARIABLES must be changed to appropriate values before live deployment */ contract FarmProRata is Ownable { using SafeMath for uint; using EnumerableSet for EnumerableSet.AddressSet; using Address for address; using SafeERC20 for IERC20; event RewardsTransferred(address holder, uint amount); event EthRewardsTransferred(address holder, uint amount); event RewardsDisbursed(uint amount); event EthRewardsDisbursed(uint amount); event EmergencyDeclared(address owner); event UniswapV2RouterChanged(address router); event StakingFeeChanged(uint fee); event UnstakingFeeChanged(uint fee); event MagicNumberChanged(uint newMagicNumber); event LockupTimeChanged(uint lockupTime); event FeeRecipientAddressChanged(address newAddress); // ============ SMART CONTRACT VARIABLES ========================== // Must be changed to appropriate configuration before live deployment // deposit token contract address and reward token contract address // these contracts (and uniswap pair & router) are "trusted" // and checked to not contain re-entrancy pattern // to safely avoid checks-effects-interactions where needed to simplify logic address public constant trustedDepositTokenAddress = 0x7463286A379F6F128058bb92B355e3d6E8BDB219; // uniswap pair address // token used for rewards - this must be one of the tokens in uniswap pair. address public constant trustedRewardTokenAddress = 0xBD100d061E120b2c67A24453CF6368E63f1Be056; address public constant trustedStakingContractAddress = 0x0b92E7f074e7Ade0181A29647ea8474522e6A7C2; // the main token which is normally claimed as reward address public constant trustedPlatformTokenAddress = 0x961C8c0B1aaD0c0b10a51FeF6a867E3091BCef17; // the other token in the uniswap pair used address public constant trustedBaseTokenAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // Make sure to double-check BURN_ADDRESS address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; // cliffTime - withdraw is not possible within cliffTime of deposit uint public cliffTime = 3 days; // Amount of tokens uint public constant disburseAmount = 996000e18; // To be disbursed continuously over this duration uint public constant disburseDuration = 365 days; // If there are any undistributed or unclaimed tokens left in contract after this time // Admin can claim them uint public constant adminCanClaimAfter = 395 days; // delays between attempted swaps uint public constant swapAttemptPeriod = 1 days; // delays between attempted burns or token disbursement uint public constant burnOrDisburseTokensPeriod = 7 days; // do not change this => disburse 100% rewards over `disburseDuration` uint public constant disbursePercentX100 = 100e2; uint public constant EMERGENCY_WAIT_TIME = 3 days; uint public STAKING_FEE_RATE_X_100 = 0; uint public UNSTAKING_FEE_RATE_X_100 = 0; uint public MAGIC_NUMBER = 5025125628140614; // ============ END CONTRACT VARIABLES ========================== event ClaimableTokenAdded(address indexed tokenAddress); event ClaimableTokenRemoved(address indexed tokenAddress); mapping (address => bool) public trustedClaimableTokens; function addTrustedClaimableToken(address trustedClaimableTokenAddress) external onlyOwner { trustedClaimableTokens[trustedClaimableTokenAddress] = true; emit ClaimableTokenAdded(trustedClaimableTokenAddress); } function removeTrustedClaimableToken(address trustedClaimableTokenAddress) external onlyOwner { trustedClaimableTokens[trustedClaimableTokenAddress] = false; emit ClaimableTokenRemoved(trustedClaimableTokenAddress); } uint public contractDeployTime; uint public adminClaimableTime; uint public lastDisburseTime; uint public lastSwapExecutionTime; uint public lastBurnOrTokenDistributeTime; bool public isEmergency = false; IUniswapV2Router public uniswapRouterV2; IUniswapV2Pair public uniswapV2Pair; address[] public SWAP_PATH; address public feeRecipientAddress; constructor(address[] memory swapPath, address _uniswapV2RouterAddress, address _feeRecipientAddress) public { contractDeployTime = now; adminClaimableTime = contractDeployTime.add(adminCanClaimAfter); lastDisburseTime = contractDeployTime; lastSwapExecutionTime = lastDisburseTime; lastBurnOrTokenDistributeTime = lastDisburseTime; setUniswapV2Router(IUniswapV2Router(_uniswapV2RouterAddress)); setFeeRecipientAddress(_feeRecipientAddress); uniswapV2Pair = IUniswapV2Pair(trustedDepositTokenAddress); SWAP_PATH = swapPath; } function setFeeRecipientAddress(address newFeeRecipientAddress) public onlyOwner { require(newFeeRecipientAddress != address(0), "Invalid address!"); feeRecipientAddress = newFeeRecipientAddress; emit FeeRecipientAddressChanged(feeRecipientAddress); } // Contracts are not allowed to deposit, claim or withdraw modifier noContractsAllowed() { require(!(address(msg.sender).isContract()) && tx.origin == msg.sender, "No Contracts Allowed!"); _; } modifier notDuringEmergency() { require(!isEmergency, "Cannot execute during emergency!"); _; } function declareEmergency() external onlyOwner notDuringEmergency { isEmergency = true; adminClaimableTime = now.add(EMERGENCY_WAIT_TIME); cliffTime = 0; emit EmergencyDeclared(owner); } uint public totalClaimedRewards = 0; uint public totalClaimedRewardsEth = 0; EnumerableSet.AddressSet private holders; mapping (address => uint) public depositedTokens; mapping (address => uint) public depositTime; mapping (address => uint) public lastClaimedTime; mapping (address => uint) public totalEarnedTokens; mapping (address => uint) public totalEarnedEth; mapping (address => uint) public lastDivPoints; mapping (address => uint) public lastEthDivPoints; uint public contractBalance = 0; uint public totalDivPoints = 0; uint public totalEthDivPoints = 0; uint public totalTokens = 0; uint public tokensToBeDisbursedOrBurnt = 0; uint public tokensToBeSwapped = 0; uint internal constant pointMultiplier = 1e18; function setUniswapV2Router(IUniswapV2Router router) public onlyOwner { require(address(router) != address(0), "Invalid router address!"); uniswapRouterV2 = router; emit UniswapV2RouterChanged(address(uniswapRouterV2)); } function setStakingFeeRateX100(uint newStakingFeeRateX100) public onlyOwner { require(newStakingFeeRateX100 < 100e2, "Invalid fee!"); STAKING_FEE_RATE_X_100 = newStakingFeeRateX100; emit StakingFeeChanged(STAKING_FEE_RATE_X_100); } function setUnstakingFeeRateX100(uint newUnstakingFeeRateX100) public onlyOwner { require(newUnstakingFeeRateX100 < 100e2, "Invalid fee!"); UNSTAKING_FEE_RATE_X_100 = newUnstakingFeeRateX100; emit UnstakingFeeChanged(UNSTAKING_FEE_RATE_X_100); } function setMagicNumber(uint newMagicNumber) public onlyOwner { MAGIC_NUMBER = newMagicNumber; emit MagicNumberChanged(MAGIC_NUMBER); } function setLockupTime(uint _newLockupTime) public onlyOwner { require(_newLockupTime <= 90 days, "Lockup time too long!"); cliffTime = _newLockupTime; emit LockupTimeChanged(cliffTime); } function setContractVariables( uint newMagicNumber, uint lockupTime, uint stakingFeeRateX100, uint unstakingFeeRateX100, address _uniswapV2RouterAddress, address newFeeRecipientAddress ) external onlyOwner { setMagicNumber(newMagicNumber); setLockupTime(lockupTime); setStakingFeeRateX100(stakingFeeRateX100); setUnstakingFeeRateX100(unstakingFeeRateX100); setUniswapV2Router(IUniswapV2Router(_uniswapV2RouterAddress)); setFeeRecipientAddress(newFeeRecipientAddress); } // To be executed by admin after deployment to add DYP to contract function addContractBalance(uint amount) public onlyOwner { IERC20(trustedRewardTokenAddress).safeTransferFrom(msg.sender, address(this), amount); contractBalance = contractBalance.add(amount); } function doSwap(address fromToken, address toToken, uint fromTokenAmount, uint amountOutMin, uint deadline) private returns (uint _toTokenReceived) { if (fromToken == toToken) { return fromTokenAmount; } IERC20(fromToken).safeApprove(address(uniswapRouterV2), 0); IERC20(fromToken).safeApprove(address(uniswapRouterV2), fromTokenAmount); uint oldToTokenBalance = IERC20(toToken).balanceOf(address(this)); address[] memory path; if (fromToken == uniswapRouterV2.WETH() || toToken == uniswapRouterV2.WETH()) { path = new address[](2); path[0] = fromToken; path[1] = toToken; } else { path = new address[](3); path[0] = fromToken; path[1] = uniswapRouterV2.WETH(); path[2] = toToken; } uniswapRouterV2.swapExactTokensForTokens(fromTokenAmount, amountOutMin, path, address(this), deadline); uint newToTokenBalance = IERC20(toToken).balanceOf(address(this)); uint toTokenReceived = newToTokenBalance.sub(oldToTokenBalance); return toTokenReceived; } // Private function to update account information and auto-claim pending rewards function updateAccount( address account, address claimAsToken, uint _amountOutMin_claimAsToken_weth, uint _amountOutMin_claimAsToken_dyp, uint _amountOutMin_attemptSwap, uint _deadline ) private { disburseTokens(); attemptSwap(_amountOutMin_attemptSwap, _deadline); uint pendingDivs = getPendingDivs(account); if (pendingDivs > 0) { uint amountToTransfer; address tokenToTransfer; if (claimAsToken == address(0) || claimAsToken == trustedPlatformTokenAddress) { tokenToTransfer = trustedPlatformTokenAddress; amountToTransfer = doSwap(trustedRewardTokenAddress, trustedPlatformTokenAddress, pendingDivs, _amountOutMin_claimAsToken_dyp, _deadline); } else { tokenToTransfer = claimAsToken; amountToTransfer = doSwap(trustedRewardTokenAddress, claimAsToken, pendingDivs, _amountOutMin_claimAsToken_dyp, _deadline); } IERC20(tokenToTransfer).safeTransfer(account, amountToTransfer); totalEarnedTokens[account] = totalEarnedTokens[account].add(pendingDivs); totalClaimedRewards = totalClaimedRewards.add(pendingDivs); emit RewardsTransferred(account, pendingDivs); } uint pendingDivsEth = getPendingDivsEth(account); if (pendingDivsEth > 0) { if (claimAsToken == address(0) || claimAsToken == uniswapRouterV2.WETH()) { IERC20(uniswapRouterV2.WETH()).safeTransfer(account, pendingDivsEth); } else { require(trustedClaimableTokens[claimAsToken], "cannot claim as this token!"); IERC20(uniswapRouterV2.WETH()).safeApprove(address(uniswapRouterV2), 0); IERC20(uniswapRouterV2.WETH()).safeApprove(address(uniswapRouterV2), pendingDivsEth); address[] memory path = new address[](2); path[0] = uniswapRouterV2.WETH(); path[1] = claimAsToken; uniswapRouterV2.swapExactTokensForTokens(pendingDivsEth, _amountOutMin_claimAsToken_weth, path, account, _deadline); } totalEarnedEth[account] = totalEarnedEth[account].add(pendingDivsEth); totalClaimedRewardsEth = totalClaimedRewardsEth.add(pendingDivsEth); emit EthRewardsTransferred(account, pendingDivsEth); } lastClaimedTime[account] = now; lastDivPoints[account] = totalDivPoints; lastEthDivPoints[account] = totalEthDivPoints; } function updateAccount(address account, uint _amountOutMin_claimAsToken_dyp, uint _amountOutMin_attemptSwap, uint _deadline) private { updateAccount(account, address(0), 0, _amountOutMin_claimAsToken_dyp, _amountOutMin_attemptSwap, _deadline); } // view function to check last updated DYP pending rewards function getPendingDivs(address _holder) public view returns (uint) { if (!holders.contains(_holder)) return 0; if (depositedTokens[_holder] == 0) return 0; uint newDivPoints = totalDivPoints.sub(lastDivPoints[_holder]); uint depositedAmount = depositedTokens[_holder]; uint pendingDivs = depositedAmount.mul(newDivPoints).div(pointMultiplier); return pendingDivs; } // view function to check last updated WETH pending rewards function getPendingDivsEth(address _holder) public view returns (uint) { if (!holders.contains(_holder)) return 0; if (depositedTokens[_holder] == 0) return 0; uint newDivPoints = totalEthDivPoints.sub(lastEthDivPoints[_holder]); uint depositedAmount = depositedTokens[_holder]; uint pendingDivs = depositedAmount.mul(newDivPoints).div(pointMultiplier); return pendingDivs; } // view functon to get number of stakers function getNumberOfHolders() public view returns (uint) { return holders.length(); } // deposit function to stake LP Tokens function deposit( address depositToken, uint amountToStake, uint[] memory minAmounts, // uint _amountOutMin_25Percent, // 0 // uint _amountOutMin_stakingReferralFee, // 1 // uint amountLiquidityMin_rewardTokenReceived, // 2 // uint amountLiquidityMin_baseTokenReceived, // 3 // uint _amountOutMin_rewardTokenReceived, // 4 // uint _amountOutMin_baseTokenReceived, // 5 // uint _amountOutMin_claimAsToken_dyp, // 6 // uint _amountOutMin_attemptSwap, // 7 uint _deadline ) public noContractsAllowed notDuringEmergency { require(minAmounts.length == 8, "Invalid minAmounts length!"); require(trustedClaimableTokens[depositToken], "Invalid deposit token!"); // can deposit reward token directly // require(depositToken != trustedRewardTokenAddress, "Cannot deposit reward token!"); require(depositToken != trustedDepositTokenAddress, "Cannot deposit LP directly!"); require(depositToken != address(0), "Deposit token cannot be 0!"); require(amountToStake > 0, "Invalid amount to Stake!"); IERC20(depositToken).safeTransferFrom(msg.sender, address(this), amountToStake); uint fee = amountToStake.mul(STAKING_FEE_RATE_X_100).div(100e2); uint amountAfterFee = amountToStake.sub(fee); if (fee > 0) { IERC20(depositToken).safeTransfer(feeRecipientAddress, fee); } uint _75Percent = amountAfterFee.mul(75e2).div(100e2); uint _25Percent = amountAfterFee.sub(_75Percent); uint amountToDepositByContract = doSwap(depositToken, trustedPlatformTokenAddress, _25Percent, /*_amountOutMin_25Percent*/minAmounts[0], _deadline); IERC20(trustedPlatformTokenAddress).safeApprove(address(trustedStakingContractAddress), 0); IERC20(trustedPlatformTokenAddress).safeApprove(address(trustedStakingContractAddress), amountToDepositByContract); StakingContract(trustedStakingContractAddress).depositByContract(msg.sender, amountToDepositByContract, /*_amountOutMin_stakingReferralFee*/minAmounts[1], _deadline); uint half = _75Percent.div(2); uint otherHalf = _75Percent.sub(half); uint _rewardTokenReceived = doSwap(depositToken, trustedRewardTokenAddress, half, /*_amountOutMin_rewardTokenReceived*/minAmounts[4], _deadline); uint _baseTokenReceived = doSwap(depositToken, trustedBaseTokenAddress, otherHalf, /*_amountOutMin_baseTokenReceived*/minAmounts[5], _deadline); uint amountToDeposit = addLiquidityAndGetAmountToDeposit( _rewardTokenReceived, _baseTokenReceived, minAmounts, _deadline ); require(amountToDeposit > 0, "Cannot deposit 0 Tokens"); updateAccount(msg.sender, /*_amountOutMin_claimAsToken_dyp*/minAmounts[6], /*_amountOutMin_attemptSwap*/minAmounts[7], _deadline); depositedTokens[msg.sender] = depositedTokens[msg.sender].add(amountToDeposit); totalTokens = totalTokens.add(amountToDeposit); holders.add(msg.sender); depositTime[msg.sender] = now; } function addLiquidityAndGetAmountToDeposit( uint _rewardTokenReceived, uint _baseTokenReceived, uint[] memory minAmounts, uint _deadline ) private returns (uint) { require(_rewardTokenReceived >= minAmounts[2], "Reward Token Received lower than expected!"); require(_baseTokenReceived >= minAmounts[3], "Base Token Received lower than expected!"); uint oldLpBalance = IERC20(trustedDepositTokenAddress).balanceOf(address(this)); IERC20(trustedRewardTokenAddress).safeApprove(address(uniswapRouterV2), 0); IERC20(trustedRewardTokenAddress).safeApprove(address(uniswapRouterV2), _rewardTokenReceived); IERC20(trustedBaseTokenAddress).safeApprove(address(uniswapRouterV2), 0); IERC20(trustedBaseTokenAddress).safeApprove(address(uniswapRouterV2), _baseTokenReceived); uniswapRouterV2.addLiquidity( trustedRewardTokenAddress, trustedBaseTokenAddress, _rewardTokenReceived, _baseTokenReceived, /*amountLiquidityMin_rewardTokenReceived*/minAmounts[2], /*amountLiquidityMin_baseTokenReceived*/minAmounts[3], address(this), _deadline ); uint newLpBalance = IERC20(trustedDepositTokenAddress).balanceOf(address(this)); uint lpTokensReceived = newLpBalance.sub(oldLpBalance); return lpTokensReceived; } // withdraw function to unstake LP Tokens function withdraw( address withdrawAsToken, uint amountToWithdraw, uint[] memory minAmounts, // uint _amountLiquidityMin_rewardToken, // 0 // uint _amountLiquidityMin_baseToken, // 1 // uint _amountOutMin_withdrawAsToken_rewardTokenReceived, // 2 // uint _amountOutMin_withdrawAsToken_baseTokenReceived, // 3 // uint _amountOutMin_claimAsToken_dyp, // 4 // uint _amountOutMin_attemptSwap, // 5 uint _deadline ) public noContractsAllowed { require(minAmounts.length == 6, "Invalid minAmounts!"); require(withdrawAsToken != address(0), "Invalid withdraw token!"); require(trustedClaimableTokens[withdrawAsToken], "Withdraw token not trusted!"); require(amountToWithdraw > 0, "Cannot withdraw 0 Tokens!"); require(depositedTokens[msg.sender] >= amountToWithdraw, "Invalid amount to withdraw"); require(now.sub(depositTime[msg.sender]) > cliffTime, "You recently deposited, please wait before withdrawing."); updateAccount(msg.sender, /*_amountOutMin_claimAsToken_dyp*/ minAmounts[4] , /*_amountOutMin_attemptSwap*/ minAmounts[5], _deadline); uint fee = amountToWithdraw.mul(UNSTAKING_FEE_RATE_X_100).div(100e2); uint amountAfterFee = amountToWithdraw.sub(fee); if (fee > 0) { IERC20(trustedDepositTokenAddress).safeTransfer(feeRecipientAddress, fee); } uint withdrawTokenReceived = removeLiquidityAndGetWithdrawTokenReceived(withdrawAsToken, amountAfterFee, minAmounts, _deadline); IERC20(withdrawAsToken).safeTransfer(msg.sender, withdrawTokenReceived); depositedTokens[msg.sender] = depositedTokens[msg.sender].sub(amountToWithdraw); totalTokens = totalTokens.sub(amountToWithdraw); if (holders.contains(msg.sender) && depositedTokens[msg.sender] == 0) { holders.remove(msg.sender); } } function removeLiquidityAndGetWithdrawTokenReceived( address withdrawAsToken, uint amountAfterFee, uint[] memory minAmounts, uint _deadline ) private returns (uint) { IERC20(trustedDepositTokenAddress).safeApprove(address(uniswapRouterV2), 0); IERC20(trustedDepositTokenAddress).safeApprove(address(uniswapRouterV2), amountAfterFee); uint _oldRewardTokenBalance = IERC20(trustedRewardTokenAddress).balanceOf(address(this)); uint _oldBaseTokenBalance = IERC20(trustedBaseTokenAddress).balanceOf(address(this)); uniswapRouterV2.removeLiquidity( trustedRewardTokenAddress, trustedBaseTokenAddress, amountAfterFee, /*_amountLiquidityMin_rewardToken*/ minAmounts[0], /*_amountLiquidityMin_baseToken*/minAmounts[1], address(this), _deadline ); uint _newRewardTokenBalance = IERC20(trustedRewardTokenAddress).balanceOf(address(this)); uint _newBaseTokenBalance = IERC20(trustedBaseTokenAddress).balanceOf(address(this)); uint _rewardTokenReceivedAfterRemovingLiquidity = _newRewardTokenBalance.sub(_oldRewardTokenBalance); uint _baseTokenReceivedAfterRemovingLiquidity = _newBaseTokenBalance.sub(_oldBaseTokenBalance); uint withdrawTokenReceived1 = doSwap(trustedRewardTokenAddress, withdrawAsToken, _rewardTokenReceivedAfterRemovingLiquidity, /*_amountOutMin_withdrawAsToken_rewardTokenReceived*/minAmounts[2], _deadline); uint withdrawTokenReceived2 = doSwap(trustedBaseTokenAddress, withdrawAsToken, _baseTokenReceivedAfterRemovingLiquidity, /*_amountOutMin_withdrawAsToken_baseTokenReceived*/minAmounts[3], _deadline); uint tokensReceived = withdrawTokenReceived1.add(withdrawTokenReceived2); return tokensReceived; } // claim function to claim pending rewards function claim(uint _amountOutMin_claimAsToken_dyp, uint _amountOutMin_attemptSwap, uint _deadline) public noContractsAllowed notDuringEmergency { updateAccount(msg.sender, _amountOutMin_claimAsToken_dyp, _amountOutMin_attemptSwap, _deadline); } function claimAs(address claimAsToken, uint _amountOutMin_claimAsToken_weth, uint _amountOutMin_claimAsToken_dyp, uint _amountOutMin_attemptSwap, uint _deadline) public noContractsAllowed notDuringEmergency { require(trustedClaimableTokens[claimAsToken], "cannot claim as this token!"); updateAccount(msg.sender, claimAsToken, _amountOutMin_claimAsToken_weth, _amountOutMin_claimAsToken_dyp, _amountOutMin_attemptSwap, _deadline); } // private function to distribute DYP rewards function distributeDivs(uint amount) private { require(amount > 0 && totalTokens > 0, "distributeDivs failed!"); totalDivPoints = totalDivPoints.add(amount.mul(pointMultiplier).div(totalTokens)); emit RewardsDisbursed(amount); } // private function to distribute WETH rewards function distributeDivsEth(uint amount) private { require(amount > 0 && totalTokens > 0, "distributeDivsEth failed!"); totalEthDivPoints = totalEthDivPoints.add(amount.mul(pointMultiplier).div(totalTokens)); emit EthRewardsDisbursed(amount); } // private function to allocate DYP to be disbursed calculated according to time passed function disburseTokens() private { uint amount = getPendingDisbursement(); if (contractBalance < amount) { amount = contractBalance; } if (amount == 0 || totalTokens == 0) return; tokensToBeSwapped = tokensToBeSwapped.add(amount); contractBalance = contractBalance.sub(amount); lastDisburseTime = now; } function attemptSwap(uint _amountOutMin_attemptSwap, uint _deadline) private { // do not attemptSwap if no one has staked if (totalTokens == 0) { return; } // Cannot execute swap so quickly if (now.sub(lastSwapExecutionTime) < swapAttemptPeriod) { return; } // force reserves to match balances uniswapV2Pair.sync(); uint _tokensToBeSwapped = tokensToBeSwapped.add(tokensToBeDisbursedOrBurnt); uint maxSwappableAmount = getMaxSwappableAmount(); // don't proceed if no liquidity if (maxSwappableAmount == 0) return; if (maxSwappableAmount < tokensToBeSwapped) { uint diff = tokensToBeSwapped.sub(maxSwappableAmount); _tokensToBeSwapped = tokensToBeSwapped.sub(diff); tokensToBeDisbursedOrBurnt = tokensToBeDisbursedOrBurnt.add(diff); tokensToBeSwapped = 0; } else if (maxSwappableAmount < _tokensToBeSwapped) { uint diff = _tokensToBeSwapped.sub(maxSwappableAmount); _tokensToBeSwapped = _tokensToBeSwapped.sub(diff); tokensToBeDisbursedOrBurnt = diff; tokensToBeSwapped = 0; } else { tokensToBeSwapped = 0; tokensToBeDisbursedOrBurnt = 0; } // don't execute 0 swap tokens if (_tokensToBeSwapped == 0) { return; } // cannot execute swap at insufficient balance if (IERC20(trustedRewardTokenAddress).balanceOf(address(this)) < _tokensToBeSwapped) { return; } IERC20(trustedRewardTokenAddress).safeApprove(address(uniswapRouterV2), 0); IERC20(trustedRewardTokenAddress).safeApprove(address(uniswapRouterV2), _tokensToBeSwapped); uint oldWethBalance = IERC20(uniswapRouterV2.WETH()).balanceOf(address(this)); uniswapRouterV2.swapExactTokensForTokens(_tokensToBeSwapped, _amountOutMin_attemptSwap, SWAP_PATH, address(this), _deadline); uint newWethBalance = IERC20(uniswapRouterV2.WETH()).balanceOf(address(this)); uint wethReceived = newWethBalance.sub(oldWethBalance); if (wethReceived > 0) { distributeDivsEth(wethReceived); } lastSwapExecutionTime = now; } // Owner is supposed to be a Governance Contract function disburseRewardTokens() public onlyOwner { require(now.sub(lastBurnOrTokenDistributeTime) > burnOrDisburseTokensPeriod, "Recently executed, Please wait!"); // force reserves to match balances uniswapV2Pair.sync(); uint maxSwappableAmount = getMaxSwappableAmount(); uint _tokensToBeDisbursed = tokensToBeDisbursedOrBurnt; uint _tokensToBeBurnt; if (maxSwappableAmount < _tokensToBeDisbursed) { _tokensToBeBurnt = _tokensToBeDisbursed.sub(maxSwappableAmount); _tokensToBeDisbursed = maxSwappableAmount; } distributeDivs(_tokensToBeDisbursed); if (_tokensToBeBurnt > 0) { IERC20(trustedRewardTokenAddress).safeTransfer(BURN_ADDRESS, _tokensToBeBurnt); } tokensToBeDisbursedOrBurnt = 0; lastBurnOrTokenDistributeTime = now; } // Owner is suposed to be a Governance Contract function burnRewardTokens() public onlyOwner { require(now.sub(lastBurnOrTokenDistributeTime) > burnOrDisburseTokensPeriod, "Recently executed, Please wait!"); IERC20(trustedRewardTokenAddress).safeTransfer(BURN_ADDRESS, tokensToBeDisbursedOrBurnt); tokensToBeDisbursedOrBurnt = 0; lastBurnOrTokenDistributeTime = now; } // get token amount which has a max price impact according to MAGIC_NUMBER for sells // !!IMPORTANT!! => Any functions using return value from this // MUST call `sync` on the pair before calling this function! function getMaxSwappableAmount() public view returns (uint) { uint tokensAvailable = IERC20(trustedRewardTokenAddress).balanceOf(trustedDepositTokenAddress); uint maxSwappableAmount = tokensAvailable.mul(MAGIC_NUMBER).div(1e18); return maxSwappableAmount; } // view function to calculate amount of DYP pending to be allocated since `lastDisburseTime` function getPendingDisbursement() public view returns (uint) { uint timeDiff; uint _now = now; uint _stakingEndTime = contractDeployTime.add(disburseDuration); if (_now > _stakingEndTime) { _now = _stakingEndTime; } if (lastDisburseTime >= _now) { timeDiff = 0; } else { timeDiff = _now.sub(lastDisburseTime); } uint pendingDisburse = disburseAmount .mul(disbursePercentX100) .mul(timeDiff) .div(disburseDuration) .div(10000); return pendingDisburse; } // view function to get depositors list function getDepositorsList(uint startIndex, uint endIndex) public view returns (address[] memory stakers, uint[] memory stakingTimestamps, uint[] memory lastClaimedTimeStamps, uint[] memory stakedTokens) { require (startIndex < endIndex); uint length = endIndex.sub(startIndex); address[] memory _stakers = new address[](length); uint[] memory _stakingTimestamps = new uint[](length); uint[] memory _lastClaimedTimeStamps = new uint[](length); uint[] memory _stakedTokens = new uint[](length); for (uint i = startIndex; i < endIndex; i = i.add(1)) { address staker = holders.at(i); uint listIndex = i.sub(startIndex); _stakers[listIndex] = staker; _stakingTimestamps[listIndex] = depositTime[staker]; _lastClaimedTimeStamps[listIndex] = lastClaimedTime[staker]; _stakedTokens[listIndex] = depositedTokens[staker]; } return (_stakers, _stakingTimestamps, _lastClaimedTimeStamps, _stakedTokens); } // admin can claim any tokens left in the contract after it expires or during emergency function claimAnyToken(address token, address recipient, uint amount) external onlyOwner { require(recipient != address(0), "Invalid Recipient"); require(now > adminClaimableTime, "Contract not expired yet!"); if (token == address(0)) { address payable _recipient = payable(recipient); _recipient.transfer(amount); return; } IERC20(token).safeTransfer(recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106104075760003560e01c80638b21990911610220578063c326bf4f11610130578063e3956a95116100b8578063f2fde38b11610087578063f2fde38b14610b05578063f3f91fa014610b2b578063f7e453b714610b51578063fccc281314610c09578063fe547f7214610c1157610407565b8063e3956a9514610a96578063e9dc18ec14610a9e578063efa9a9be14610ad4578063f1bab2ec14610afd57610407565b8063d140d6eb116100ff578063d140d6eb14610a1a578063d578ceab14610a58578063d7130e1414610a60578063dbcdc2cc14610a68578063e027c61f14610a8e57610407565b8063c326bf4f146109be578063c725e6d2146109e4578063ca7e083514610a0a578063ca9a213214610a1257610407565b8063a3c962c7116101b3578063ac51de8d11610182578063ac51de8d14610963578063b7ad18c41461096b578063b7d3786e14610973578063b9dffd3214610990578063c1665f40146109b657610407565b8063a3c962c714610893578063a6f5388c1461089b578063a891fa8914610953578063aabcad821461095b57610407565b80638f5705be116101ef5780638f5705be1461084057806398896d10146108485780639f54790d1461086e578063a1ccb8131461087657610407565b80638b219909146108025780638b7afe2e146108285780638da5cb5b146108305780638e20a1d91461083857610407565b8063452b4cfc1161031b57806358ee82fe116102ae5780636949b9d61161027d5780636949b9d6146107da578063765ae8bf146107e25780637a6eb0d0146107ea5780637e1c0c09146107f25780637e44b933146107fa57610407565b806358ee82fe1461077e578063596fa9e3146107a45780635f9e8f82146107ac5780636270cd18146107b457610407565b806349bd5a5e116102ea57806349bd5a5e146107495780634b62b70b146107515780634ca5610b1461076e57806358a3d9631461077657610407565b8063452b4cfc146106f6578063468b4d411461071357806346a28f631461071b57806346c648731461072357610407565b80632ba2ed981161039e57806331a5dda11161036d57806331a5dda1146106b057806331e244e5146106b85780633992fba5146106c05780633bed5043146106c857806344aa796a146106ee57610407565b80632ba2ed981461060b5780632e9f87a614610628578063307e52a71461066e578063308feec3146106a857610407565b80631cfa8021116103da5780631cfa80211461059c5780631f04461c146105c0578063271c23fa146105e65780632b4beea6146105ee57610407565b806305447d251461040c5780630c9a0c78146105525780630f1a64441461056c5780631419841d14610574575b600080fd5b61042f6004803603604081101561042257600080fd5b5080359060200135610c19565b6040518080602001806020018060200180602001858103855289818151815260200191508051906020019060200280838360005b8381101561047b578181015183820152602001610463565b50505050905001858103845288818151815260200191508051906020019060200280838360005b838110156104ba5781810151838201526020016104a2565b50505050905001858103835287818151815260200191508051906020019060200280838360005b838110156104f95781810151838201526020016104e1565b50505050905001858103825286818151815260200191508051906020019060200280838360005b83811015610538578181015183820152602001610520565b505050509050019850505050505050505060405180910390f35b61055a610e9d565b60408051918252519081900360200190f35b61055a610ea3565b61059a6004803603602081101561058a57600080fd5b50356001600160a01b0316610ea9565b005b6105a4610f7f565b604080516001600160a01b039092168252519081900360200190f35b61055a600480360360208110156105d657600080fd5b50356001600160a01b0316610f97565b61055a610fa9565b6105a46004803603602081101561060457600080fd5b5035610faf565b61059a6004803603602081101561062157600080fd5b5035610fd6565b61059a600480360360c081101561063e57600080fd5b508035906020810135906040810135906060810135906001600160a01b03608082013581169160a0013516611028565b6106946004803603602081101561068457600080fd5b50356001600160a01b031661107d565b604080519115158252519081900360200190f35b61055a611092565b6105a46110a3565b61059a6110b5565b61055a61117b565b61055a600480360360208110156106de57600080fd5b50356001600160a01b0316611181565b61055a61123f565b61059a6004803603602081101561070c57600080fd5b5035611246565b61055a611296565b61055a611355565b61055a6004803603602081101561073957600080fd5b50356001600160a01b031661135b565b6105a461136d565b61059a6004803603602081101561076757600080fd5b503561137c565b6105a461141e565b61055a611436565b61055a6004803603602081101561079457600080fd5b50356001600160a01b031661143c565b6105a461144e565b610694611462565b61055a600480360360208110156107ca57600080fd5b50356001600160a01b031661146b565b61055a61147d565b6105a4611483565b61055a61149b565b61055a6114a1565b61055a6114a7565b61055a6004803603602081101561081857600080fd5b50356001600160a01b03166114ad565b61055a6114bf565b6105a46114c5565b61055a6114d4565b61055a6114da565b61055a6004803603602081101561085e57600080fd5b50356001600160a01b03166114e2565b61055a611551565b61059a6004803603602081101561088c57600080fd5b5035611557565b6105a46115ee565b61059a600480360360808110156108b157600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b8111156108e057600080fd5b8201836020820111156108f257600080fd5b803590602001918460208302840111600160201b8311171561091357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250611606915050565b61055a6119eb565b61059a6119f2565b61055a611b4a565b61055a611be2565b61059a6004803603602081101561098957600080fd5b5035611be8565b61059a600480360360208110156109a657600080fd5b50356001600160a01b0316611c7f565b61055a611ce2565b61055a600480360360208110156109d457600080fd5b50356001600160a01b0316611ce8565b61059a600480360360208110156109fa57600080fd5b50356001600160a01b0316611cfa565b61055a611d5a565b61055a611d60565b61059a600480360360a0811015610a3057600080fd5b506001600160a01b038135169060208101359060408101359060608101359060800135611d67565b61055a611e8d565b61055a611e93565b61059a60048036036020811015610a7e57600080fd5b50356001600160a01b0316611e9b565b61055a611f5a565b61059a611f60565b61059a60048036036060811015610ab457600080fd5b506001600160a01b03813581169160208101359091169060400135612013565b61059a60048036036060811015610aea57600080fd5b508035906020810135906040013561213b565b6105a46121eb565b61059a60048036036020811015610b1b57600080fd5b50356001600160a01b03166121fa565b61055a60048036036020811015610b4157600080fd5b50356001600160a01b031661227f565b61059a60048036036080811015610b6757600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610b9657600080fd5b820183602082011115610ba857600080fd5b803590602001918460208302840111600160201b83111715610bc957600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250612291915050565b6105a46128be565b61055a6128c4565b606080606080848610610c2b57600080fd5b6000610c3d868863ffffffff61293516565b905060608167ffffffffffffffff81118015610c5857600080fd5b50604051908082528060200260200182016040528015610c82578160200160208202803683370190505b50905060608267ffffffffffffffff81118015610c9e57600080fd5b50604051908082528060200260200182016040528015610cc8578160200160208202803683370190505b50905060608367ffffffffffffffff81118015610ce457600080fd5b50604051908082528060200260200182016040528015610d0e578160200160208202803683370190505b50905060608467ffffffffffffffff81118015610d2a57600080fd5b50604051908082528060200260200182016040528015610d54578160200160208202803683370190505b5090508a5b8a811015610e8b576000610d7460118363ffffffff61297716565b90506000610d88838f63ffffffff61293516565b905081878281518110610d9757fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060146000836001600160a01b03166001600160a01b0316815260200190815260200160002054868281518110610de957fe5b60200260200101818152505060156000836001600160a01b03166001600160a01b0316815260200190815260200160002054858281518110610e2757fe5b60200260200101818152505060136000836001600160a01b03166001600160a01b0316815260200190815260200160002054848281518110610e6557fe5b602090810291909101015250610e84905081600163ffffffff6128d216565b9050610d59565b50929a91995097509095509350505050565b61271081565b60015481565b6000546001600160a01b03163314610ec057600080fd5b6001600160a01b038116610f1b576040805162461bcd60e51b815260206004820152601760248201527f496e76616c696420726f75746572206164647265737321000000000000000000604482015290519081900360640190fd5b600b80546001600160a01b03808416610100908102610100600160a81b03199093169290921792839055604080519290930416815290517f49381de8f56ca0c45bdd955e613a01e042fdf45d2ae4b0cfd920226fe0ed2ede9181900360200190a150565b737463286a379f6f128058bb92b355e3d6e8bdb21981565b60186020526000908152604090205481565b60095481565b600d8181548110610fbc57fe5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b03163314610fed57600080fd5b60048190556040805182815290517ffb06af695e3e2ab9f65ec2316a3cb72fd442f2288bb3bb1fa8f52cea13e446db9181900360200190a150565b6000546001600160a01b0316331461103f57600080fd5b61104886610fd6565b6110518561137c565b61105a84611be8565b61106383611557565b61106c82610ea9565b61107581611e9b565b505050505050565b60056020526000908152604090205460ff1681565b600061109e6011612983565b905090565b600080516020614f0083398151915281565b6000546001600160a01b031633146110cc57600080fd5b600b5460ff1615611112576040805162461bcd60e51b81526020600482018190526024820152600080516020614e6d833981519152604482015290519081900360640190fd5b600b805460ff19166001179055611132426203f48063ffffffff6128d216565b6007556000600181905554604080516001600160a01b039092168252517fe465b068e033879ed58088ba05882c35e2a52240ea1432b95753d6aebdd0814a9181900360200190a1565b60045481565b600061119460118363ffffffff61298e16565b6111a05750600061123a565b6001600160a01b0382166000908152601360205260409020546111c55750600061123a565b6001600160a01b038216600090815260196020526040812054601c546111f09163ffffffff61293516565b6001600160a01b038416600090815260136020526040812054919250611234670de0b6b3a7640000611228848663ffffffff6129a316565b9063ffffffff6129fc16565b93505050505b919050565b6201518081565b6000546001600160a01b0316331461125d57600080fd5b61127d600080516020614f0083398151915233308463ffffffff612a3e16565b601a54611290908263ffffffff6128d216565b601a5550565b604080516370a0823160e01b8152737463286a379f6f128058bb92b355e3d6e8bdb219600482015290516000918291600080516020614f00833981519152916370a08231916024808301926020929190829003018186803b1580156112fa57600080fd5b505afa15801561130e573d6000803e3d6000fd5b505050506040513d602081101561132457600080fd5b505160045490915060009061134e90670de0b6b3a76400009061122890859063ffffffff6129a316565b9250505090565b60105481565b60146020526000908152604090205481565b600c546001600160a01b031681565b6000546001600160a01b0316331461139357600080fd5b6276a7008111156113e3576040805162461bcd60e51b81526020600482015260156024820152744c6f636b75702074696d6520746f6f206c6f6e672160581b604482015290519081900360640190fd5b60018190556040805182815290517fadbac78f382a6f10bef84ad4b704cac4817788ffec4f83ac665d7a1152dc44729181900360200190a150565b730b92e7f074e7ade0181a29647ea8474522e6a7c281565b601f5481565b60176020526000908152604090205481565b600b5461010090046001600160a01b031681565b600b5460ff1681565b60166020526000908152604090205481565b600a5481565b73961c8c0b1aad0c0b10a51fef6a867e3091bcef1781565b601e5481565b601d5481565b60025481565b60196020526000908152604090205481565b601a5481565b6000546001600160a01b031681565b601b5481565b6301e1338081565b60006114f560118363ffffffff61298e16565b6115015750600061123a565b6001600160a01b0382166000908152601360205260409020546115265750600061123a565b6001600160a01b038216600090815260186020526040812054601b546111f09163ffffffff61293516565b60065481565b6000546001600160a01b0316331461156e57600080fd5b61271081106115b3576040805162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206665652160a01b604482015290519081900360640190fd5b60038190556040805182815290517f0a9e89cff3f9f01bd1c6aeb9b71324bb138123c40d02eb478613fb3427b231009181900360200190a150565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b61160f33612a9e565b15801561161b57503233145b611664576040805162461bcd60e51b81526020600482015260156024820152744e6f20436f6e74726163747320416c6c6f7765642160581b604482015290519081900360640190fd5b81516006146116b0576040805162461bcd60e51b8152602060048201526013602482015272496e76616c6964206d696e416d6f756e74732160681b604482015290519081900360640190fd5b6001600160a01b03841661170b576040805162461bcd60e51b815260206004820152601760248201527f496e76616c696420776974686472617720746f6b656e21000000000000000000604482015290519081900360640190fd5b6001600160a01b03841660009081526005602052604090205460ff16611778576040805162461bcd60e51b815260206004820152601b60248201527f576974686472617720746f6b656e206e6f742074727573746564210000000000604482015290519081900360640190fd5b600083116117cd576040805162461bcd60e51b815260206004820152601960248201527f43616e6e6f74207769746864726177203020546f6b656e732100000000000000604482015290519081900360640190fd5b33600090815260136020526040902054831115611831576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420616d6f756e7420746f207769746864726177000000000000604482015290519081900360640190fd5b6001543360009081526014602052604090205461185590429063ffffffff61293516565b116118915760405162461bcd60e51b8152600401808060200182810382526037815260200180614f206037913960400191505060405180910390fd5b6118c533836004815181106118a257fe5b6020026020010151846005815181106118b757fe5b602002602001015184612aa4565b60006118e2612710611228600354876129a390919063ffffffff16565b905060006118f6858363ffffffff61293516565b9050811561193057600e5461193090737463286a379f6f128058bb92b355e3d6e8bdb219906001600160a01b03168463ffffffff612ab316565b600061193e87838787612b05565b905061195a6001600160a01b038816338363ffffffff612ab316565b3360009081526013602052604090205461197a908763ffffffff61293516565b33600090815260136020526040902055601d5461199d908763ffffffff61293516565b601d556119b160113363ffffffff61298e16565b80156119ca575033600090815260136020526040902054155b156119e2576119e060113363ffffffff612f0c16565b505b50505050505050565b62093a8081565b6000546001600160a01b03163314611a0957600080fd5b62093a80611a22600a544261293590919063ffffffff16565b11611a74576040805162461bcd60e51b815260206004820152601f60248201527f526563656e746c792065786563757465642c20506c6561736520776169742100604482015290519081900360640190fd5b600c60009054906101000a90046001600160a01b03166001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611ac457600080fd5b505af1158015611ad8573d6000803e3d6000fd5b505050506000611ae6611296565b601e54909150600081831015611b0c57611b06828463ffffffff61293516565b90508291505b611b1582612f21565b8015611b3c57611b3c600080516020614f0083398151915261dead8363ffffffff612ab316565b50506000601e555042600a55565b600654600090819042908290611b6a906301e1338063ffffffff6128d216565b905080821115611b78578091505b8160085410611b8a5760009250611ba1565b600854611b9e90839063ffffffff61293516565b92505b6000611bd96127106112286301e133808188611bcd69d2e944a815d6268000008663ffffffff6129a316565b9063ffffffff6129a316565b94505050505090565b601c5481565b6000546001600160a01b03163314611bff57600080fd5b6127108110611c44576040805162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206665652160a01b604482015290519081900360640190fd5b60028190556040805182815290517f327680b8ba8221210809b2aae37f88a529ae9eec9a3a3fe952fe0a3a262b487f9181900360200190a150565b6000546001600160a01b03163314611c9657600080fd5b6001600160a01b038116600081815260056020526040808220805460ff19166001179055517f74bd711825aaf93834b0d2fb7bce500caae1be2723cbe48022e2584d6151e3329190a250565b60035481565b60136020526000908152604090205481565b6000546001600160a01b03163314611d1157600080fd5b6001600160a01b038116600081815260056020526040808220805460ff19169055517f091fc62f7712ef1aa0d7d7957476c0cf7e066e7cd795eae019e0f45f64ea00989190a250565b60075481565b6203f48081565b611d7033612a9e565b158015611d7c57503233145b611dc5576040805162461bcd60e51b81526020600482015260156024820152744e6f20436f6e74726163747320416c6c6f7765642160581b604482015290519081900360640190fd5b600b5460ff1615611e0b576040805162461bcd60e51b81526020600482018190526024820152600080516020614e6d833981519152604482015290519081900360640190fd5b6001600160a01b03851660009081526005602052604090205460ff16611e78576040805162461bcd60e51b815260206004820152601b60248201527f63616e6e6f7420636c61696d206173207468697320746f6b656e210000000000604482015290519081900360640190fd5b611e86338686868686612fe8565b5050505050565b600f5481565b630208c08081565b6000546001600160a01b03163314611eb257600080fd5b6001600160a01b038116611f00576040805162461bcd60e51b815260206004820152601060248201526f496e76616c696420616464726573732160801b604482015290519081900360640190fd5b600e80546001600160a01b0319166001600160a01b03838116919091179182905560408051929091168252517fafc54c644914e872610dbc4334999d957d145108fd88d63d83cc3a710dc6ee71916020908290030190a150565b60085481565b6000546001600160a01b03163314611f7757600080fd5b62093a80611f90600a544261293590919063ffffffff16565b11611fe2576040805162461bcd60e51b815260206004820152601f60248201527f526563656e746c792065786563757465642c20506c6561736520776169742100604482015290519081900360640190fd5b601e5461200890600080516020614f008339815191529061dead9063ffffffff612ab316565b6000601e5542600a55565b6000546001600160a01b0316331461202a57600080fd5b6001600160a01b038216612079576040805162461bcd60e51b8152602060048201526011602482015270125b9d985b1a5908149958da5c1a595b9d607a1b604482015290519081900360640190fd5b60075442116120cf576040805162461bcd60e51b815260206004820152601960248201527f436f6e7472616374206e6f742065787069726564207965742100000000000000604482015290519081900360640190fd5b6001600160a01b03831661211c5760405182906001600160a01b0382169083156108fc029084906000818181858888f19350505050158015612115573d6000803e3d6000fd5b5050612136565b6121366001600160a01b038416838363ffffffff612ab316565b505050565b61214433612a9e565b15801561215057503233145b612199576040805162461bcd60e51b81526020600482015260156024820152744e6f20436f6e74726163747320416c6c6f7765642160581b604482015290519081900360640190fd5b600b5460ff16156121df576040805162461bcd60e51b81526020600482018190526024820152600080516020614e6d833981519152604482015290519081900360640190fd5b61213633848484612aa4565b600e546001600160a01b031681565b6000546001600160a01b0316331461221157600080fd5b6001600160a01b03811661222457600080fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60156020526000908152604090205481565b61229a33612a9e565b1580156122a657503233145b6122ef576040805162461bcd60e51b81526020600482015260156024820152744e6f20436f6e74726163747320416c6c6f7765642160581b604482015290519081900360640190fd5b600b5460ff1615612335576040805162461bcd60e51b81526020600482018190526024820152600080516020614e6d833981519152604482015290519081900360640190fd5b815160081461238b576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c6964206d696e416d6f756e7473206c656e67746821000000000000604482015290519081900360640190fd5b6001600160a01b03841660009081526005602052604090205460ff166123f1576040805162461bcd60e51b8152602060048201526016602482015275496e76616c6964206465706f73697420746f6b656e2160501b604482015290519081900360640190fd5b6001600160a01b038416737463286a379f6f128058bb92b355e3d6e8bdb2191415612463576040805162461bcd60e51b815260206004820152601b60248201527f43616e6e6f74206465706f736974204c50206469726563746c79210000000000604482015290519081900360640190fd5b6001600160a01b0384166124be576040805162461bcd60e51b815260206004820152601a60248201527f4465706f73697420746f6b656e2063616e6e6f74206265203021000000000000604482015290519081900360640190fd5b60008311612513576040805162461bcd60e51b815260206004820152601860248201527f496e76616c696420616d6f756e7420746f205374616b65210000000000000000604482015290519081900360640190fd5b61252e6001600160a01b03851633308663ffffffff612a3e16565b600061254b612710611228600254876129a390919063ffffffff16565b9050600061255f858363ffffffff61293516565b9050811561258757600e54612587906001600160a01b0388811691168463ffffffff612ab316565b60006125a161271061122884611d4c63ffffffff6129a316565b905060006125b5838363ffffffff61293516565b905060006125ee8973961c8c0b1aad0c0b10a51fef6a867e3091bcef17848a6000815181106125e057fe5b60200260200101518a613758565b905061262a73961c8c0b1aad0c0b10a51fef6a867e3091bcef17730b92e7f074e7ade0181a29647ea8474522e6a7c2600063ffffffff613d1216565b61266373961c8c0b1aad0c0b10a51fef6a867e3091bcef17730b92e7f074e7ade0181a29647ea8474522e6a7c28363ffffffff613d1216565b730b92e7f074e7ade0181a29647ea8474522e6a7c26001600160a01b03166355468afa33838a60018151811061269557fe5b60200260200101518a6040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b03168152602001848152602001838152602001828152602001945050505050600060405180830381600087803b1580156126fb57600080fd5b505af115801561270f573d6000803e3d6000fd5b5050505060006127296002856129fc90919063ffffffff16565b9050600061273d858363ffffffff61293516565b905060006127708c600080516020614f00833981519152858d60048151811061276257fe5b60200260200101518d613758565b905060006127a98d73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2858e60058151811061279b57fe5b60200260200101518e613758565b905060006127b983838e8e613e25565b905060008111612810576040805162461bcd60e51b815260206004820152601760248201527f43616e6e6f74206465706f736974203020546f6b656e73000000000000000000604482015290519081900360640190fd5b612844338d60068151811061282157fe5b60200260200101518e60078151811061283657fe5b60200260200101518e612aa4565b33600090815260136020526040902054612864908263ffffffff6128d216565b33600090815260136020526040902055601d54612887908263ffffffff6128d216565b601d5561289b60113363ffffffff6141c816565b505033600090815260146020526040902042905550505050505050505050505050565b61dead81565b69d2e944a815d62680000081565b60008282018381101561292c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600061292c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506141dd565b600061292c8383614279565b600061292f826142dd565b600061292c836001600160a01b0384166142e1565b6000826129b25750600061292f565b828202828482816129bf57fe5b041461292c5760405162461bcd60e51b8152600401808060200182810382526021815260200180614eb76021913960400191505060405180910390fd5b600061292c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506142f9565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052612a9890859061435e565b50505050565b3b151590565b612a9884600080868686612fe8565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261213690849061435e565b600b54600090612b3990737463286a379f6f128058bb92b355e3d6e8bdb2199061010090046001600160a01b031683613d12565b600b54612b6a90737463286a379f6f128058bb92b355e3d6e8bdb2199061010090046001600160a01b031686613d12565b604080516370a0823160e01b81523060048201529051600091600080516020614f00833981519152916370a0823191602480820192602092909190829003018186803b158015612bb957600080fd5b505afa158015612bcd573d6000803e3d6000fd5b505050506040513d6020811015612be357600080fd5b5051604080516370a0823160e01b8152306004820152905191925060009173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2916370a08231916024808301926020929190829003018186803b158015612c3c57600080fd5b505afa158015612c50573d6000803e3d6000fd5b505050506040513d6020811015612c6657600080fd5b5051600b54865191925061010090046001600160a01b03169063baa2abde90600080516020614f008339815191529073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2908a908a90600090612cb857fe5b60200260200101518a600181518110612ccd57fe5b6020908102919091010151604080516001600160e01b031960e089901b1681526001600160a01b0396871660048201529490951660248501526044840192909252606483015260848201523060a482015260c48101889052815160e480830193928290030181600087803b158015612d4457600080fd5b505af1158015612d58573d6000803e3d6000fd5b505050506040513d6040811015612d6e57600080fd5b5050604080516370a0823160e01b81523060048201529051600091600080516020614f00833981519152916370a0823191602480820192602092909190829003018186803b158015612dbf57600080fd5b505afa158015612dd3573d6000803e3d6000fd5b505050506040513d6020811015612de957600080fd5b5051604080516370a0823160e01b8152306004820152905191925060009173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2916370a08231916024808301926020929190829003018186803b158015612e4257600080fd5b505afa158015612e56573d6000803e3d6000fd5b505050506040513d6020811015612e6c57600080fd5b505190506000612e82838663ffffffff61293516565b90506000612e96838663ffffffff61293516565b90506000612ebb600080516020614f008339815191528d858d60028151811061276257fe5b90506000612ee673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28e858e60038151811061279b57fe5b90506000612efa838363ffffffff6128d216565b9e9d5050505050505050505050505050565b600061292c836001600160a01b03841661440f565b600081118015612f3357506000601d54115b612f7d576040805162461bcd60e51b81526020600482015260166024820152756469737472696275746544697673206661696c65642160501b604482015290519081900360640190fd5b601d54612faf90612fa09061122884670de0b6b3a764000063ffffffff6129a316565b601b549063ffffffff6128d216565b601b556040805182815290517f497e6c34cb46390a801e970e8c72fd87aa7fded87c9b77cdac588f235904a8259181900360200190a150565b612ff06144d5565b612ffa828261453c565b6000613005876114e2565b90508015613158576000806001600160a01b038816158061304257506001600160a01b03881673961c8c0b1aad0c0b10a51fef6a867e3091bcef17145b1561307f575073961c8c0b1aad0c0b10a51fef6a867e3091bcef17613078600080516020614f0083398151915282858988613758565b915061309f565b508661309c600080516020614f0083398151915282858988613758565b91505b6130b96001600160a01b0382168a8463ffffffff612ab316565b6001600160a01b0389166000908152601660205260409020546130e2908463ffffffff6128d216565b6001600160a01b038a16600090815260166020526040902055600f5461310e908463ffffffff6128d216565b600f55604080516001600160a01b038b1681526020810185905281517f586b2e63a21a7a4e1402e36f48ce10cb1ec94684fea254c186b76d1f98ecf130929181900390910190a150505b600061316388611181565b90508015613719576001600160a01b03871615806132055750600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156131ca57600080fd5b505afa1580156131de573d6000803e3d6000fd5b505050506040513d60208110156131f457600080fd5b50516001600160a01b038881169116145b156132a45761329f8882600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561325d57600080fd5b505afa158015613271573d6000803e3d6000fd5b505050506040513d602081101561328757600080fd5b50516001600160a01b0316919063ffffffff612ab316565b61367c565b6001600160a01b03871660009081526005602052604090205460ff16613311576040805162461bcd60e51b815260206004820152601b60248201527f63616e6e6f7420636c61696d206173207468697320746f6b656e210000000000604482015290519081900360640190fd5b600b54604080516315ab88c960e31b815290516133a39261010090046001600160a01b031691600091839163ad5c4648916004808301926020929190829003018186803b15801561336157600080fd5b505afa158015613375573d6000803e3d6000fd5b505050506040513d602081101561338b57600080fd5b50516001600160a01b0316919063ffffffff613d1216565b600b54604080516315ab88c960e31b815290516133f29261010090046001600160a01b0316918491839163ad5c4648916004808301926020929190829003018186803b15801561336157600080fd5b6040805160028082526060808301845292602083019080368337019050509050600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561346057600080fd5b505afa158015613474573d6000803e3d6000fd5b505050506040513d602081101561348a57600080fd5b50518151829060009061349957fe5b60200260200101906001600160a01b031690816001600160a01b03168152505087816001815181106134c757fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600b60019054906101000a90046001600160a01b03166001600160a01b03166338ed17398389848d896040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613589578181015183820152602001613571565b505050509050019650505050505050600060405180830381600087803b1580156135b257600080fd5b505af11580156135c6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156135ef57600080fd5b8101908080516040519392919084600160201b82111561360e57600080fd5b90830190602082018581111561362357600080fd5b82518660208202830111600160201b8211171561363f57600080fd5b82525081516020918201928201910280838360005b8381101561366c578181015183820152602001613654565b5050505090500160405250505050505b6001600160a01b0388166000908152601760205260409020546136a5908263ffffffff6128d216565b6001600160a01b0389166000908152601760205260409020556010546136d1908263ffffffff6128d216565b601055604080516001600160a01b038a1681526020810183905281517ff17669744a2126d947b5b82df9711ffdcc0fcea345193964bf642c98e1563b99929181900390910190a15b5050506001600160a01b039094166000908152601560209081526040808320429055601b546018835281842055601c5460199092529091205550505050565b6000846001600160a01b0316866001600160a01b0316141561377b575082613d09565b600b546137a1906001600160a01b0388811691610100900416600063ffffffff613d1216565b600b546137c6906001600160a01b03888116916101009004168663ffffffff613d1216565b604080516370a0823160e01b815230600482015290516000916001600160a01b038816916370a0823191602480820192602092909190829003018186803b15801561381057600080fd5b505afa158015613824573d6000803e3d6000fd5b505050506040513d602081101561383a57600080fd5b5051600b54604080516315ab88c960e31b815290519293506060926101009092046001600160a01b03169163ad5c464891600480820192602092909190829003018186803b15801561388b57600080fd5b505afa15801561389f573d6000803e3d6000fd5b505050506040513d60208110156138b557600080fd5b50516001600160a01b03898116911614806139545750600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561391957600080fd5b505afa15801561392d573d6000803e3d6000fd5b505050506040513d602081101561394357600080fd5b50516001600160a01b038881169116145b156139da576040805160028082526060820183529091602083019080368337019050509050878160008151811061398757fe5b60200260200101906001600160a01b031690816001600160a01b03168152505086816001815181106139b557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050613b01565b6040805160038082526080820190925290602082016060803683370190505090508781600081518110613a0957fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015613a7757600080fd5b505afa158015613a8b573d6000803e3d6000fd5b505050506040513d6020811015613aa157600080fd5b5051815182906001908110613ab257fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508681600281518110613ae057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505b600b546040516338ed173960e01b8152600481018881526024820188905230606483018190526084830188905260a060448401908152855160a485015285516101009095046001600160a01b0316946338ed1739948c948c94899490938d9360c401906020878101910280838360005b83811015613b89578181015183820152602001613b71565b505050509050019650505050505050600060405180830381600087803b158015613bb257600080fd5b505af1158015613bc6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015613bef57600080fd5b8101908080516040519392919084600160201b821115613c0e57600080fd5b908301906020820185811115613c2357600080fd5b82518660208202830111600160201b82111715613c3f57600080fd5b82525081516020918201928201910280838360005b83811015613c6c578181015183820152602001613c54565b505050509190910160408181526370a0823160e01b825230600483015251600096506001600160a01b038e1695506370a08231945060248083019450602093509091829003018186803b158015613cc257600080fd5b505afa158015613cd6573d6000803e3d6000fd5b505050506040513d6020811015613cec57600080fd5b505190506000613d02828563ffffffff61293516565b9450505050505b95945050505050565b801580613d98575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015613d6a57600080fd5b505afa158015613d7e573d6000803e3d6000fd5b505050506040513d6020811015613d9457600080fd5b5051155b613dd35760405162461bcd60e51b8152600401808060200182810382526036815260200180614f816036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261213690849061435e565b600082600281518110613e3457fe5b6020026020010151851015613e7a5760405162461bcd60e51b815260040180806020018281038252602a815260200180614e8d602a913960400191505060405180910390fd5b82600381518110613e8757fe5b6020026020010151841015613ecd5760405162461bcd60e51b8152600401808060200182810382526028815260200180614ed86028913960400191505060405180910390fd5b604080516370a0823160e01b81523060048201529051600091737463286a379f6f128058bb92b355e3d6e8bdb219916370a0823191602480820192602092909190829003018186803b158015613f2257600080fd5b505afa158015613f36573d6000803e3d6000fd5b505050506040513d6020811015613f4c57600080fd5b5051600b54909150613f7d90600080516020614f008339815191529061010090046001600160a01b03166000613d12565b600b54613fa890600080516020614f008339815191529061010090046001600160a01b031688613d12565b600b54613fda9073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29061010090046001600160a01b03166000613d12565b600b5461400b9073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29061010090046001600160a01b031687613d12565b600b60019054906101000a90046001600160a01b03166001600160a01b031663e8e33700600080516020614f0083398151915273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc289898960028151811061406257fe5b60200260200101518a60038151811061407757fe5b6020908102919091010151604080516001600160e01b031960e08a901b1681526001600160a01b03978816600482015295909616602486015260448501939093526064840191909152608483015260a48201523060c482015260e4810187905290516101048083019260609291908290030181600087803b1580156140fb57600080fd5b505af115801561410f573d6000803e3d6000fd5b505050506040513d606081101561412557600080fd5b5050604080516370a0823160e01b81523060048201529051600091737463286a379f6f128058bb92b355e3d6e8bdb219916370a0823191602480820192602092909190829003018186803b15801561417c57600080fd5b505afa158015614190573d6000803e3d6000fd5b505050506040513d60208110156141a657600080fd5b5051905060006141bc828463ffffffff61293516565b98975050505050505050565b600061292c836001600160a01b038416614b33565b6000818484111561426c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614231578181015183820152602001614219565b50505050905090810190601f16801561425e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50508183035b9392505050565b815460009082106142bb5760405162461bcd60e51b8152600401808060200182810382526022815260200180614e256022913960400191505060405180910390fd5b8260000182815481106142ca57fe5b9060005260206000200154905092915050565b5490565b60009081526001919091016020526040902054151590565b600081836143485760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614231578181015183820152602001614219565b50600083858161435457fe5b0495945050505050565b60606143b3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614b7d9092919063ffffffff16565b805190915015612136578080602001905160208110156143d257600080fd5b50516121365760405162461bcd60e51b815260040180806020018281038252602a815260200180614f57602a913960400191505060405180910390fd5b600081815260018301602052604081205480156144cb578354600019808301919081019060009087908390811061444257fe5b906000526020600020015490508087600001848154811061445f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061448f57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061292f565b600091505061292f565b60006144df611b4a565b905080601a5410156144f05750601a545b8015806144fd5750601d54155b15614508575061453a565b601f5461451b908263ffffffff6128d216565b601f55601a54614531908263ffffffff61293516565b601a5550426008555b565b601d5461454857614b2f565b620151806145616009544261293590919063ffffffff16565b101561456c57614b2f565b600c60009054906101000a90046001600160a01b03166001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156145bc57600080fd5b505af11580156145d0573d6000803e3d6000fd5b5050505060006145ed601e54601f546128d290919063ffffffff16565b905060006145f9611296565b905080614607575050614b2f565b601f5481101561466157601f54600090614627908363ffffffff61293516565b601f5490915061463d908263ffffffff61293516565b601e54909350614653908263ffffffff6128d216565b601e55506000601f556146aa565b8181101561469f57600061467b838363ffffffff61293516565b905061468d838263ffffffff61293516565b601e919091556000601f5591506146aa565b6000601f819055601e555b816146b6575050614b2f565b604080516370a0823160e01b815230600482015290518391600080516020614f00833981519152916370a0823191602480820192602092909190829003018186803b15801561470457600080fd5b505afa158015614718573d6000803e3d6000fd5b505050506040513d602081101561472e57600080fd5b5051101561473d575050614b2f565b600b5461476990600080516020614f008339815191529061010090046001600160a01b03166000613d12565b600b5461479490600080516020614f008339815191529061010090046001600160a01b031684613d12565b6000600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156147e457600080fd5b505afa1580156147f8573d6000803e3d6000fd5b505050506040513d602081101561480e57600080fd5b5051604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561485857600080fd5b505afa15801561486c573d6000803e3d6000fd5b505050506040513d602081101561488257600080fd5b5051600b546040516338ed173960e01b8152600481018681526024820189905230606483018190526084830189905260a060448401908152600d805460a486018190529697506101009095046001600160a01b0316956338ed1739958a958d959194938d93909160c401908690801561492457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311614906575b50509650505050505050600060405180830381600087803b15801561494857600080fd5b505af115801561495c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561498557600080fd5b8101908080516040519392919084600160201b8211156149a457600080fd5b9083019060208201858111156149b957600080fd5b82518660208202830111600160201b821117156149d557600080fd5b82525081516020918201928201910280838360005b83811015614a025781810151838201526020016149ea565b50505050905001604052505050506000600b60019054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015614a6057600080fd5b505afa158015614a74573d6000803e3d6000fd5b505050506040513d6020811015614a8a57600080fd5b5051604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015614ad457600080fd5b505afa158015614ae8573d6000803e3d6000fd5b505050506040513d6020811015614afe57600080fd5b505190506000614b14828463ffffffff61293516565b90508015614b2557614b2581614b94565b5050426009555050505b5050565b6000614b3f83836142e1565b614b755750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561292f565b50600061292f565b6060614b8c8484600085614c62565b949350505050565b600081118015614ba657506000601d54115b614bf7576040805162461bcd60e51b815260206004820152601960248201527f6469737472696275746544697673457468206661696c65642100000000000000604482015290519081900360640190fd5b601d54614c2990614c1a9061122884670de0b6b3a764000063ffffffff6129a316565b601c549063ffffffff6128d216565b601c556040805182815290517f56ce0eae0b79fabf707cf07252ae767ac575085fbf32b98546f8f0f01725b9749181900360200190a150565b606082471015614ca35760405162461bcd60e51b8152600401808060200182810382526026815260200180614e476026913960400191505060405180910390fd5b614cac85612a9e565b614cfd576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614d3c5780518252601f199092019160209182019101614d1d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614d9e576040519150601f19603f3d011682016040523d82523d6000602084013e614da3565b606091505b5091509150614db3828286614dbe565b979650505050505050565b60608315614dcd575081614272565b825115614ddd5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561423157818101518382015260200161421956fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c43616e6e6f74206578656375746520647572696e6720656d657267656e63792152657761726420546f6b656e205265636569766564206c6f776572207468616e20657870656374656421536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774261736520546f6b656e205265636569766564206c6f776572207468616e20657870656374656421000000000000000000000000bd100d061e120b2c67a24453cf6368e63f1be056596f7520726563656e746c79206465706f73697465642c20706c656173652077616974206265666f7265207769746864726177696e672e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212206935fec14b3e68ec1c1849d5fd5b5c0c283a0c7b43f0d27eca09541f7a55fef364736f6c634300060b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2683, 2278, 2549, 2094, 2581, 21057, 2581, 2278, 23499, 2487, 2063, 28154, 2546, 14526, 16409, 2094, 16048, 2050, 19481, 2581, 23833, 2620, 26224, 15136, 2509, 2497, 2509, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2340, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 18667, 2094, 1011, 1017, 1011, 11075, 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,968
0x97a9ebD15ec0C8528616e38Ea14FF14aE57Ae651
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.4; import {ERC20} from "ERC20.sol"; import {SafeTransferLib} from "SafeTransferLib.sol"; import {Ownable} from "Ownable.sol"; import {FullMath} from "FullMath.sol"; import {ERC20 as CloneERC20} from "ERC20.sol"; /// @title xERC20 /// @author zefram.eth /// @notice A special type of ERC20 staking pool where the reward token is the same as /// the stake token. This enables stakers to receive an xERC20 token representing their /// stake that can then be transferred or plugged into other things (e.g. Uniswap). /// @dev xERC20 is inspired by xSUSHI, but is superior because rewards are distributed over time rather /// than immediately, which prevents MEV bots from stealing the rewards or malicious users staking immediately /// before the reward distribution and unstaking immediately after. contract xERC20 is CloneERC20, Ownable { /// ----------------------------------------------------------------------- /// Library usage /// ----------------------------------------------------------------------- using SafeTransferLib for ERC20; /// ----------------------------------------------------------------------- /// Errors /// ----------------------------------------------------------------------- error Error_ZeroOwner(); error Error_AlreadyInitialized(); error Error_NotRewardDistributor(); error Error_ZeroSupply(); /// ----------------------------------------------------------------------- /// Events /// ----------------------------------------------------------------------- event RewardAdded(uint128 reward); event Staked( address indexed user, uint256 stakeTokenAmount, uint256 xERC20Amount ); event Withdrawn( address indexed user, uint256 stakeTokenAmount, uint256 xERC20Amount ); /// ----------------------------------------------------------------------- /// Constants /// ----------------------------------------------------------------------- uint256 internal constant PRECISION = 1e18; /// ----------------------------------------------------------------------- /// Storage variables /// ----------------------------------------------------------------------- uint64 public currentUnlockEndTimestamp; uint64 public lastRewardTimestamp; uint128 public lastRewardAmount; /// @notice Tracks if an address can call notifyReward() mapping(address => bool) public isRewardDistributor; /// ----------------------------------------------------------------------- /// Immutable parameters /// ----------------------------------------------------------------------- /// @notice The token being staked in the pool function stakeToken() public pure returns (ERC20) { return ERC20(_getArgAddress(0x41)); } /// @notice The length of each reward period, in seconds function DURATION() public pure returns (uint64) { return _getArgUint64(0x55); } /// ----------------------------------------------------------------------- /// Initialization /// ----------------------------------------------------------------------- /// @notice Initializes the owner, called by StakingPoolFactory /// @param initialOwner The initial owner of the contract function initialize(address initialOwner) external { if (owner() != address(0)) { revert Error_AlreadyInitialized(); } if (initialOwner == address(0)) { revert Error_ZeroOwner(); } _transferOwnership(initialOwner); } /// ----------------------------------------------------------------------- /// User actions /// ----------------------------------------------------------------------- /// @notice Stake tokens to receive xERC20 tokens /// @param stakeTokenAmount The amount of tokens to stake /// @return xERC20Amount The amount of xERC20 tokens minted function stake(uint256 stakeTokenAmount) external virtual returns (uint256 xERC20Amount) { /// ----------------------------------------------------------------------- /// Validation /// ----------------------------------------------------------------------- if (stakeTokenAmount == 0) { return 0; } /// ----------------------------------------------------------------------- /// State updates /// ----------------------------------------------------------------------- xERC20Amount = FullMath.mulDiv( stakeTokenAmount, PRECISION, getPricePerFullShare() ); _mint(msg.sender, xERC20Amount); /// ----------------------------------------------------------------------- /// Effects /// ----------------------------------------------------------------------- stakeToken().safeTransferFrom( msg.sender, address(this), stakeTokenAmount ); emit Staked(msg.sender, stakeTokenAmount, xERC20Amount); } /// @notice Withdraw tokens by burning xERC20 tokens /// @param xERC20Amount The amount of xERC20 to burn /// @return stakeTokenAmount The amount of staked tokens withdrawn function withdraw(uint256 xERC20Amount) external virtual returns (uint256 stakeTokenAmount) { /// ----------------------------------------------------------------------- /// Validation /// ----------------------------------------------------------------------- if (xERC20Amount == 0) { return 0; } /// ----------------------------------------------------------------------- /// State updates /// ----------------------------------------------------------------------- stakeTokenAmount = FullMath.mulDiv( xERC20Amount, getPricePerFullShare(), PRECISION ); _burn(msg.sender, xERC20Amount); /// ----------------------------------------------------------------------- /// Effects /// ----------------------------------------------------------------------- stakeToken().safeTransfer(msg.sender, stakeTokenAmount); emit Withdrawn(msg.sender, stakeTokenAmount, xERC20Amount); } /// ----------------------------------------------------------------------- /// Getters /// ----------------------------------------------------------------------- /// @notice Compute the amount of staked tokens that can be withdrawn by burning /// 1 xERC20 token. Increases linearly during a reward distribution period. /// @dev Initialized to be PRECISION (representing 1:1) /// @return The amount of staked tokens that can be withdrawn by burning /// 1 xERC20 token function getPricePerFullShare() public view returns (uint256) { uint256 totalShares = totalSupply; uint256 stakeTokenBalance = stakeToken().balanceOf(address(this)); if (totalShares == 0 || stakeTokenBalance == 0) { return PRECISION; } uint256 lastRewardAmount_ = lastRewardAmount; uint256 currentUnlockEndTimestamp_ = currentUnlockEndTimestamp; if ( lastRewardAmount_ == 0 || block.timestamp >= currentUnlockEndTimestamp_ ) { // no rewards or rewards fully unlocked // entire balance is withdrawable return FullMath.mulDiv(stakeTokenBalance, PRECISION, totalShares); } else { // rewards not fully unlocked // deduct locked rewards from balance uint256 lastRewardTimestamp_ = lastRewardTimestamp; // can't overflow since lockedRewardAmount < lastRewardAmount uint256 lockedRewardAmount = (lastRewardAmount_ * (currentUnlockEndTimestamp_ - block.timestamp)) / (currentUnlockEndTimestamp_ - lastRewardTimestamp_); return FullMath.mulDiv( stakeTokenBalance - lockedRewardAmount, PRECISION, totalShares ); } } /// ----------------------------------------------------------------------- /// Owner actions /// ----------------------------------------------------------------------- /// @notice Distributes rewards to xERC20 holders /// @dev When not in a distribution period, start a new one with rewardUnlockPeriod seconds. /// When in a distribution period, add rewards to current period. function distributeReward(uint128 rewardAmount) external { /// ----------------------------------------------------------------------- /// Validation /// ----------------------------------------------------------------------- if (totalSupply == 0) { revert Error_ZeroSupply(); } if (!isRewardDistributor[msg.sender]) { revert Error_NotRewardDistributor(); } /// ----------------------------------------------------------------------- /// Storage loads /// ----------------------------------------------------------------------- uint256 currentUnlockEndTimestamp_ = currentUnlockEndTimestamp; /// ----------------------------------------------------------------------- /// State updates /// ----------------------------------------------------------------------- if (block.timestamp >= currentUnlockEndTimestamp_) { // start new reward period currentUnlockEndTimestamp = uint64(block.timestamp + DURATION()); lastRewardAmount = rewardAmount; } else { // add rewards to current reward period // can't overflow since lockedRewardAmount < lastRewardAmount uint256 lockedRewardAmount = (lastRewardAmount * (currentUnlockEndTimestamp_ - block.timestamp)) / (currentUnlockEndTimestamp_ - lastRewardTimestamp); // will revert if lastRewardAmount overflows lastRewardAmount = uint128(rewardAmount + lockedRewardAmount); } lastRewardTimestamp = uint64(block.timestamp); /// ----------------------------------------------------------------------- /// Effects /// ----------------------------------------------------------------------- stakeToken().safeTransferFrom(msg.sender, address(this), rewardAmount); emit RewardAdded(rewardAmount); } /// @notice Lets the owner add/remove accounts from the list of reward distributors. /// Reward distributors can call notifyRewardAmount() /// @param rewardDistributor The account to add/remove /// @param isRewardDistributor_ True to add the account, false to remove the account function setRewardDistributor( address rewardDistributor, bool isRewardDistributor_ ) external onlyOwner { isRewardDistributor[rewardDistributor] = isRewardDistributor_; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {Clone} from "Clone.sol"; /// @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 is Clone { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval( address indexed owner, address indexed spender, uint256 amount ); /*/////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*/////////////////////////////////////////////////////////////// METADATA //////////////////////////////////////////////////////////////*/ function name() external pure returns (string memory) { return string(abi.encodePacked(_getArgUint256(0))); } function symbol() external pure returns (string memory) { return string(abi.encodePacked(_getArgUint256(0x20))); } function decimals() external pure returns (uint8) { return _getArgUint8(0x40); } /*/////////////////////////////////////////////////////////////// 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; } /*/////////////////////////////////////////////////////////////// INTERNAL 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); } function _getImmutableVariablesOffset() internal pure returns (uint256 offset) { assembly { offset := sub( calldatasize(), add(shr(240, calldataload(sub(calldatasize(), 2))), 2) ) } } } // SPDX-License-Identifier: BSD pragma solidity ^0.8.4; /// @title Clone /// @author zefram.eth /// @notice Provides helper functions for reading immutable args from calldata contract Clone { /// @notice Reads an immutable arg with type address /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgAddress(uint256 argOffset) internal pure returns (address arg) { uint256 offset = _getImmutableArgsOffset(); assembly { arg := shr(0x60, calldataload(add(offset, argOffset))) } } /// @notice Reads an immutable arg with type uint256 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint256(uint256 argOffset) internal pure returns (uint256 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := calldataload(add(offset, argOffset)) } } /// @notice Reads an immutable arg with type uint64 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint64(uint256 argOffset) internal pure returns (uint64 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := shr(0xc0, calldataload(add(offset, argOffset))) } } /// @notice Reads an immutable arg with type uint8 /// @param argOffset The offset of the arg in the packed data /// @return arg The arg value function _getArgUint8(uint256 argOffset) internal pure returns (uint8 arg) { uint256 offset = _getImmutableArgsOffset(); // solhint-disable-next-line no-inline-assembly assembly { arg := shr(0xf8, calldataload(add(offset, argOffset))) } } /// @return offset The offset of the packed immutable args in calldata function _getImmutableArgsOffset() internal pure returns (uint256 offset) { // solhint-disable-next-line no-inline-assembly assembly { offset := sub( calldatasize(), add(shr(240, calldataload(sub(calldatasize(), 2))), 2) ) } } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "ERC20.sol"; /// @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) /// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.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 { /*/////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool callStatus; assembly { // Transfer the ETH and store if it succeeded or not. callStatus := call(gas(), to, amount, 0, 0, 0, 0) } require(callStatus, "ETH_TRANSFER_FAILED"); } /*/////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore( freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000 ) // Begin with the function selector. mstore( add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff) ) // Mask and append the "from" argument. mstore( add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff) ) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 100 because the calldata length is 4 + 32 * 3. callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0) } require( didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED" ); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore( freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000 ) // Begin with the function selector. mstore( add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff) ) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require( didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FAILED" ); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore( freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000 ) // Begin with the function selector. mstore( add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff) ) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED"); } /*/////////////////////////////////////////////////////////////// INTERNAL HELPER LOGIC //////////////////////////////////////////////////////////////*/ function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) { assembly { // Get how many bytes the call returned. let returnDataSize := returndatasize() // If the call reverted: if iszero(callStatus) { // Copy the revert message into memory. returndatacopy(0, 0, returnDataSize) // Revert with the same message. revert(0, returnDataSize) } switch returnDataSize case 32 { // Copy the return data into memory. returndatacopy(0, 0, returnDataSize) // Set success to whether it returned true. success := iszero(iszero(mload(0))) } case 0 { // There was no return data. success := 1 } default { // It returned some malformed input. success := 0 } } } } // SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.4; abstract contract Ownable { error Ownable_NotOwner(); error Ownable_NewOwnerZeroAddress(); address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /// @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() { if (owner() != msg.sender) revert Ownable_NotOwner(); _; } /// @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 { if (newOwner == address(0)) revert Ownable_NewOwnerZeroAddress(); _transferOwnership(newOwner); } /// @dev Transfers ownership of the contract to a new account (`newOwner`). /// Internal function without access restriction. function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (type(uint256).max - denominator + 1) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); unchecked { if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806377c7b8fc116100c3578063a9059cbb1161007c578063a9059cbb146102e5578063bafedcaa146102f8578063c4d66de81461032a578063dd62ed3e1461033d578063f2fde38b14610368578063f8077fae1461037b57600080fd5b806377c7b8fc1461028957806380e59f8d146102915780638da5cb5b146102a657806395d89b41146102b7578063a20e165c146102bf578063a694fc3a146102d257600080fd5b806323b872dd1161011557806323b872dd146101ee5780632e1a7d4d14610201578063313ce5671461021457806351ed6a301461022e57806370a082311461024e578063722c2fff1461026e57600080fd5b806306fdde0314610152578063095ea7b31461017057806316ed85251461019357806318160ddd146101b65780631be05289146101cd575b600080fd5b61015a61038f565b6040516101679190610ebf565b60405180910390f35b61018361017e366004610f30565b6103c1565b6040519015158152602001610167565b6101836101a1366004610f5a565b60056020526000908152604090205460ff1681565b6101bf60005481565b604051908152602001610167565b6101d561042d565b60405167ffffffffffffffff9091168152602001610167565b6101836101fc366004610f75565b61043e565b6101bf61020f366004610fb1565b610520565b61021c6105b3565b60405160ff9091168152602001610167565b6102366105bf565b6040516001600160a01b039091168152602001610167565b6101bf61025c366004610f5a565b60016020526000908152604090205481565b6003546101d590600160a01b900467ffffffffffffffff1681565b6101bf6105cb565b6102a461029f366004610fca565b61071b565b005b6003546001600160a01b0316610236565b61015a610780565b6102a46102cd366004611006565b61078c565b6101bf6102e0366004610fb1565b610985565b6101836102f3366004610f30565b610a00565b60045461031290600160401b90046001600160801b031681565b6040516001600160801b039091168152602001610167565b6102a4610338366004610f5a565b610a66565b6101bf61034b36600461102f565b600260209081526000928352604080842090915290825290205481565b6102a4610376366004610f5a565b610ad4565b6004546101d59067ffffffffffffffff1681565b606061039b6000610b35565b6040516020016103ad91815260200190565b604051602081830303815290604052905090565b3360008181526002602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061041c9086815260200190565b60405180910390a350600192915050565b60006104396055610b4b565b905090565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461049a576104758382611078565b6001600160a01b03861660009081526002602090815260408083203384529091529020555b6001600160a01b038516600090815260016020526040812080548592906104c2908490611078565b90915550506001600160a01b03808516600081815260016020526040908190208054870190555190918716906000805160206111028339815191529061050b9087815260200190565b60405180910390a360019150505b9392505050565b60008161052f57506000919050565b6105498261053b6105cb565b670de0b6b3a7640000610b64565b90506105553383610c13565b61057233826105626105bf565b6001600160a01b03169190610c7a565b604080518281526020810184905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc691015b60405180910390a2919050565b60006104396040610cfe565b60006104396041610d17565b60008054816105d86105bf565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561061e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610642919061108f565b905081158061064f575080155b1561066457670de0b6b3a76400009250505090565b600454600354600160401b9091046001600160801b031690600160a01b900467ffffffffffffffff1681158061069a5750804210155b156106bb576106b283670de0b6b3a764000086610b64565b94505050505090565b60045467ffffffffffffffff1660006106d48284611078565b6106de4285611078565b6106e890866110a8565b6106f291906110c7565b90506107106107018287611078565b670de0b6b3a764000088610b64565b965050505050505090565b3361072e6003546001600160a01b031690565b6001600160a01b03161461075557604051635eee3ad160e01b815260040160405180910390fd5b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b606061039b6020610b35565b6000546107ac57604051634161561b60e11b815260040160405180910390fd5b3360009081526005602052604090205460ff166107dc5760405163434e91f160e01b815260040160405180910390fd5b600354600160a01b900467ffffffffffffffff16428111610878576107ff61042d565b6108139067ffffffffffffffff16426110e9565b6003805467ffffffffffffffff60a01b1916600160a01b67ffffffffffffffff93909316929092029190911790556004805477ffffffffffffffffffffffffffffffff00000000000000001916600160401b6001600160801b03851602179055610900565b6004546000906108929067ffffffffffffffff1683611078565b61089c4284611078565b6004546108b99190600160401b90046001600160801b03166110a8565b6108c391906110c7565b90506108d8816001600160801b0385166110e9565b600460086101000a8154816001600160801b0302191690836001600160801b03160217905550505b6004805467ffffffffffffffff19164267ffffffffffffffff1617905561094533306001600160801b0385166109346105bf565b6001600160a01b0316929190610d30565b6040516001600160801b03831681527f03120f0a8f91c16cdf611a921fd5e938e6c54a611606dec3b5fe776c595641229060200160405180910390a15050565b60008161099457506000919050565b6109ae82670de0b6b3a76400006109a96105cb565b610b64565b90506109ba3382610dc4565b6109c83330846109346105bf565b604080518381526020810183905233917f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee9091016105a6565b33600090815260016020526040812080548391908390610a21908490611078565b90915550506001600160a01b038316600081815260016020526040908190208054850190555133906000805160206111028339815191529061041c9086815260200190565b6000610a7a6003546001600160a01b031690565b6001600160a01b031614610aa15760405163d31b2dd760e01b815260040160405180910390fd5b6001600160a01b038116610ac857604051630d803da360e11b815260040160405180910390fd5b610ad181610e15565b50565b33610ae76003546001600160a01b031690565b6001600160a01b031614610b0e57604051635eee3ad160e01b815260040160405180910390fd5b6001600160a01b038116610ac857604051633b7c6c7f60e21b815260040160405180910390fd5b600080610b40610e67565b929092013592915050565b600080610b56610e67565b929092013560c01c92915050565b600080806000198587098587029250828110838203039150508060001415610b9e5760008411610b9357600080fd5b508290049050610519565b808411610baa57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6001600160a01b03821660009081526001602052604081208054839290610c3b908490611078565b90915550506000805482900381556040518281526001600160a01b03841690600080516020611102833981519152906020015b60405180910390a35050565b600060405163a9059cbb60e01b81526001600160a01b03841660048201528260248201526000806044836000895af1915050610cb581610e78565b610cf85760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064015b60405180910390fd5b50505050565b600080610d09610e67565b929092013560f81c92915050565b600080610d22610e67565b929092013560601c92915050565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260008060648360008a5af1915050610d7a81610e78565b610dbd5760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b6044820152606401610cef565b5050505050565b80600080828254610dd591906110e9565b90915550506001600160a01b0382166000818152600160209081526040808320805486019055518481526000805160206111028339815191529101610c6e565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600119368181013560f01c90030190565b60003d82610e8a57806000803e806000fd5b8060208114610ea2578015610eb35760009250610eb8565b816000803e60005115159250610eb8565b600192505b5050919050565b600060208083528351808285015260005b81811015610eec57858101830151858201604001528201610ed0565b81811115610efe576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610f2b57600080fd5b919050565b60008060408385031215610f4357600080fd5b610f4c83610f14565b946020939093013593505050565b600060208284031215610f6c57600080fd5b61051982610f14565b600080600060608486031215610f8a57600080fd5b610f9384610f14565b9250610fa160208501610f14565b9150604084013590509250925092565b600060208284031215610fc357600080fd5b5035919050565b60008060408385031215610fdd57600080fd5b610fe683610f14565b915060208301358015158114610ffb57600080fd5b809150509250929050565b60006020828403121561101857600080fd5b81356001600160801b038116811461051957600080fd5b6000806040838503121561104257600080fd5b61104b83610f14565b915061105960208401610f14565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b60008282101561108a5761108a611062565b500390565b6000602082840312156110a157600080fd5b5051919050565b60008160001904831182151516156110c2576110c2611062565b500290565b6000826110e457634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156110fc576110fc611062565b50019056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220e832d86ddb82f118492d7d6505feb12fa33fa7b99c4b120757a1c14c2cfaa61d64736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2050, 2683, 15878, 2094, 16068, 8586, 2692, 2278, 27531, 22407, 2575, 16048, 2063, 22025, 5243, 16932, 4246, 16932, 6679, 28311, 6679, 26187, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1063, 9413, 2278, 11387, 1065, 2013, 1000, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1063, 3647, 6494, 3619, 7512, 29521, 1065, 2013, 1000, 3647, 6494, 3619, 7512, 29521, 1012, 14017, 1000, 1025, 12324, 1063, 2219, 3085, 1065, 2013, 1000, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1063, 2440, 18900, 2232, 1065, 2013, 1000, 2440, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1063, 9413, 2278, 11387, 2004, 17598, 2121, 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,969
0x97aa7e0af7ed3f69d2a6b66c7860f2e53d5334df
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./ERC20.sol"; import "./IERC20.sol"; contract PizzaToken is ERC20{ address public deployer; constructor() ERC20("pizza-token.finance", "PZZ" ) { _mint(msg.sender, 100000 * (10 ** uint256(18))); deployer = msg.sender; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146101a357806395d89b41146101d3578063a457c2d7146101f1578063a9059cbb14610221578063d5f3948814610251578063dd62ed3e1461026f576100b4565b806306fdde03146100b9578063095ea7b3146100d757806318160ddd1461010757806323b872dd14610125578063313ce567146101555780633950935114610173575b600080fd5b6100c161029f565b6040516100ce919061108e565b60405180910390f35b6100f160048036038101906100ec9190610cdd565b610331565b6040516100fe9190611073565b60405180910390f35b61010f61034f565b60405161011c9190611190565b60405180910390f35b61013f600480360381019061013a9190610c8e565b610359565b60405161014c9190611073565b60405180910390f35b61015d61045a565b60405161016a91906111ab565b60405180910390f35b61018d60048036038101906101889190610cdd565b610463565b60405161019a9190611073565b60405180910390f35b6101bd60048036038101906101b89190610c29565b61050f565b6040516101ca9190611190565b60405180910390f35b6101db610557565b6040516101e8919061108e565b60405180910390f35b61020b60048036038101906102069190610cdd565b6105e9565b6040516102189190611073565b60405180910390f35b61023b60048036038101906102369190610cdd565b6106dd565b6040516102489190611073565b60405180910390f35b6102596106fb565b6040516102669190611058565b60405180910390f35b61028960048036038101906102849190610c52565b610721565b6040516102969190611190565b60405180910390f35b6060600380546102ae906112f4565b80601f01602080910402602001604051908101604052809291908181526020018280546102da906112f4565b80156103275780601f106102fc57610100808354040283529160200191610327565b820191906000526020600020905b81548152906001019060200180831161030a57829003601f168201915b5050505050905090565b600061034561033e6107a8565b84846107b0565b6001905092915050565b6000600254905090565b600061036684848461097b565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006103b16107a8565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610431576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042890611110565b60405180910390fd5b61044e8561043d6107a8565b85846104499190611238565b6107b0565b60019150509392505050565b60006012905090565b60006105056104706107a8565b84846001600061047e6107a8565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461050091906111e2565b6107b0565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054610566906112f4565b80601f0160208091040260200160405190810160405280929190818152602001828054610592906112f4565b80156105df5780601f106105b4576101008083540402835291602001916105df565b820191906000526020600020905b8154815290600101906020018083116105c257829003601f168201915b5050505050905090565b600080600160006105f86107a8565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156106b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ac90611170565b60405180910390fd5b6106d26106c06107a8565b8585846106cd9190611238565b6107b0565b600191505092915050565b60006106f16106ea6107a8565b848461097b565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081790611150565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610890576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610887906110d0565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161096e9190611190565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e290611130565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a52906110b0565b60405180910390fd5b610a66838383610bfa565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610aec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae3906110f0565b60405180910390fd5b8181610af89190611238565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b8891906111e2565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610bec9190611190565b60405180910390a350505050565b505050565b600081359050610c0e81611395565b92915050565b600081359050610c23816113ac565b92915050565b600060208284031215610c3b57600080fd5b6000610c4984828501610bff565b91505092915050565b60008060408385031215610c6557600080fd5b6000610c7385828601610bff565b9250506020610c8485828601610bff565b9150509250929050565b600080600060608486031215610ca357600080fd5b6000610cb186828701610bff565b9350506020610cc286828701610bff565b9250506040610cd386828701610c14565b9150509250925092565b60008060408385031215610cf057600080fd5b6000610cfe85828601610bff565b9250506020610d0f85828601610c14565b9150509250929050565b610d228161126c565b82525050565b610d318161127e565b82525050565b6000610d42826111c6565b610d4c81856111d1565b9350610d5c8185602086016112c1565b610d6581611384565b840191505092915050565b6000610d7d6023836111d1565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610de36022836111d1565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e496026836111d1565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610eaf6028836111d1565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f156025836111d1565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f7b6024836111d1565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610fe16025836111d1565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b611043816112aa565b82525050565b611052816112b4565b82525050565b600060208201905061106d6000830184610d19565b92915050565b60006020820190506110886000830184610d28565b92915050565b600060208201905081810360008301526110a88184610d37565b905092915050565b600060208201905081810360008301526110c981610d70565b9050919050565b600060208201905081810360008301526110e981610dd6565b9050919050565b6000602082019050818103600083015261110981610e3c565b9050919050565b6000602082019050818103600083015261112981610ea2565b9050919050565b6000602082019050818103600083015261114981610f08565b9050919050565b6000602082019050818103600083015261116981610f6e565b9050919050565b6000602082019050818103600083015261118981610fd4565b9050919050565b60006020820190506111a5600083018461103a565b92915050565b60006020820190506111c06000830184611049565b92915050565b600081519050919050565b600082825260208201905092915050565b60006111ed826112aa565b91506111f8836112aa565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561122d5761122c611326565b5b828201905092915050565b6000611243826112aa565b915061124e836112aa565b92508282101561126157611260611326565b5b828203905092915050565b60006112778261128a565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156112df5780820151818401526020810190506112c4565b838111156112ee576000848401525b50505050565b6000600282049050600182168061130c57607f821691505b602082108114156113205761131f611355565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b61139e8161126c565b81146113a957600080fd5b50565b6113b5816112aa565b81146113c057600080fd5b5056fea2646970667358221220aa4f5394bf4a1813e149b4a0a8d0f14ec88645773f719505ada76e8ffae47b5664736f6c63430008000033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 11057, 2581, 2063, 2692, 10354, 2581, 2098, 2509, 2546, 2575, 2683, 2094, 2475, 2050, 2575, 2497, 28756, 2278, 2581, 20842, 2692, 2546, 2475, 2063, 22275, 2094, 22275, 22022, 20952, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 3206, 10733, 18715, 2368, 2003, 9413, 2278, 11387, 1063, 4769, 2270, 21296, 2121, 1025, 9570, 2953, 1006, 1007, 9413, 2278, 11387, 1006, 1000, 10733, 1011, 19204, 1012, 5446, 1000, 1010, 1000, 1052, 13213, 1000, 1007, 1063, 1035, 12927, 1006, 5796, 2290, 1012, 4604, 2121, 1010, 6694, 8889, 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,970
0x97AA9658cfE27D6382b71FF9E72d773615Bd529E
/* 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 "StarkExForcedActionState.sol"; import "ERC721Receiver.sol"; import "Freezable.sol"; import "KeyGetters.sol"; import "TokenRegister.sol"; import "TokenTransfers.sol"; import "Users.sol"; import "MainGovernance.sol"; import "AcceptModifications.sol"; import "CompositeActions.sol"; import "Deposits.sol"; import "TokenAssetData.sol"; import "TokenQuantization.sol"; import "Withdrawals.sol"; import "SubContractor.sol"; contract TokensAndRamping is ERC721Receiver, SubContractor, Freezable, MainGovernance, AcceptModifications, StarkExForcedActionState, TokenAssetData, TokenQuantization, TokenRegister, TokenTransfers, KeyGetters, Users, Deposits, CompositeActions, Withdrawals { function initialize(bytes calldata /* data */) external override { revert("NOT_IMPLEMENTED"); } function initializerSize() external view override returns(uint256){ return 0; } function identify() external pure override returns(string memory){ return "StarkWare_TokensAndRamping_2020_1"; } }
0x6080604052600436106102de5760003560e01c80638c4bce1c11610186578063c8b1031a116100d7578063e6de628211610085578063e6de628214610ea3578063ebef0fd014610eb8578063ec3161b014610efd578063eeb7286614610f2d578063f3e0c3fb14610f42578063f637d95014610f75578063fcb0582214610f9f576102de565b8063c8b1031a14610b75578063d528058914610bf7578063d88d8b3814610c93578063d91443b714610d4d578063dd2414d414610dd4578063dd7202d814610e64578063e30a5cff14610e8e576102de565b8063a6fa6e9011610134578063a6fa6e90146109c8578063abf98fe1146109fb578063ae1cdde614610a31578063ae87381614610a6d578063b04b617914610aa3578063b766311214610ad6578063c23b60ef14610aeb576102de565b80638c4bce1c146108b4578063993f3639146108e75780639c6a2837146108fc5780639ed1708414610911578063a1cc921e1461094d578063a2bdde3d14610980578063a45d7841146109b3576102de565b80633cc660ad116102405780635eecd218116101ee5780635eecd218146107f75780636ce5d9571461030a57806372eb36881461080c57806374d523a81461082157806377e84e0d146108545780637cf12b90146108695780637df7dc041461087e576102de565b80633cc660ad1461061b5780633ccfc8ed14610630578063439fab91146106b9578063441a3e701461073457806345f5cd97146107645780634e8912da146107975780635e586cd1146107cd576102de565b8063150b7a021161029d578063150b7a021461041b5780631dbd1da7146105095780632505c3d91461054f57806328700a151461058b578063296e2f37146105a0578063333ac20b146105d057806333eeb14714610606576102de565b8062717542146102e3578062aeef8a1461030a578063019b417a14610335578063049f5ade1461036b5780630b3a2d21146103a957806314cd70e4146103dc575b600080fd5b3480156102ef57600080fd5b506102f8610fdb565b60408051918252519081900360200190f35b6103336004803603606081101561032057600080fd5b5080359060208101359060400135610fe2565b005b34801561034157600080fd5b506103336004803603606081101561035857600080fd5b508035906020810135906040013561104b565b34801561037757600080fd5b506103956004803603602081101561038e57600080fd5b5035611057565b604080519115158252519081900360200190f35b3480156103b557600080fd5b50610333600480360360208110156103cc57600080fd5b50356001600160a01b031661106f565b3480156103e857600080fd5b50610333600480360360608110156103ff57600080fd5b50803590602081013590604001356001600160a01b0316611116565b34801561042757600080fd5b506104ec6004803603608081101561043e57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561047857600080fd5b82018360208201111561048a57600080fd5b803590602001918460018302840111600160201b831117156104ab57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611170945050505050565b604080516001600160e01b03199092168252519081900360200190f35b34801561051557600080fd5b506105336004803603602081101561052c57600080fd5b5035611180565b604080516001600160a01b039092168252519081900360200190f35b34801561055b57600080fd5b506103336004803603608081101561057257600080fd5b50803590602081013590604081013590606001356111de565b34801561059757600080fd5b50610333611476565b3480156105ac57600080fd5b506102f8600480360360408110156105c357600080fd5b5080359060200135611480565b3480156105dc57600080fd5b506102f8600480360360608110156105f357600080fd5b50803590602081013590604001356114a7565b34801561061257600080fd5b506103956114cb565b34801561062757600080fd5b506102f86114dc565b610333600480360360a081101561064657600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561067557600080fd5b82018360208201111561068757600080fd5b803590602001918460018302840111600160201b831117156106a857600080fd5b9193509150803590602001356114e1565b3480156106c557600080fd5b50610333600480360360208110156106dc57600080fd5b810190602081018135600160201b8111156106f657600080fd5b82018360208201111561070857600080fd5b803590602001918460018302840111600160201b8311171561072957600080fd5b509092509050611500565b34801561074057600080fd5b506103336004803603604081101561075757600080fd5b508035906020013561153f565b34801561077057600080fd5b506103956004803603602081101561078757600080fd5b50356001600160a01b0316611556565b3480156107a357600080fd5b506102f8600480360360608110156107ba57600080fd5b5080359060208101359060400135611567565b3480156107d957600080fd5b506102f8600480360360208110156107f057600080fd5b503561158b565b34801561080357600080fd5b506102f86115fb565b34801561081857600080fd5b50610333611601565b34801561082d57600080fd5b506103956004803603602081101561084457600080fd5b50356001600160a01b0316611609565b34801561086057600080fd5b506102f8611627565b34801561087557600080fd5b5061033361162e565b34801561088a57600080fd5b50610333600480360360608110156108a157600080fd5b5080359060208101359060400135611765565b3480156108c057600080fd5b50610333600480360360208110156108d757600080fd5b50356001600160a01b0316611816565b3480156108f357600080fd5b506102f8611822565b34801561090857600080fd5b5061053361182a565b34801561091d57600080fd5b506103336004803603608081101561093457600080fd5b5080359060208101359060408101359060600135611841565b34801561095957600080fd5b506103336004803603602081101561097057600080fd5b50356001600160a01b031661184d565b34801561098c57600080fd5b50610395600480360360208110156109a357600080fd5b50356001600160a01b0316611856565b3480156109bf57600080fd5b506102f8611874565b3480156109d457600080fd5b50610333600480360360208110156109eb57600080fd5b50356001600160a01b0316611882565b348015610a0757600080fd5b506102f860048036036060811015610a1e57600080fd5b5080359060208101359060400135611926565b348015610a3d57600080fd5b5061033360048036036080811015610a5457600080fd5b508035906020810135906040810135906060013561195e565b348015610a7957600080fd5b5061033360048036036060811015610a9057600080fd5b5080359060208101359060400135611b9f565b348015610aaf57600080fd5b5061033360048036036020811015610ac657600080fd5b50356001600160a01b0316611d60565b348015610ae257600080fd5b506102f8611e04565b348015610af757600080fd5b50610b00611e0b565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610b3a578181015183820152602001610b22565b50505050905090810190601f168015610b675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610b8157600080fd5b5061033360048036036040811015610b9857600080fd5b81359190810190604081016020820135600160201b811115610bb957600080fd5b820183602082011115610bcb57600080fd5b803590602001918460018302840111600160201b83111715610bec57600080fd5b509092509050611e27565b348015610c0357600080fd5b50610333600480360360c0811015610c1a57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610c4957600080fd5b820183602082011115610c5b57600080fd5b803590602001918460018302840111600160201b83111715610c7c57600080fd5b919350915080359060208101359060400135611e6a565b348015610c9f57600080fd5b5061033360048036036060811015610cb657600080fd5b81359190810190604081016020820135600160201b811115610cd757600080fd5b820183602082011115610ce957600080fd5b803590602001918460018302840111600160201b83111715610d0a57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250611e8b915050565b348015610d5957600080fd5b5061033360048036036060811015610d7057600080fd5b813591602081013591810190606081016040820135600160201b811115610d9657600080fd5b820183602082011115610da857600080fd5b803590602001918460018302840111600160201b83111715610dc957600080fd5b50909250905061222e565b348015610de057600080fd5b5061033360048036036060811015610df757600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610e2657600080fd5b820183602082011115610e3857600080fd5b803590602001918460018302840111600160201b83111715610e5957600080fd5b50909250905061248f565b348015610e7057600080fd5b506102f860048036036020811015610e8757600080fd5b5035612879565b348015610e9a57600080fd5b506102f86128aa565b348015610eaf57600080fd5b506102f86128af565b348015610ec457600080fd5b5061033360048036036080811015610edb57600080fd5b50803590602081013590604081013590606001356001600160a01b03166128b4565b348015610f0957600080fd5b506102f860048036036040811015610f2057600080fd5b5080359060200135612a94565b348015610f3957600080fd5b50610b00612ac3565b348015610f4e57600080fd5b5061033360048036036020811015610f6557600080fd5b50356001600160a01b0316612ae3565b348015610f8157600080fd5b50610b0060048036036020811015610f9857600080fd5b5035612b8a565b348015610fab57600080fd5b5061033360048036036080811015610fc257600080fd5b5080359060208101359060408101359060600135612c8b565b62093a8081565b610feb82612e55565b611031576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6110468383836110418634612e9e565b6111de565b505050565b611046838383336128b4565b60008181526015602052604090205460ff165b919050565b61107833612f0b565b6110bb576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19166001179055815192835290517f9085a9044aeb6daeeb5b4bf84af42b1a1613d4056f503c4e992b6396c16bd52f9281900390910190a150565b8261112081612f3a565b61115f576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b61116a848484612f60565b50505050565b630a85bd0160e11b949350505050565b6000818152601860205260409020546001600160a01b03168061106a576040805162461bcd60e51b81526020600482015260116024820152701554d15497d553949151d254d511549151607a1b604482015290519081900360640190fd5b6111e66114cb565b1561122a576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b6000848152601860205260409020546001600160a01b0316611287576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f535441524b5f4b455960781b604482015290519081900360640190fd5b61129083613097565b156112d8576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b6112e183613114565b61132c576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000848152600660209081526040808320868452825280832085845290915290208054820190819055839082111561139e576040805162461bcd60e51b815260206004820152601060248201526f4445504f5349545f4f564552464c4f5760801b604482015290519081900360640190fd5b6113a785612f3a565b80156113d357506000858152600760209081526040808320848452825280832086845290915290205415155b156113fb57600085815260076020908152604080832084845282528083208684529091528120555b61140584836131ca565b7f06724742ccc8c330a39a641ef02a0b419bd09248360680bb38159b0a8c2635d633868587611434898861348c565b604080516001600160a01b0390961686526020860194909452848401929092526060840152608083015260a08201859052519081900360c00190a15050505050565b61147e6134fd565b565b60006022600061149085856135c4565b815260200190815260200160002054905092915050565b60009283526007602090815260408085209385529281528284209184525290205490565b600454600160a01b900460ff165b90565b600090565b6114ed8686868661248f565b6114f8858383610fe2565b505050505050565b6040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253541311535153951151608a1b604482015290519081900360640190fd5b611552828261154d85611180565b612f60565b5050565b600061156182612f0b565b92915050565b60009283526006602090815260408085209385529281528284209184525290205490565b60245460009082106115dc576040805162461bcd60e51b815260206004820152601560248201527408286a8929e9cbe929c888ab0bea89e9ebe90928e9605b1b604482015290519081900360640190fd5b602482815481106115e957fe5b90600052602060002001549050919050565b60245490565b61147e61361e565b6001600160a01b031660009081526012602052604090205460ff1690565b6203f48081565b6116366114cb565b61167a576040805162461bcd60e51b815260206004820152601060248201526f29aa20aa22afa727aa2fa32927ad22a760811b604482015290519081900360640190fd5b61168333612f0b565b6116c6576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b600554421015611718576040805162461bcd60e51b8152602060048201526018602482015277155391949151569157d393d517d0531313d5d15117d6515560421b604482015290519081900360640190fd5b6004805460ff60a01b19169055600d80546001908101909155600f805490910190556040517f07017fe9180629cfffba412f65a9affcf9a121de02294179f5c058f881dcc9f890600090a1565b8261176f81612f3a565b6117ae576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b60008481526007602090815260408083208684528252808320858452825291829020429055815186815290810184905280820185905290517f0bc1df35228095c37da66a6ffcc755ea79dfc437345685f618e05fafad6b445e9181900360600190a150505050565b61181f816136b5565b50565b6301e1338081565b68010000000000000004546001600160a01b031681565b61116a848484846111de565b61181f816137b2565b6001600160a01b031660009081526011602052604090205460ff1690565b680100000000000000035481565b61188b33612f0b565b6118ce576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19169055815192835290517ffa49aecb996ea8d99950bb051552dfcc0b5460a0bb209867a1ed8067c32c21779281900390910190a150565b60008381526006602090815260408083208584528252808320848452909152812054839061195590829061348c565b95945050505050565b6119666114cb565b156119aa576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b6000848152601860205260409020546001600160a01b0316611a07576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f535441524b5f4b455960781b604482015290519081900360640190fd5b611a1083613097565b15611a58576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b611a6183613114565b15611aa9576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b6000611ab584836138ff565b600086815260066020908152604080832084845282528083208784529091529020600190559050611ae585612f3a565b8015611b1157506000858152600760209081526040808320848452825280832086845290915290205415155b15611b3957600085815260076020908152604080832084845282528083208684529091528120555b611b4384836139a3565b6040805133815260208101879052808201859052606081018690526080810184905260a0810183905290517f0fcf2162832b2d6033d4d34d2f45a28d9cfee523f1899945bbdd32529cfda67b9181900360c00190a15050505050565b82611ba981612f3a565b611be8576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b60008481526007602090815260408083208684528252808320858452909152902054839080611c55576040805162461bcd60e51b815260206004820152601460248201527311115413d4d25517d393d517d0d05390d153115160621b604482015290519081900360640190fd5b6203f48081810190811015611c6657fe5b80421015611cac576040805162461bcd60e51b815260206004820152600e60248201526d11115413d4d25517d313d0d2d15160921b604482015290519081900360640190fd5b6000878152600660209081526040808320898452825280832088845282528083208054908490558a8452600783528184208a85528352818420898552909252822091909155611cfc338583613a5c565b7fe3e46ecf1138180bf93cba62a0b7e661d976a8ab3d40243f7b082667d8f500af888786611d2a888661348c565b60408051948552602085019390935283830191909152606083015260808201849052519081900360a00190a15050505050505050565b611d6933612f0b565b611dac576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260126020908152604091829020805460ff19169055815192835290517fb32f8aed6bedf93605e95bc99e0e229b8bbfcd0fe2e76a6748450d3e9522db469281900390910190a150565b6224ea0081565b604051806060016040528060268152602001614af56026913981565b6110468383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250611e8b915050565b611e768787878761248f565b611e8286848484611841565b50505050505050565b611e9433611856565b611ed9576040805162461bcd60e51b815260206004820152601160248201527027a7262cafaa27a5a2a729afa0a226a4a760791b604482015290519081900360640190fd5b611ee283611057565b15611f2f576040805162461bcd60e51b81526020600482015260186024820152771054d4d15517d053149150511657d49151d254d51154915160421b604482015290519081900360640190fd5b6001601160c01b01600160fb1b018310611f85576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b60008111611fcc576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b600160801b8110612016576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b60006001600160fa1b0383836040516020018083805190602001908083835b602083106120545780518252601f199092019160209182019101612035565b51815160209384036101000a60001901801990921691161790529201938452506040805180850381529382019052825192019190912092909216925050508381146120db576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6120e483613ca0565b6120ed83613e31565b1561213d578160011461213d576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f4e46545f5155414e54554d60681b604482015290519081900360640190fd5b6000848152601560209081526040808320805460ff1916600117905560148252909120845161216e928601906149d7565b508160166000868152602001908152602001600020819055507f4d2c7bfd8df1ba4f331f1abd2562bf3088e8b378c7dd1308113a82c64e518dbf84846040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156121ed5781810151838201526020016121d5565b50505050905090810190601f16801561221a5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a150505050565b8361223881612f3a565b612277576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b60008481526015602052604090205460ff166122cf576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6122d884613097565b612323576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b60006123658585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613eab92505050565b60008781526008602090815260408083208484529091529020549091506123d3576040805162461bcd60e51b815260206004820152601d60248201527f4e4f5f50454e44494e475f5749544844524157414c5f42414c414e4345000000604482015290519081900360640190fd5b6000868152600860209081526040808320848452825280832080549390558051601f870183900483028101830190915285815261242e91889184918990899081908401838280828437600092019190915250613f6c92505050565b7f7e6e15df814c1a309a57686de672b2bedd128eacde35c5370c36d6840d4e9a92878761245b898561348c565b604080519384526020840192909252828201526060820184905260808201859052519081900360a00190a150505050505050565b826124d5576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f535441524b5f4b455960781b604482015290519081900360640190fd5b6001601160c01b01600160fb1b01831061252a576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f535441524b5f4b455960781b604482015290519081900360640190fd5b6001600160a01b03841661257b576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f4554485f4144445245535360681b604482015290519081900360640190fd5b6000838152601860205260409020546001600160a01b0316156125dd576040805162461bcd60e51b8152602060048201526015602482015274535441524b5f4b45595f554e415641494c41424c4560581b604482015290519081900360640190fd5b6125e6836140bb565b61262b576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f535441524b5f4b455960781b604482015290519081900360640190fd5b60418114612674576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b600084846040516020018080702ab9b2b92932b3b4b9ba3930ba34b7b71d60791b815250601101836001600160a01b03166001600160a01b031660601b815260140182815260200192505050604051602081830303815290604052805190602001209050606083838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250845194955093859350604092508210905061272357fe5b0160209081015183820151604080860151815160008082528187018085528a905260f89590951c81840181905260608201859052608082018390529251929650929490939260019260a08083019392601f198301929081900390910190855afa158015612794573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906127bd57506127bd81611609565b612802576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b60008981526018602090815260409182902080546001600160a01b038e166001600160a01b0319909116811790915582519081529081018b9052338183015290517fcab1cf17c190e4e2195a7b8f7b362023246fa774390432b4704ab6b29d56b07b9181900360600190a150505050505050505050565b60008181526015602052604081205460ff166128975750600161106a565b5060009081526016602052604090205490565b600a81565b604081565b836128be81612f3a565b6128fd576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b600061290985856138ff565b905061291485613097565b1561295c576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b61296585613114565b156129ad576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b6000868152600860209081526040808320848452909152902054600114612a11576040805162461bcd60e51b8152602060048201526013602482015272494c4c4547414c5f4e46545f42414c414e434560681b604482015290519081900360640190fd5b6000868152600860209081526040808320848452909152812055612a3683868661412a565b6040805187815260208101879052808201869052606081018390526001600160a01b038516608082015290517fa5cfa8e2199ec5b8ca319288bcab72734207d30569756ee594a74b4df7abbf419181900360a00190a1505050505050565b60008281526008602090815260408083208484529091528120548290612abb90829061348c565b949350505050565b6060604051806060016040528060218152602001614ab060219139905090565b612aec33612f0b565b612b2f576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260126020908152604091829020805460ff19166001179055815192835290517f7284e8b42a1333a4f23e858e513b3b28d2667a3531b7c1872cce3f7720a250469281900390910190a150565b60008181526015602052604090205460609060ff16612bec576040805162461bcd60e51b81526020600482015260196024820152781054d4d15517d516541157d393d517d49151d254d511549151603a1b604482015290519081900360640190fd5b60008281526014602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015612c7f5780601f10612c5457610100808354040283529160200191612c7f565b820191906000526020600020905b815481529060010190602001808311612c6257829003601f168201915b50505050509050919050565b83612c9581612f3a565b612cd4576040805162461bcd60e51b815260206004820152601a6024820152600080516020614a90833981519152604482015290519081900360640190fd5b6000612ce085846138ff565b6000878152600760209081526040808320848452825280832088845290915290205490915080612d4e576040805162461bcd60e51b815260206004820152601460248201527311115413d4d25517d393d517d0d05390d153115160621b604482015290519081900360640190fd5b6203f48081810190811015612d5f57fe5b80421015612da5576040805162461bcd60e51b815260206004820152600e60248201526d11115413d4d25517d313d0d2d15160921b604482015290519081900360640190fd5b6000888152600660209081526040808320868452825280832089845282528083208054908490558b84526007835281842087855283528184208a85529092528220919091558015612e4a57612dfb33898861412a565b604080518a8152602081018990528082018a9052606081018890526080810186905290517ff00c0c1a754f6df7545d96a7e12aad552728b94ca6aa94f81e297bdbcf1dab9c9181900360a00190a15b505050505050505050565b6040805164455448282960d81b815290519081900360050190206000906001600160e01b031916612e8d612e8884612b8a565b6141e6565b6001600160e01b0319161492915050565b600080612eaa84612879565b9050808381612eb557fe5b0615612ef9576040805162461bcd60e51b815260206004820152600e60248201526d1253959053125117d05353d5539560921b604482015290519081900360640190fd5b808381612f0257fe5b04949350505050565b600080612f166141f7565b6001600160a01b039390931660009081526020939093525050604090205460ff1690565b6000612f4582611180565b6001600160a01b0316336001600160a01b0316149050919050565b612f6982613097565b15612fb1576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b612fba82613114565b613005576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000838152600860209081526040808320858452909152812080549190558290613030838383613a5c565b7fb7477a7b93b2addc5272bbd7ad0986ef1c0d0bd265f26c3dc4bbe42727c2ac0c858561305d878561348c565b60408051938452602084019290925282820152606082018490526001600160a01b0386166080830152519081900360a00190a15050505050565b6000806130a6612e8884612b8a565b60408051600080516020614a708339815191528152905190819003601b0190209091506001600160e01b03198083169116148061310d5750604051806024614ad18239602401905060405180910390206001600160e01b031916816001600160e01b031916145b9392505050565b600080613123612e8884612b8a565b6040805164455448282960d81b815290519081900360050190209091506001600160e01b03198083169116148061318d575060408051724552433230546f6b656e28616464726573732960681b815290519081900360130190206001600160e01b03198281169116145b8061310d575060408051600080516020614a708339815191528152905190819003601b0190206001600160e01b0319828116911614915050919050565b60006131d6838361348c565b90506131e1836142c2565b156133e45760006131f184614303565b604080516370a0823160e01b8152306004820152905191925082916000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561324057600080fd5b505afa158015613254573d6000803e3d6000fd5b505050506040513d602081101561326a57600080fd5b50516040805133602482015230604482015260648082018890528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790529091506132cc6001600160a01b0385168263ffffffff61431616565b604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561331657600080fd5b505afa15801561332a573d6000803e3d6000fd5b505050506040513d602081101561334057600080fd5b5051905082811015613384576040805162461bcd60e51b81526020600482015260086024820152674f564552464c4f5760c01b604482015290519081900360640190fd5b85830181146133da576040805162461bcd60e51b815260206004820152601c60248201527f494e434f52524543545f414d4f554e545f5452414e5346455252454400000000604482015290519081900360640190fd5b5050505050611046565b6133ed83612e55565b1561344657803414613441576040805162461bcd60e51b8152602060048201526018602482015277125390d3d4949150d517d1115413d4d25517d05353d5539560421b604482015290519081900360640190fd5b611046565b6040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b60008061349884612879565b90508083029150828183816134a957fe5b04146134f6576040805162461bcd60e51b815260206004820152601760248201527644455155414e54495a4154494f4e5f4f564552464c4f5760481b604482015290519081900360640190fd5b5092915050565b60006135076141f7565b60018101549091506001600160a01b03163314613565576040805162461bcd60e51b815260206004820152601760248201527627a7262cafa1a0a72224a220aa22afa3a7ab22a92727a960491b604482015290519081900360640190fd5b600181015461357c906001600160a01b0316614502565b6001810180546001600160a01b03191690556040805133815290517fcfb473e6c03f9a29ddaf990e736fa3de5188a0bd85d684f5b6e164ebfbfff5d29181900360200190a150565b600061310d6040518060400160405280600f81526020016e1195531317d5d2551211149055d053608a1b81525084846040516020018083815260200182815260200192505050604051602081830303815290604052614582565b61362733612f0b565b61366a576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60006136746141f7565b6001810180546001600160a01b03191690556040519091507f7a8dc7dd7fffb43c4807438fa62729225156941e641fd877938f4edade3429f590600090a150565b6136be33612f0b565b613701576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b600061370b6141f7565b905061371682612f0b565b1561375b576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6001810180546001600160a01b0384166001600160a01b0319909116811790915560408051918252517f6166272c8d3f5f579082f2827532732f97195007983bb5b83ac12c56700b01a69181900360200190a15050565b6137bb33612f0b565b6137fe576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b336001600160a01b0382161415613853576040805162461bcd60e51b8152602060048201526014602482015273474f5645524e4f525f53454c465f52454d4f564560601b604482015290519081900360640190fd5b600061385d6141f7565b905061386882612f0b565b6138a8576040805162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3a7ab22a92727a960a11b604482015290519081900360640190fd5b6001600160a01b03821660008181526020838152604091829020805460ff19169055815192835290517fd75f94825e770b8b512be8e74759e252ad00e102e38f50cce2f7c6f868a295999281900390910190a15050565b60006001600160fa1b036040518060400160405280600481526020016327232a1d60e11b81525084846040516020018084805190602001908083835b6020831061395a5780518252601f19909201916020918201910161393b565b51815160209384036101000a6000190180199092169116179052920194855250838101929092525060408051808403830181529281019052815191012091909116949350505050565b6139ac82614644565b6139f0576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b60006139fb83614303565b6040805133602482015230604482015260648082018690528251808303909101815260849091019091526020810180516001600160e01b0316632142170760e11b179052909150611046906001600160a01b0383169063ffffffff61431616565b6000613a68838361348c565b9050613a73836142c2565b15613c74576000613a8384614303565b604080516370a0823160e01b8152306004820152905191925082916000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b158015613ad257600080fd5b505afa158015613ae6573d6000803e3d6000fd5b505050506040513d6020811015613afc57600080fd5b5051604080516001600160a01b03808b16602483015260448083018990528351808403909101815260649092019092526020810180516001600160e01b031663a9059cbb60e01b179052919250613b5b9085168263ffffffff61431616565b604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b158015613ba557600080fd5b505afa158015613bb9573d6000803e3d6000fd5b505050506040513d6020811015613bcf57600080fd5b5051905082811115613c14576040805162461bcd60e51b8152602060048201526009602482015268554e444552464c4f5760b81b604482015290519081900360640190fd5b8583038114613c6a576040805162461bcd60e51b815260206004820152601c60248201527f494e434f52524543545f414d4f554e545f5452414e5346455252454400000000604482015290519081900360640190fd5b505050505061116a565b613c7d83612e55565b1561344657613c9b6001600160a01b0385168263ffffffff61467d16565b61116a565b6000613cab826141e6565b9050613cb681614719565b613d00576040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b6040805164455448282960d81b815290519081900360050190206001600160e01b031982811691161415613d80578151600414613d7b576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b611552565b8151602414613dcd576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b6000613dd88361482a565b9050613dec816001600160a01b0316614831565b611046576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b600080613e3d836141e6565b60408051600080516020614b1b8339815191528152905190819003601c0190209091506001600160e01b03198083169116148061310d5750604051806024614ad18239602401905060405180910390206001600160e01b031916816001600160e01b03191614915050919050565b600080828051906020012060001c9050600160fa1b6001600160f01b036040518060400160405280600981526020016826a4a72a20a126229d60b91b81525086846040516020018084805190602001908083835b60208310613f1e5780518252601f199092019160209182019101613eff565b51815160209384036101000a60001901801990921691161790529201948552508381019290925250604080518084038301815292810190528151910120919091169190911795945050505050565b613f7583613097565b613fc0576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000613fcc848461348c565b90506000613fd985614303565b90506140b433838560405160240180846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561403f578181015183820152602001614027565b50505050905090810190601f16801561406c5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166319ee6e3f60e01b1790526001600160a01b038816955093505063ffffffff61431616915050565b5050505050565b6000806001601160c01b01600160fb1b01836001601160c01b01600160fb1b0185860909905061310d6001601160c01b01600160fb1b017f06f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e896001601160c01b01600160fb1b0186850808614837565b61413382614644565b614177576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b600061418283614303565b604080513060248201526001600160a01b03808816604483015260648083018790528351808403909101815260849092019092526020810180516001600160e01b0316632142170760e11b17905291925061116a919083169063ffffffff61431616565b602001516001600160e01b03191690565b60006060614203614857565b9050600080826040518082805190602001908083835b602083106142385780518252601f199092019160209182019101614219565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001810154909350600160a01b900460ff1691506142bc9050576040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253925512505312569151608a1b604482015290519081900360640190fd5b91505090565b60408051724552433230546f6b656e28616464726573732960681b815290519081900360130190206000906001600160e01b031916612e8d612e8884612b8a565b600061156161431183612b8a565b61482a565b61431f82614831565b614364576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106143a25780518252601f199092019160209182019101614383565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614404576040519150601f19603f3d011682016040523d82523d6000602084013e614409565b606091505b50915091508181906144995760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561445e578181015183820152602001614446565b50505050905090810190601f16801561448b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080511561116a578080602001905160208110156144b657600080fd5b505161116a576040805162461bcd60e51b81526020600482015260166024820152751513d2d15397d3d4115490551253d397d1905253115160521b604482015290519081900360640190fd5b61450b81612f0b565b15614550576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b600061455a6141f7565b6001600160a01b0390921660009081526020929092525060409020805460ff19166001179055565b600082826040516020018083805190602001908083835b602083106145b85780518252601f199092019160209182019101614599565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106146005780518252601f1990920191602091820191016145e1565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405280519060200120905092915050565b60408051600080516020614b1b8339815191528152905190819003601c0190206000906001600160e01b031916612e8d612e8884612b8a565b6040516000906001600160a01b0384169083908381818185875af1925050503d80600081146146c8576040519150601f19603f3d011682016040523d82523d6000602084013e6146cd565b606091505b5050905080611046576040805162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b6040805164455448282960d81b815290519081900360050190206000906001600160e01b031983811691161480614783575060408051724552433230546f6b656e28616464726573732960681b815290519081900360130190206001600160e01b03198381169116145b806147b9575060408051600080516020614b1b8339815191528152905190819003601c0190206001600160e01b03198381169116145b806147ef575060408051600080516020614a708339815191528152905190819003601b0190206001600160e01b03198381169116145b806115615750604051806024614ad18239602401905060405180910390206001600160e01b031916826001600160e01b031916149050919050565b6024015190565b3b151590565b600061484e8267080000000000001160bf1b614877565b60011492915050565b6060604051806060016040528060268152602001614af560269139905090565b60408051602081810181905281830181905260608281018290526080830186905260a083018590526001601160c01b01600160fb1b0160c0808501919091528451808503909101815260e0909301938490528251600094859492936005939282918401908083835b602083106148fe5780518252601f1990920191602091820191016148df565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461495e576040519150601f19603f3d011682016040523d82523d6000602084013e614963565b606091505b50915091508181906149b65760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561445e578181015183820152602001614446565b508080602001905160208110156149cc57600080fd5b505195945050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614a1857805160ff1916838001178555614a45565b82800160010185558215614a45579182015b82811115614a45578251825591602001919060010190614a2a565b50614a51929150614a55565b5090565b6114d991905b80821115614a515760008155600101614a5b56fe4d696e7461626c654552433230546f6b656e28616464726573732900000000004d49534d41544348494e475f535441524b5f4554485f4b455953000000000000537461726b576172655f546f6b656e73416e6452616d70696e675f323032305f314d696e7461626c65455243373231546f6b656e28616464726573732c75696e7432353629537461726b45782e4d61696e2e323031392e476f7665726e6f7273496e666f726d6174696f6e455243373231546f6b656e28616464726573732c75696e743235362900000000a264697066735822122010abc6d1d4f7b53ebfde198acd07f8947254bd2a7e3220d2a4c0a125ff7a045964736f6c634300060b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 11057, 2683, 26187, 2620, 2278, 7959, 22907, 2094, 2575, 22025, 2475, 2497, 2581, 2487, 4246, 2683, 2063, 2581, 2475, 2094, 2581, 2581, 21619, 16068, 2497, 2094, 25746, 2683, 2063, 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, 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,971
0x97AAba078BFda24f15CC9081e084e2B58C09E70E
// 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); } } } } 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); } 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"); } } } pragma solidity ^0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } function getLockedAmount() public view virtual returns (uint256) { uint256 amount = token().balanceOf(address(this)); return amount; } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063252bc8861461005c57806338af3eed1461007a57806386d1a69f14610098578063b91d4001146100a2578063fc0c546a146100c0575b600080fd5b6100646100de565b6040516100719190610944565b60405180910390f35b61008261017a565b60405161008f9190610823565b60405180910390f35b6100a06101a2565b005b6100aa6102ff565b6040516100b79190610944565b60405180910390f35b6100c8610327565b6040516100d59190610867565b60405180910390f35b6000806100e9610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101219190610823565b60206040518083038186803b15801561013957600080fd5b505afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610699565b90508091505090565b60007f00000000000000000000000046b97d3c87e5fcceb85ff81785a2937a01743344905090565b6101aa6102ff565b4210156101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108a4565b60405180910390fd5b60006101f6610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022e9190610823565b60206040518083038186803b15801561024657600080fd5b505afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610699565b9050600081116102c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ba90610924565b60405180910390fd5b6102fc6102ce61017a565b826102d7610327565b73ffffffffffffffffffffffffffffffffffffffff1661034f9092919063ffffffff16565b50565b60007f00000000000000000000000000000000000000000000000000000000630f7770905090565b60007f000000000000000000000000aa2d8c9a8bd0f7945143bfd509be3ff23dd78918905090565b6103d08363a9059cbb60e01b848460405160240161036e92919061083e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103d5565b505050565b6000610437826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661049c9092919063ffffffff16565b90506000815111156104975780806020019051810190610457919061066c565b610496576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048d90610904565b60405180910390fd5b5b505050565b60606104ab84846000856104b4565b90509392505050565b6060824710156104f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f0906108c4565b60405180910390fd5b610502856105c8565b610541576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610538906108e4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161056a919061080c565b60006040518083038185875af1925050503d80600081146105a7576040519150601f19603f3d011682016040523d82523d6000602084013e6105ac565b606091505b50915091506105bc8282866105db565b92505050949350505050565b600080823b905060008111915050919050565b606083156105eb5782905061063b565b6000835111156105fe5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106329190610882565b60405180910390fd5b9392505050565b60008151905061065181610bbd565b92915050565b60008151905061066681610bd4565b92915050565b60006020828403121561068257610681610a42565b5b600061069084828501610642565b91505092915050565b6000602082840312156106af576106ae610a42565b5b60006106bd84828501610657565b91505092915050565b6106cf81610991565b82525050565b60006106e08261095f565b6106ea8185610975565b93506106fa818560208601610a0f565b80840191505092915050565b61070f816109d9565b82525050565b60006107208261096a565b61072a8185610980565b935061073a818560208601610a0f565b61074381610a47565b840191505092915050565b600061075b603283610980565b915061076682610a58565b604082019050919050565b600061077e602683610980565b915061078982610aa7565b604082019050919050565b60006107a1601d83610980565b91506107ac82610af6565b602082019050919050565b60006107c4602a83610980565b91506107cf82610b1f565b604082019050919050565b60006107e7602383610980565b91506107f282610b6e565b604082019050919050565b610806816109cf565b82525050565b600061081882846106d5565b915081905092915050565b600060208201905061083860008301846106c6565b92915050565b600060408201905061085360008301856106c6565b61086060208301846107fd565b9392505050565b600060208201905061087c6000830184610706565b92915050565b6000602082019050818103600083015261089c8184610715565b905092915050565b600060208201905081810360008301526108bd8161074e565b9050919050565b600060208201905081810360008301526108dd81610771565b9050919050565b600060208201905081810360008301526108fd81610794565b9050919050565b6000602082019050818103600083015261091d816107b7565b9050919050565b6000602082019050818103600083015261093d816107da565b9050919050565b600060208201905061095960008301846107fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061099c826109af565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109e4826109eb565b9050919050565b60006109f6826109fd565b9050919050565b6000610a08826109af565b9050919050565b60005b83811015610a2d578082015181840152602081019050610a12565b83811115610a3c576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610bc6816109a3565b8114610bd157600080fd5b50565b610bdd816109cf565b8114610be857600080fd5b5056fea26469706673582212203e63e96979253a59ac95f463be96d3464e11fc89e72e4d4c44a1c61a8e30935d64736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 11057, 3676, 2692, 2581, 2620, 29292, 2850, 18827, 2546, 16068, 9468, 21057, 2620, 2487, 2063, 2692, 2620, 2549, 2063, 2475, 2497, 27814, 2278, 2692, 2683, 2063, 19841, 2063, 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, 3074, 1997, 4972, 3141, 2000, 1996, 4769, 2828, 1008, 1013, 3075, 4769, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 2995, 2065, 1036, 4070, 1036, 2003, 1037, 3206, 1012, 1008, 1008, 1031, 2590, 1033, 1008, 1027, 1027, 1027, 1027, 1008, 2009, 2003, 25135, 2000, 7868, 2008, 2019, 4769, 2005, 2029, 2023, 3853, 5651, 1008, 6270, 2003, 2019, 27223, 1011, 3079, 4070, 1006, 1041, 10441, 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,972
0x97abDBEc66E4382bC4d9fA7D05aED600FD4Da5DD
pragma solidity =0.6.6; import './interfaces/IFomodexFactory.sol'; import '@uniswap/lib/contracts/libraries/TransferHelper.sol'; import './interfaces/IFomodexRouter02.sol'; import './libraries/FomodexLibrary.sol'; import './libraries/SafeMath.sol'; import './interfaces/IERC20.sol'; import './interfaces/IWETH.sol'; contract FomodexRouter is IFomodexRouter02 { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'FomodexRouter: EXPIRED'); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IFomodexFactory(factory).getPair(tokenA, tokenB) == address(0)) { IFomodexFactory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = FomodexLibrary.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = FomodexLibrary.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'FomodexRouter: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = FomodexLibrary.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'FomodexRouter: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = FomodexLibrary.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IFomodexPair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = FomodexLibrary.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IFomodexPair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = FomodexLibrary.pairFor(factory, tokenA, tokenB); IFomodexPair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IFomodexPair(pair).burn(to); (address token0,) = FomodexLibrary.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'FomodexRouter: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'FomodexRouter: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, 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 virtual override returns (uint amountA, uint amountB) { address pair = FomodexLibrary.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IFomodexPair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = FomodexLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IFomodexPair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = FomodexLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IFomodexPair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = FomodexLibrary.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? FomodexLibrary.pairFor(factory, output, path[i + 2]) : _to; IFomodexPair(FomodexLibrary.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = FomodexLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = FomodexLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'FomodexRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'FomodexRouter: INVALID_PATH'); amounts = FomodexLibrary.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'FomodexRouter: INVALID_PATH'); amounts = FomodexLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'FomodexRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'FomodexRouter: INVALID_PATH'); amounts = FomodexLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'FomodexRouter: INVALID_PATH'); amounts = FomodexLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'FomodexRouter: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(FomodexLibrary.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = FomodexLibrary.sortTokens(input, output); IFomodexPair pair = IFomodexPair(FomodexLibrary.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = FomodexLibrary.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? FomodexLibrary.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'FomodexRouter: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(FomodexLibrary.pairFor(factory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { require(path[path.length - 1] == WETH, 'FomodexRouter: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, FomodexLibrary.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'FomodexRouter: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return FomodexLibrary.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return FomodexLibrary.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return FomodexLibrary.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return FomodexLibrary.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return FomodexLibrary.getAmountsIn(factory, amountOut, path); } } pragma solidity >=0.5.0; interface IFomodexFactory { 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.6.0; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } pragma solidity >=0.6.2; import './IFomodexRouter01.sol'; interface IFomodexRouter02 is IFomodexRouter01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } pragma solidity >=0.5.0; import '../interfaces/IFomodexPair.sol'; import "./SafeMath.sol"; library FomodexLibrary { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'FomodexLibrary: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'FomodexLibrary: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'6b17f6c33349c7eaef1f6fbb2631b4d415285a9854dc23586b60ef019667b93f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); pairFor(factory, tokenA, tokenB); (uint reserve0, uint reserve1,) = IFomodexPair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'FomodexLibrary: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'FomodexLibrary: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'FomodexLibrary: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'FomodexLibrary: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(998); uint numerator = amountInWithFee.mul(reserveOut); uint 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(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'FomodexLibrary: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'FomodexLibrary: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(998); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'FomodexLibrary: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'FomodexLibrary: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } pragma solidity =0.6.6; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { 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.0; interface IERC20 { 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 IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } pragma solidity >=0.6.2; interface IFomodexRouter01 { 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.5.0; interface IFomodexPair { 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; }
0x60806040526004361061014f5760003560e01c80638803dbee116100b6578063c45a01551161006f578063c45a015514610a10578063d06ca61f14610a25578063ded9382a14610ada578063e8e3370014610b4d578063f305d71914610bcd578063fb3bdb4114610c1357610188565b80638803dbee146107df578063ad5c464814610875578063ad615dec146108a6578063af2979eb146108dc578063b6f9de951461092f578063baa2abde146109b357610188565b80634a25d94a116101085780634a25d94a146104f05780635b0d5984146105865780635c11d795146105f9578063791ac9471461068f5780637ff36ab51461072557806385f8c259146107a957610188565b806302751cec1461018d578063054d50d4146101f957806318cbafe5146102415780631f00ca74146103275780632195995c146103dc57806338ed17391461045a57610188565b3661018857336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2161461018657fe5b005b600080fd5b34801561019957600080fd5b506101e0600480360360c08110156101b057600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a00135610c97565b6040805192835260208301919091528051918290030190f35b34801561020557600080fd5b5061022f6004803603606081101561021c57600080fd5b5080359060208101359060400135610db1565b60408051918252519081900360200190f35b34801561024d57600080fd5b506102d7600480360360a081101561026457600080fd5b813591602081013591810190606081016040820135600160201b81111561028a57600080fd5b82018360208201111561029c57600080fd5b803590602001918460208302840111600160201b831117156102bd57600080fd5b91935091506001600160a01b038135169060200135610dc6565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103135781810151838201526020016102fb565b505050509050019250505060405180910390f35b34801561033357600080fd5b506102d76004803603604081101561034a57600080fd5b81359190810190604081016020820135600160201b81111561036b57600080fd5b82018360208201111561037d57600080fd5b803590602001918460208302840111600160201b8311171561039e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506110f3945050505050565b3480156103e857600080fd5b506101e0600480360361016081101561040057600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359091169060c08101359060e081013515159060ff6101008201351690610120810135906101400135611129565b34801561046657600080fd5b506102d7600480360360a081101561047d57600080fd5b813591602081013591810190606081016040820135600160201b8111156104a357600080fd5b8201836020820111156104b557600080fd5b803590602001918460208302840111600160201b831117156104d657600080fd5b91935091506001600160a01b038135169060200135611223565b3480156104fc57600080fd5b506102d7600480360360a081101561051357600080fd5b813591602081013591810190606081016040820135600160201b81111561053957600080fd5b82018360208201111561054b57600080fd5b803590602001918460208302840111600160201b8311171561056c57600080fd5b91935091506001600160a01b03813516906020013561136e565b34801561059257600080fd5b5061022f60048036036101408110156105aa57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a08101359060c081013515159060ff60e082013516906101008101359061012001356114fa565b34801561060557600080fd5b50610186600480360360a081101561061c57600080fd5b813591602081013591810190606081016040820135600160201b81111561064257600080fd5b82018360208201111561065457600080fd5b803590602001918460208302840111600160201b8311171561067557600080fd5b91935091506001600160a01b038135169060200135611608565b34801561069b57600080fd5b50610186600480360360a08110156106b257600080fd5b813591602081013591810190606081016040820135600160201b8111156106d857600080fd5b8201836020820111156106ea57600080fd5b803590602001918460208302840111600160201b8311171561070b57600080fd5b91935091506001600160a01b03813516906020013561189d565b6102d76004803603608081101561073b57600080fd5b81359190810190604081016020820135600160201b81111561075c57600080fd5b82018360208201111561076e57600080fd5b803590602001918460208302840111600160201b8311171561078f57600080fd5b91935091506001600160a01b038135169060200135611b21565b3480156107b557600080fd5b5061022f600480360360608110156107cc57600080fd5b5080359060208101359060400135611e74565b3480156107eb57600080fd5b506102d7600480360360a081101561080257600080fd5b813591602081013591810190606081016040820135600160201b81111561082857600080fd5b82018360208201111561083a57600080fd5b803590602001918460208302840111600160201b8311171561085b57600080fd5b91935091506001600160a01b038135169060200135611e81565b34801561088157600080fd5b5061088a611f7a565b604080516001600160a01b039092168252519081900360200190f35b3480156108b257600080fd5b5061022f600480360360608110156108c957600080fd5b5080359060208101359060400135611f9e565b3480156108e857600080fd5b5061022f600480360360c08110156108ff57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a00135611fab565b6101866004803603608081101561094557600080fd5b81359190810190604081016020820135600160201b81111561096657600080fd5b82018360208201111561097857600080fd5b803590602001918460208302840111600160201b8311171561099957600080fd5b91935091506001600160a01b03813516906020013561212c565b3480156109bf57600080fd5b506101e0600480360360e08110156109d657600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359091169060c001356124b8565b348015610a1c57600080fd5b5061088a6126fc565b348015610a3157600080fd5b506102d760048036036040811015610a4857600080fd5b81359190810190604081016020820135600160201b811115610a6957600080fd5b820183602082011115610a7b57600080fd5b803590602001918460208302840111600160201b83111715610a9c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612720945050505050565b348015610ae657600080fd5b506101e06004803603610140811015610afe57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a08101359060c081013515159060ff60e0820135169061010081013590610120013561274d565b348015610b5957600080fd5b50610baf6004803603610100811015610b7157600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359160c0820135169060e00135612861565b60408051938452602084019290925282820152519081900360600190f35b610baf600480360360c0811015610be357600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a0013561299d565b6102d760048036036080811015610c2957600080fd5b81359190810190604081016020820135600160201b811115610c4a57600080fd5b820183602082011115610c5c57600080fd5b803590602001918460208302840111600160201b83111715610c7d57600080fd5b91935091506001600160a01b038135169060200135612c42565b6000808242811015610cde576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b610d0d897f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a8a8a308a6124b8565b9093509150610d1d898685612fc4565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610d8357600080fd5b505af1158015610d97573d6000803e3d6000fd5b50505050610da5858361312e565b50965096945050505050565b6000610dbe848484613226565b949350505050565b60608142811015610e0c576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21686866000198101818110610e4657fe5b905060200201356001600160a01b03166001600160a01b031614610e9f576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b610efd7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061331692505050565b91508682600184510381518110610f1057fe5b60200260200101511015610f555760405162461bcd60e51b815260040180806020018281038252602981526020018061457f6029913960400191505060405180910390fd5b610ff386866000818110610f6557fe5b905060200201356001600160a01b031633610fd97f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8a8a6000818110610fa757fe5b905060200201356001600160a01b03168b8b6001818110610fc457fe5b905060200201356001600160a01b0316613462565b85600081518110610fe657fe5b6020026020010151613522565b6110328287878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525030925061367f915050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d8360018551038151811061107157fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156110af57600080fd5b505af11580156110c3573d6000803e3d6000fd5b505050506110e884836001855103815181106110db57fe5b602002602001015161312e565b509695505050505050565b60606111207f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f84846138c5565b90505b92915050565b60008060006111597f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8f8f613462565b9050600087611168578c61116c565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018c905260ff8a16608482015260a4810189905260c4810188905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b1580156111e257600080fd5b505af11580156111f6573d6000803e3d6000fd5b505050506112098f8f8f8f8f8f8f6124b8565b809450819550505050509b509b9950505050505050505050565b60608142811015611269576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6112c77f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061331692505050565b915086826001845103815181106112da57fe5b6020026020010151101561131f5760405162461bcd60e51b815260040180806020018281038252602981526020018061457f6029913960400191505060405180910390fd5b61132f86866000818110610f6557fe5b6110e88287878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525089925061367f915050565b606081428110156113b4576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216868660001981018181106113ee57fe5b905060200201356001600160a01b03166001600160a01b031614611447576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b6114a57f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506138c592505050565b915086826000815181106114b557fe5b60200260200101511115610f555760405162461bcd60e51b81526004018080602001828103825260258152602001806144606025913960400191505060405180910390fd5b6000806115487f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613462565b9050600086611557578b61155b565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018b905260ff8916608482015260a4810188905260c4810187905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b1580156115d157600080fd5b505af11580156115e5573d6000803e3d6000fd5b505050506115f78d8d8d8d8d8d611fab565b9d9c50505050505050505050505050565b804281101561164c576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6116c18585600081811061165c57fe5b905060200201356001600160a01b0316336116bb7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8989600081811061169e57fe5b905060200201356001600160a01b03168a8a6001818110610fc457fe5b8a613522565b6000858560001981018181106116d357fe5b905060200201356001600160a01b03166001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561173857600080fd5b505afa15801561174c573d6000803e3d6000fd5b505050506040513d602081101561176257600080fd5b505160408051602088810282810182019093528882529293506117a49290918991899182918501908490808284376000920191909152508892506139fd915050565b8661185682888860001981018181106117b957fe5b905060200201356001600160a01b03166001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561181e57600080fd5b505afa158015611832573d6000803e3d6000fd5b505050506040513d602081101561184857600080fd5b50519063ffffffff613d0816565b10156118935760405162461bcd60e51b815260040180806020018281038252602981526020018061457f6029913960400191505060405180910390fd5b5050505050505050565b80428110156118e1576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168585600019810181811061191b57fe5b905060200201356001600160a01b03166001600160a01b031614611974576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b6119848585600081811061165c57fe5b6119c28585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506139fd915050565b604080516370a0823160e01b815230600482015290516000916001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216916370a0823191602480820192602092909190829003018186803b158015611a2c57600080fd5b505afa158015611a40573d6000803e3d6000fd5b505050506040513d6020811015611a5657600080fd5b5051905086811015611a995760405162461bcd60e51b815260040180806020018281038252602981526020018061457f6029913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611aff57600080fd5b505af1158015611b13573d6000803e3d6000fd5b50505050611893848261312e565b60608142811015611b67576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031686866000818110611b9e57fe5b905060200201356001600160a01b03166001600160a01b031614611bf7576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b611c557f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f3488888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061331692505050565b91508682600184510381518110611c6857fe5b60200260200101511015611cad5760405162461bcd60e51b815260040180806020018281038252602981526020018061457f6029913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db083600081518110611ce957fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611d1c57600080fd5b505af1158015611d30573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb611d957f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8989600081811061169e57fe5b84600081518110611da257fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015611df957600080fd5b505af1158015611e0d573d6000803e3d6000fd5b505050506040513d6020811015611e2357600080fd5b5051611e2b57fe5b611e6a8287878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525089925061367f915050565b5095945050505050565b6000610dbe848484613d58565b60608142811015611ec7576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b611f257f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506138c592505050565b91508682600081518110611f3557fe5b6020026020010151111561131f5760405162461bcd60e51b81526004018080602001828103825260258152602001806144606025913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6000610dbe848484613e48565b60008142811015611ff1576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b612020887f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc289898930896124b8565b604080516370a0823160e01b815230600482015290519194506120a492508a9187916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561207357600080fd5b505afa158015612087573d6000803e3d6000fd5b505050506040513d602081101561209d57600080fd5b5051612fc4565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561210a57600080fd5b505af115801561211e573d6000803e3d6000fd5b505050506110e8848361312e565b8042811015612170576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316858560008181106121a757fe5b905060200201356001600160a01b03166001600160a01b031614612200576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b60003490507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561226057600080fd5b505af1158015612274573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb6122d97f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8989600081811061169e57fe5b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561232957600080fd5b505af115801561233d573d6000803e3d6000fd5b505050506040513d602081101561235357600080fd5b505161235b57fe5b60008686600019810181811061236d57fe5b905060200201356001600160a01b03166001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156123d257600080fd5b505afa1580156123e6573d6000803e3d6000fd5b505050506040513d60208110156123fc57600080fd5b5051604080516020898102828101820190935289825292935061243e9290918a918a9182918501908490808284376000920191909152508992506139fd915050565b87611856828989600019810181811061245357fe5b905060200201356001600160a01b03166001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561181e57600080fd5b60008082428110156124ff576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b600061252c7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8c8c613462565b604080516323b872dd60e01b81523360048201526001600160a01b03831660248201819052604482018d9052915192935090916323b872dd916064808201926020929091908290030181600087803b15801561258757600080fd5b505af115801561259b573d6000803e3d6000fd5b505050506040513d60208110156125b157600080fd5b50506040805163226bf2d160e21b81526001600160a01b03888116600483015282516000938493928616926389afcb44926024808301939282900301818787803b1580156125fe57600080fd5b505af1158015612612573d6000803e3d6000fd5b505050506040513d604081101561262857600080fd5b508051602090910151909250905060006126428e8e613ef4565b509050806001600160a01b03168e6001600160a01b031614612665578183612668565b82825b90975095508a8710156126ac5760405162461bcd60e51b81526004018080602001828103825260248152602001806144136024913960400191505060405180910390fd5b898610156126eb5760405162461bcd60e51b81526004018080602001828103825260248152602001806143ef6024913960400191505060405180910390fd5b505050505097509795505050505050565b7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f81565b60606111207f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8484613316565b600080600061279d7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8e7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613462565b90506000876127ac578c6127b0565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018c905260ff8a16608482015260a4810189905260c4810188905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b15801561282657600080fd5b505af115801561283a573d6000803e3d6000fd5b5050505061284c8e8e8e8e8e8e610c97565b909f909e509c50505050505050505050505050565b600080600083428110156128aa576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b6128b88c8c8c8c8c8c613fd2565b909450925060006128ea7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8e8e613462565b90506128f88d338388613522565b6129048c338387613522565b806001600160a01b0316636a627842886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b15801561295c57600080fd5b505af1158015612970573d6000803e3d6000fd5b505050506040513d602081101561298657600080fd5b5051949d939c50939a509198505050505050505050565b600080600083428110156129e6576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b612a148a7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28b348c8c613fd2565b90945092506000612a667f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8c7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613462565b9050612a748b338388613522565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b158015612acf57600080fd5b505af1158015612ae3573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb82866040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b505050506040513d6020811015612b9257600080fd5b5051612b9a57fe5b806001600160a01b0316636a627842886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b158015612bf257600080fd5b505af1158015612c06573d6000803e3d6000fd5b505050506040513d6020811015612c1c57600080fd5b5051925034841015612c3457612c343385340361312e565b505096509650969350505050565b60608142811015612c88576040805162461bcd60e51b81526020600482015260166024820152600080516020614485833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031686866000818110612cbf57fe5b905060200201356001600160a01b03166001600160a01b031614612d18576040805162461bcd60e51b815260206004820152601b6024820152600080516020614511833981519152604482015290519081900360640190fd5b612d767f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f888888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506138c592505050565b91503482600081518110612d8657fe5b60200260200101511115612dcb5760405162461bcd60e51b81526004018080602001828103825260258152602001806144606025913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db083600081518110612e0757fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015612e3a57600080fd5b505af1158015612e4e573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb612eb37f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8989600081811061169e57fe5b84600081518110612ec057fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612f1757600080fd5b505af1158015612f2b573d6000803e3d6000fd5b505050506040513d6020811015612f4157600080fd5b5051612f4957fe5b612f888287878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525089925061367f915050565b81600081518110612f9557fe5b6020026020010151341115611e6a57611e6a3383600081518110612fb557fe5b6020026020010151340361312e565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b602083106130415780518252601f199092019160209182019101613022565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146130a3576040519150601f19603f3d011682016040523d82523d6000602084013e6130a8565b606091505b50915091508180156130d65750805115806130d657508080602001905160208110156130d357600080fd5b50515b613127576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b6020831061317a5780518252601f19909201916020918201910161315b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146131dc576040519150601f19603f3d011682016040523d82523d6000602084013e6131e1565b606091505b50509050806132215760405162461bcd60e51b81526004018080602001828103825260238152602001806144ee6023913960400191505060405180910390fd5b505050565b60008084116132665760405162461bcd60e51b81526004018080602001828103825260298152602001806144376029913960400191505060405180910390fd5b6000831180156132765750600082115b6132b15760405162461bcd60e51b81526004018080602001828103825260268152602001806144c86026913960400191505060405180910390fd5b60006132c5856103e663ffffffff61424616565b905060006132d9828563ffffffff61424616565b905060006132ff836132f3886103e863ffffffff61424616565b9063ffffffff6142a916565b905080828161330a57fe5b04979650505050505050565b606060028251101561336f576040805162461bcd60e51b815260206004820152601c60248201527f466f6d6f6465784c6962726172793a20494e56414c49445f5041544800000000604482015290519081900360640190fd5b815167ffffffffffffffff8111801561338757600080fd5b506040519080825280602002602001820160405280156133b1578160200160208202803683370190505b50905082816000815181106133c257fe5b60200260200101818152505060005b600183510381101561345a57600080613414878685815181106133f057fe5b602002602001015187866001018151811061340757fe5b60200260200101516142f8565b9150915061343684848151811061342757fe5b60200260200101518383613226565b84846001018151811061344557fe5b602090810291909101015250506001016133d1565b509392505050565b60008060006134718585613ef4565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f6b17f6c33349c7eaef1f6fbb2631b4d415285a9854dc23586b60ef019667b93f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b602083106135a75780518252601f199092019160209182019101613588565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613609576040519150601f19603f3d011682016040523d82523d6000602084013e61360e565b606091505b509150915081801561363c57508051158061363c575080806020019051602081101561363957600080fd5b50515b6136775760405162461bcd60e51b815260040180806020018281038252602481526020018061455b6024913960400191505060405180910390fd5b505050505050565b60005b60018351038110156138bf5760008084838151811061369d57fe5b60200260200101518584600101815181106136b457fe5b60200260200101519150915060006136cc8383613ef4565b50905060008785600101815181106136e057fe5b60200260200101519050600080836001600160a01b0316866001600160a01b03161461370e57826000613712565b6000835b91509150600060028a51038810613729578861376a565b61376a7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f878c8b6002018151811061375d57fe5b6020026020010151613462565b90506137977f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8888613462565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156137d4576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561384557818101518382015260200161382d565b50505050905090810190601f1680156138725780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561389457600080fd5b505af11580156138a8573d6000803e3d6000fd5b505060019099019850613682975050505050505050565b50505050565b606060028251101561391e576040805162461bcd60e51b815260206004820152601c60248201527f466f6d6f6465784c6962726172793a20494e56414c49445f5041544800000000604482015290519081900360640190fd5b815167ffffffffffffffff8111801561393657600080fd5b50604051908082528060200260200182016040528015613960578160200160208202803683370190505b509050828160018351038151811061397457fe5b60209081029190910101528151600019015b801561345a576000806139b6878660018603815181106139a257fe5b602002602001015187868151811061340757fe5b915091506139d88484815181106139c957fe5b60200260200101518383613d58565b8460018503815181106139e757fe5b6020908102919091010152505060001901613986565b60005b600183510381101561322157600080848381518110613a1b57fe5b6020026020010151858460010181518110613a3257fe5b6020026020010151915091506000613a4a8383613ef4565b5090506000613a7a7f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8585613462565b9050600080600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015613abb57600080fd5b505afa158015613acf573d6000803e3d6000fd5b505050506040513d6060811015613ae557600080fd5b5080516020909101516001600160701b0391821693501690506000806001600160a01b038a811690891614613b1b578284613b1e565b83835b91509150613b7c828b6001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561181e57600080fd5b9550613b89868383613226565b945050505050600080856001600160a01b0316886001600160a01b031614613bb357826000613bb7565b6000835b91509150600060028c51038a10613bce578a613c02565b613c027f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f898e8d6002018151811061375d57fe5b604080516000808252602082019283905263022c0d9f60e01b835260248201878152604483018790526001600160a01b038086166064850152608060848501908152845160a48601819052969750908c169563022c0d9f958a958a958a9591949193919260c486019290918190849084905b83811015613c8c578181015183820152602001613c74565b50505050905090810190601f168015613cb95780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015613cdb57600080fd5b505af1158015613cef573d6000803e3d6000fd5b50506001909b019a50613a009950505050505050505050565b80820382811115611123576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6000808411613d985760405162461bcd60e51b815260040180806020018281038252602a815260200180614531602a913960400191505060405180910390fd5b600083118015613da85750600082115b613de35760405162461bcd60e51b81526004018080602001828103825260268152602001806144c86026913960400191505060405180910390fd5b6000613e076103e8613dfb868863ffffffff61424616565b9063ffffffff61424616565b90506000613e216103e6613dfb868963ffffffff613d0816565b9050613e3e6001828481613e3157fe5b049063ffffffff6142a916565b9695505050505050565b6000808411613e885760405162461bcd60e51b81526004018080602001828103825260238152602001806144a56023913960400191505060405180910390fd5b600083118015613e985750600082115b613ed35760405162461bcd60e51b81526004018080602001828103825260268152602001806144c86026913960400191505060405180910390fd5b82613ee4858463ffffffff61424616565b81613eeb57fe5b04949350505050565b600080826001600160a01b0316846001600160a01b03161415613f485760405162461bcd60e51b81526004018080602001828103825260238152602001806143cc6023913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031610613f68578284613f6b565b83835b90925090506001600160a01b038216613fcb576040805162461bcd60e51b815260206004820152601c60248201527f466f6d6f6465784c6962726172793a205a45524f5f4144445245535300000000604482015290519081900360640190fd5b9250929050565b6040805163e6a4390560e01b81526001600160a01b03888116600483015287811660248301529151600092839283927f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f9092169163e6a4390591604480820192602092909190829003018186803b15801561404c57600080fd5b505afa158015614060573d6000803e3d6000fd5b505050506040513d602081101561407657600080fd5b50516001600160a01b0316141561412957604080516364e329cb60e11b81526001600160a01b038a81166004830152898116602483015291517f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f9092169163c9c65396916044808201926020929091908290030181600087803b1580156140fc57600080fd5b505af1158015614110573d6000803e3d6000fd5b505050506040513d602081101561412657600080fd5b50505b6000806141577f0000000000000000000000000c824c7e6edbf50996b7fcdd2c767a7f7f36bc6f8b8b6142f8565b91509150816000148015614169575080155b1561417957879350869250614239565b6000614186898484613e48565b90508781116141d957858110156141ce5760405162461bcd60e51b81526004018080602001828103825260248152602001806143ef6024913960400191505060405180910390fd5b889450925082614237565b60006141e6898486613e48565b9050898111156141f257fe5b878110156142315760405162461bcd60e51b81526004018080602001828103825260248152602001806144136024913960400191505060405180910390fd5b94508793505b505b5050965096945050505050565b60008115806142615750508082028282828161425e57fe5b04145b611123576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b80820182811015611123576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b60008060006143078585613ef4565b509050614315868686613462565b50600080614324888888613462565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561435c57600080fd5b505afa158015614370573d6000803e3d6000fd5b505050506040513d606081101561438657600080fd5b5080516020909101516001600160701b0391821693501690506001600160a01b03878116908416146143b95780826143bc565b81815b9099909850965050505050505056fe466f6d6f6465784c6962726172793a204944454e544943414c5f414444524553534553466f6d6f646578526f757465723a20494e53554646494349454e545f425f414d4f554e54466f6d6f646578526f757465723a20494e53554646494349454e545f415f414d4f554e54466f6d6f6465784c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e54466f6d6f646578526f757465723a204558434553534956455f494e5055545f414d4f554e54466f6d6f646578526f757465723a204558504952454400000000000000000000466f6d6f6465784c6962726172793a20494e53554646494349454e545f414d4f554e54466f6d6f6465784c6962726172793a20494e53554646494349454e545f4c49515549444954595472616e7366657248656c7065723a204554485f5452414e534645525f4641494c4544466f6d6f646578526f757465723a20494e56414c49445f504154480000000000466f6d6f6465784c6962726172793a20494e53554646494349454e545f4f55545055545f414d4f554e545472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544466f6d6f646578526f757465723a20494e53554646494349454e545f4f55545055545f414d4f554e54a2646970667358221220b719a89c594beed98fc32ca975bf6c1c7aa56b90aefdb57e25f878675df471aa64736f6c63430006060033
{"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, 2581, 7875, 18939, 8586, 28756, 2063, 23777, 2620, 2475, 9818, 2549, 2094, 2683, 7011, 2581, 2094, 2692, 2629, 6679, 2094, 16086, 2692, 2546, 2094, 2549, 2850, 2629, 14141, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1020, 1012, 1020, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 2065, 19506, 3207, 2595, 21450, 1012, 14017, 1005, 1025, 12324, 1005, 1030, 4895, 2483, 4213, 2361, 1013, 5622, 2497, 1013, 8311, 1013, 8860, 1013, 4651, 16001, 4842, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 19706, 1013, 2065, 19506, 3207, 2595, 22494, 3334, 2692, 2475, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 8860, 1013, 1042, 19506, 3207, 2595, 29521, 19848, 2100, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 8860, 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,973
0x97abee33cd075c58bfdd174e0885e08e8f03556f
pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract SENTToken is ERC20 { constructor( string memory name, string memory symbol, uint256 initialSupply ) ERC20(name, symbol) { _mint(msg.sender, initialSupply); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012357806370a082311461013657806395d89b411461015f578063a457c2d714610167578063a9059cbb1461017a578063dd62ed3e1461018d57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c6565b6040516100c391906107e1565b60405180910390f35b6100df6100da3660046107b8565b610258565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f36600461077d565b61026e565b604051601281526020016100c3565b6100df6101313660046107b8565b610324565b6100f361014436600461072a565b6001600160a01b031660009081526020819052604090205490565b6100b661035b565b6100df6101753660046107b8565b61036a565b6100df6101883660046107b8565b610405565b6100f361019b36600461074b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101d590610863565b80601f016020809104026020016040519081016040528092919081815260200182805461020190610863565b801561024e5780601f106102235761010080835404028352916020019161024e565b820191906000526020600020905b81548152906001019060200180831161023157829003601f168201915b5050505050905090565b6000610265338484610412565b50600192915050565b600061027b848484610536565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103055760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103198533610314868561084c565b610412565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610265918590610314908690610834565b6060600480546101d590610863565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156103ec5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016102fc565b6103fb3385610314868561084c565b5060019392505050565b6000610265338484610536565b6001600160a01b0383166104745760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016102fc565b6001600160a01b0382166104d55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016102fc565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831661059a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016102fc565b6001600160a01b0382166105fc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016102fc565b6001600160a01b038316600090815260208190526040902054818110156106745760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016102fc565b61067e828261084c565b6001600160a01b0380861660009081526020819052604080822093909355908516815290812080548492906106b4908490610834565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161070091815260200190565b60405180910390a350505050565b80356001600160a01b038116811461072557600080fd5b919050565b60006020828403121561073b578081fd5b6107448261070e565b9392505050565b6000806040838503121561075d578081fd5b6107668361070e565b91506107746020840161070e565b90509250929050565b600080600060608486031215610791578081fd5b61079a8461070e565b92506107a86020850161070e565b9150604084013590509250925092565b600080604083850312156107ca578182fd5b6107d38361070e565b946020939093013593505050565b6000602080835283518082850152825b8181101561080d578581018301518582016040015282016107f1565b8181111561081e5783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108475761084761089e565b500190565b60008282101561085e5761085e61089e565b500390565b600181811c9082168061087757607f821691505b6020821081141561089857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212200a7d2492cc64fb7a272475ddc396477d21aed2e69d629663b5e7c53d185628da64736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 16336, 2063, 22394, 19797, 2692, 23352, 2278, 27814, 29292, 14141, 16576, 2549, 2063, 2692, 2620, 27531, 2063, 2692, 2620, 2063, 2620, 2546, 2692, 19481, 26976, 2546, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 3206, 2741, 18715, 2368, 2003, 9413, 2278, 11387, 1063, 9570, 2953, 1006, 5164, 3638, 2171, 1010, 5164, 3638, 6454, 1010, 21318, 3372, 17788, 2575, 20381, 6279, 22086, 1007, 9413, 2278, 11387, 1006, 2171, 1010, 6454, 1007, 1063, 1035, 12927, 1006, 5796, 2290, 1012, 4604, 2121, 1010, 20381, 6279, 22086, 1007, 1025, 1065, 1065, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 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,974
0x97ad070879be5c31a03a1fe7e35dfb7d51d0eef1
// 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; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract CatDogInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'CatDog Inu'; string private _symbol = 'CDINU'; uint8 private _decimals = 8; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a10565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610ae9565b6040518082815260200191505060405180910390f35b61035b610b6d565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b84565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c37565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cf3565b6040518082815260200191505060405180910390f35b610486610dde565b005b610490610f64565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f8d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061102f565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110fc565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111a565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611170565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111f7565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611511565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061171c565b005b60006107af611aa6565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806131c6602c913960400191505060405180910390fd5b600061085f83611aae565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b0690919063ffffffff16565b60068190555061092a83600754611b5090919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611aa6565b8484611bd8565b6001905092915050565b6000600754905090565b600068056bc75e2d63100000905090565b6000610a1d848484611dcf565b610ade84610a29611aa6565b610ad98560405180606001604052806028815260200161312c60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a8f611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b600190509392505050565b6000600654821115610b46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613099602a913960400191505060405180910390fd5b6000610b506122e8565b9050610b65818461231390919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2d610b91611aa6565b84610c288560036000610ba2611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b611bd8565b6001905092915050565b600068056bc75e2d63100000831115610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610cd7576000610cc884611aae565b50505050905080915050610ced565b6000610ce284611aae565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d8e57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610dd9565b610dd6600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b90505b919050565b610de6611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ea6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110255780601f10610ffa57610100808354040283529160200191611025565b820191906000526020600020905b81548152906001019060200180831161100857829003601f168201915b5050505050905090565b60006110f261103c611aa6565b846110ed856040518060600160405280602581526020016131f26025913960036000611066611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b6001905092915050565b6000611110611109611aa6565b8484611dcf565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111ff611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561137f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156114535761140f600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611519611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561165f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806130c36026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611724611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aa2578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a955760056001600580549050038154811061193357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061196b57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a5b57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aa2565b80806001019150506118a6565b5050565b600033905090565b6000806000806000806000611ac28861235d565b915091506000611ad06122e8565b90506000806000611ae28c86866123af565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b4883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612228565b905092915050565b600080828401905083811015611bce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806131a26024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ce4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806130e96022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e55576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061317d6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806130766023913960400191505060405180910390fd5b60008111611f34576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806131546029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fd75750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611fec57611fe783838361240d565b612223565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561208f5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120a45761209f838383612660565b612222565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156121485750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561215d576121588383836128b3565b612221565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121ff5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122145761220f838383612a71565b612220565b61221f8383836128b3565b5b5b5b5b505050565b60008383111582906122d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561229a57808201518184015260208101905061227f565b50505050905090810190601f1680156122c75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006122f5612d59565b9150915061230c818361231390919063ffffffff16565b9250505090565b600061235583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612eef565b905092915050565b6000806000612389600261237b60648761231390919063ffffffff16565b612fb590919063ffffffff16565b905060006123a08286611b0690919063ffffffff16565b90508082935093505050915091565b6000806000806123c88588612fb590919063ffffffff16565b905060006123df8688612fb590919063ffffffff16565b905060006123f68284611b0690919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061241e86611aae565b9450945094509450945061247a86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250f85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a484600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125f1838261303b565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267186611aae565b945094509450945094506126cd85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276282600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127f784600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612844838261303b565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128c486611aae565b9450945094509450945061292085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129b584600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a02838261303b565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8286611aae565b94509450945094509450612ade86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c0882600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cea838261303b565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060006006549050600068056bc75e2d63100000905060005b600580549050811015612ea457612e0a6001600060058481548110612d9557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b0690919063ffffffff16565b9250612e956002600060058481548110612e2057fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b0690919063ffffffff16565b91508080600101915050612d74565b50612ec368056bc75e2d6310000060065461231390919063ffffffff16565b821015612ee25760065468056bc75e2d63100000935093505050612eeb565b81819350935050505b9091565b60008083118290612f9b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f60578082015181840152602081019050612f45565b50505050905090810190601f168015612f8d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612fa757fe5b049050809150509392505050565b600080831415612fc85760009050613035565b6000828402905082848281612fd957fe5b0414613030576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061310b6021913960400191505060405180910390fd5b809150505b92915050565b61305082600654611b0690919063ffffffff16565b60068190555061306b81600754611b5090919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122026a598f18a021f8486a2eed537ca983d56cf81f4c6995c688f30e5e83200725d64736f6c634300060c0033
{"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, 2581, 4215, 2692, 19841, 2620, 2581, 2683, 4783, 2629, 2278, 21486, 2050, 2692, 2509, 27717, 7959, 2581, 2063, 19481, 20952, 2497, 2581, 2094, 22203, 2094, 2692, 4402, 2546, 2487, 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, 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, 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,975
0x97Ad1e4742073Db4998F6bc649BfEEDaF4EcDec3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./ENS.sol"; // ███╗░░██╗██╗███████╗████████╗██╗░░░██╗██╗░░██╗██╗████████╗  ██╗░░░██╗██████╗░ // ████╗░██║██║██╔════╝╚══██╔══╝╚██╗░██╔╝██║░██╔╝██║╚══██╔══╝  ██║░░░██║╚════██╗ // ██╔██╗██║██║█████╗░░░░░██║░░░░╚████╔╝░█████═╝░██║░░░██║░░░  ╚██╗░██╔╝░░███╔═╝ // ██║╚████║██║██╔══╝░░░░░██║░░░░░╚██╔╝░░██╔═██╗░██║░░░██║░░░  ░╚████╔╝░██╔══╝░░ // ██║░╚███║██║██║░░░░░░░░██║░░░░░░██║░░░██║░╚██╗██║░░░██║░░░  ░░╚██╔╝░░███████╗ // ╚═╝░░╚══╝╚═╝╚═╝░░░░░░░░╚═╝░░░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░░╚═╝░░░  ░░░╚═╝░░░╚══════╝ contract DropKitCollection is ERC721, ERC721Enumerable, Ownable { using Address for address; using SafeMath for uint256; using MerkleProof for bytes32[]; ENS ens = ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e); uint256 public immutable _maxAmount; uint256 public _maxPerMint; uint256 public _maxPerWallet; uint256 public _price; string internal _tokenBaseURI; bytes32 internal _merkleRoot; mapping(address => uint256) internal _mintCount; bool public started = false; uint256 public totalRevenue = 0; uint256 public niftyKitFees = 0; uint256 public feesClaimed = 0; uint256 private constant _commissionRate = 500; // parts per 10,000 bytes32 private constant _niftyKit = 0xc5d1114c6023fd78e89dca4228d59c42fde243eba4d98bb8798037216662dd21; // namehash constructor( string memory name, string memory symbol, uint256 maxAmount, uint256 maxPerMint, uint256 maxPerWallet, uint256 price, string memory tokenBaseURI ) ERC721(name, symbol) { _maxAmount = maxAmount; _maxPerMint = maxPerMint; _maxPerWallet = maxPerWallet; _price = price; _tokenBaseURI = tokenBaseURI; } function mint(uint256 numberOfTokens) public payable { require(started == true, "Sale must be active"); require(numberOfTokens <= _maxPerMint, "Exceeded maximum per mint"); require(numberOfTokens > 0, "Must mint greater than 0"); require( _mintCount[_msgSender()] <= _maxPerWallet, "Exceeded maximum per wallet" ); require( totalSupply().add(numberOfTokens) <= _maxAmount, "Exceeded max supply" ); require( _price.mul(numberOfTokens) == msg.value, "Value sent is not correct" ); niftyKitFees = niftyKitFees.add(commissionAmount(_price.mul(numberOfTokens))); totalRevenue = totalRevenue.add(msg.value); _mintCount[_msgSender()].add(numberOfTokens); _mint(numberOfTokens, _msgSender()); } function presaleMint(uint256 numberOfTokens, bytes32[] calldata proof) public payable { require(_verify(_leaf(_msgSender()), proof), "Not part of list"); require(numberOfTokens <= _maxPerMint, "Exceeded maximum per mint"); require(numberOfTokens > 0, "Must mint greater than 0"); require( _mintCount[_msgSender()] <= _maxPerWallet, "Exceeded maximum per wallet" ); require( totalSupply().add(numberOfTokens) <= _maxAmount, "Exceeded max supply" ); require( _price.mul(numberOfTokens) == msg.value, "Value sent is not correct" ); niftyKitFees = niftyKitFees.add(commissionAmount(_price.mul(numberOfTokens))); totalRevenue = totalRevenue.add(msg.value); _mintCount[_msgSender()].add(numberOfTokens); _mint(numberOfTokens, _msgSender()); } function airdrop(uint256 numberOfTokens, address recipient) public payable onlyOwner { require( totalSupply().add(numberOfTokens) <= _maxAmount, "Exceeded max supply" ); require( commissionAmount(_price.mul(numberOfTokens)) == msg.value, "Value sent is not correct" ); niftyKitFees = niftyKitFees.add(commissionAmount(_price.mul(numberOfTokens))); _mint(numberOfTokens, recipient); } function start() public onlyOwner { require(started == false, "Sale is already started"); started = true; } function pause() public onlyOwner { require(started == true, "Sale is already paused"); started = false; } function setMerkleRoot(bytes32 root) external onlyOwner { _merkleRoot = root; } function withdraw() public { require(address(this).balance > 0, "Nothing to withdraw"); Resolver resolver = ens.resolver(_niftyKit); uint256 balance = address(this).balance; uint256 commission = niftyKitFees - feesClaimed; Address.sendValue(payable(owner()), balance - commission); Address.sendValue(payable(resolver.addr(_niftyKit)), commission); feesClaimed = feesClaimed.add(commission); } function setBaseURI(string memory newBaseURI) public onlyOwner { _tokenBaseURI = newBaseURI; } function setParameters( uint256 maxPerMint, uint256 maxPerWallet, uint256 price ) public onlyOwner { _maxPerMint = maxPerMint; _maxPerWallet = maxPerWallet; _price = price; } function commissionAmount(uint256 amount) public pure returns (uint256) { return ((_commissionRate * amount) / 10000); } function _baseURI() internal view virtual override returns (string memory) { return _tokenBaseURI; } function _mint(uint256 numberOfTokens, address sender) internal { for (uint256 i = 0; i < numberOfTokens; i++) { uint256 mintIndex = totalSupply() + 1; _safeMint(sender, mintIndex); } } function _leaf(address wallet) internal pure returns (bytes32) { return keccak256(abi.encodePacked(wallet)); } function _verify(bytes32 leaf, bytes32[] memory proof) internal view returns (bool) { return MerkleProof.verify(proof, _merkleRoot, leaf); } // 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 supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // 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; // 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 "./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 "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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.4; abstract contract ENS { function resolver(bytes32 node) public view virtual returns (Resolver); } abstract contract Resolver { function addr(bytes32 node) public view virtual returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // 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); }
0x60806040526004361061021a5760003560e01c806378a0ee8611610123578063a22cb465116100ab578063c596bc641161006f578063c596bc641461077f578063c87b56dd146107aa578063e3e1e8ef146107e7578063e985e9c514610803578063f2fde38b146108405761021a565b8063a22cb465146106cf578063b88d4fde146106f8578063bc63f02e14610721578063be9a65551461073d578063bf2d9e0b146107545761021a565b80638456cb59116100f25780638456cb59146106095780638da5cb5b1461062057806395d89b411461064b5780639c86bae414610676578063a0712d68146106b35761021a565b806378a0ee861461055f5780637cb647591461058a5780637e6decae146105b35780637fa8e5e4146105de5761021a565b806334c5d2ce116101a65780634f6ccce7116101755780634f6ccce71461046857806355f804b3146104a55780636352211e146104ce57806370a082311461050b578063715018a6146105485761021a565b806334c5d2ce146103d457806339f8db9a146103fd5780633ccfd60b1461042857806342842e0e1461043f5761021a565b806318160ddd116101ed57806318160ddd146102ed5780631f2698ab14610318578063235b6ea11461034357806323b872dd1461036e5780632f745c59146103975761021a565b806301ffc9a71461021f57806306fdde031461025c578063081812fc14610287578063095ea7b3146102c4575b600080fd5b34801561022b57600080fd5b5061024660048036038101906102419190613a42565b610869565b604051610253919061423b565b60405180910390f35b34801561026857600080fd5b5061027161087b565b60405161027e9190614271565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a99190613afe565b61090d565b6040516102bb91906141d4565b60405180910390f35b3480156102d057600080fd5b506102eb60048036038101906102e691906139dd565b610992565b005b3480156102f957600080fd5b50610302610aaa565b60405161030f9190614653565b60405180910390f35b34801561032457600080fd5b5061032d610ab7565b60405161033a919061423b565b60405180910390f35b34801561034f57600080fd5b50610358610aca565b6040516103659190614653565b60405180910390f35b34801561037a57600080fd5b50610395600480360381019061039091906138d7565b610ad0565b005b3480156103a357600080fd5b506103be60048036038101906103b991906139dd565b610b30565b6040516103cb9190614653565b60405180910390f35b3480156103e057600080fd5b506103fb60048036038101906103f69190613bbb565b610bd5565b005b34801561040957600080fd5b50610412610c6b565b60405161041f9190614653565b60405180910390f35b34801561043457600080fd5b5061043d610c71565b005b34801561044b57600080fd5b50610466600480360381019061046191906138d7565b610e90565b005b34801561047457600080fd5b5061048f600480360381019061048a9190613afe565b610eb0565b60405161049c9190614653565b60405180910390f35b3480156104b157600080fd5b506104cc60048036038101906104c79190613abd565b610f47565b005b3480156104da57600080fd5b506104f560048036038101906104f09190613afe565b610fdd565b60405161050291906141d4565b60405180910390f35b34801561051757600080fd5b50610532600480360381019061052d9190613849565b61108f565b60405161053f9190614653565b60405180910390f35b34801561055457600080fd5b5061055d611147565b005b34801561056b57600080fd5b506105746111cf565b6040516105819190614653565b60405180910390f35b34801561059657600080fd5b506105b160048036038101906105ac9190613a19565b6111d5565b005b3480156105bf57600080fd5b506105c861125b565b6040516105d59190614653565b60405180910390f35b3480156105ea57600080fd5b506105f361127f565b6040516106009190614653565b60405180910390f35b34801561061557600080fd5b5061061e611285565b005b34801561062c57600080fd5b50610635611374565b60405161064291906141d4565b60405180910390f35b34801561065757600080fd5b5061066061139e565b60405161066d9190614271565b60405180910390f35b34801561068257600080fd5b5061069d60048036038101906106989190613afe565b611430565b6040516106aa9190614653565b60405180910390f35b6106cd60048036038101906106c89190613afe565b611454565b005b3480156106db57600080fd5b506106f660048036038101906106f191906139a1565b61174f565b005b34801561070457600080fd5b5061071f600480360381019061071a9190613926565b6118d0565b005b61073b60048036038101906107369190613b27565b611932565b005b34801561074957600080fd5b50610752611acd565b005b34801561076057600080fd5b50610769611bbc565b6040516107769190614653565b60405180910390f35b34801561078b57600080fd5b50610794611bc2565b6040516107a19190614653565b60405180910390f35b3480156107b657600080fd5b506107d160048036038101906107cc9190613afe565b611bc8565b6040516107de9190614271565b60405180910390f35b61080160048036038101906107fc9190613b63565b611c6f565b005b34801561080f57600080fd5b5061082a6004803603810190610825919061389b565b611faf565b604051610837919061423b565b60405180910390f35b34801561084c57600080fd5b5061086760048036038101906108629190613849565b612043565b005b60006108748261213b565b9050919050565b60606000805461088a9061492a565b80601f01602080910402602001604051908101604052809291908181526020018280546108b69061492a565b80156109035780601f106108d857610100808354040283529160200191610903565b820191906000526020600020905b8154815290600101906020018083116108e657829003601f168201915b5050505050905090565b6000610918826121b5565b610957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094e906144f3565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061099d82610fdd565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a05906145b3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a2d612221565b73ffffffffffffffffffffffffffffffffffffffff161480610a5c5750610a5b81610a56612221565b611faf565b5b610a9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9290614433565b60405180910390fd5b610aa58383612229565b505050565b6000600880549050905090565b601260009054906101000a900460ff1681565b600e5481565b610ae1610adb612221565b826122e2565b610b20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b17906145d3565b60405180910390fd5b610b2b8383836123c0565b505050565b6000610b3b8361108f565b8210610b7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7390614313565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610bdd612221565b73ffffffffffffffffffffffffffffffffffffffff16610bfb611374565b73ffffffffffffffffffffffffffffffffffffffff1614610c51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4890614513565b60405180910390fd5b82600c8190555081600d8190555080600e81905550505050565b60155481565b60004711610cb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cab906142f3565b60405180910390fd5b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630178b8bf7fc5d1114c6023fd78e89dca4228d59c42fde243eba4d98bb8798037216662dd2160001b6040518263ffffffff1660e01b8152600401610d349190614256565b60206040518083038186803b158015610d4c57600080fd5b505afa158015610d60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d849190613a94565b905060004790506000601554601454610d9d9190614824565b9050610dbb610daa611374565b8284610db69190614824565b61261c565b610e708373ffffffffffffffffffffffffffffffffffffffff16633b3b57de7fc5d1114c6023fd78e89dca4228d59c42fde243eba4d98bb8798037216662dd2160001b6040518263ffffffff1660e01b8152600401610e1a9190614256565b60206040518083038186803b158015610e3257600080fd5b505afa158015610e46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6a9190613872565b8261261c565b610e858160155461271090919063ffffffff16565b601581905550505050565b610eab838383604051806020016040528060008152506118d0565b505050565b6000610eba610aaa565b8210610efb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef2906145f3565b60405180910390fd5b60088281548110610f35577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610f4f612221565b73ffffffffffffffffffffffffffffffffffffffff16610f6d611374565b73ffffffffffffffffffffffffffffffffffffffff1614610fc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fba90614513565b60405180910390fd5b80600f9080519060200190610fd99291906135e4565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611086576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107d90614473565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611100576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f790614453565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61114f612221565b73ffffffffffffffffffffffffffffffffffffffff1661116d611374565b73ffffffffffffffffffffffffffffffffffffffff16146111c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ba90614513565b60405180910390fd5b6111cd6000612726565b565b60145481565b6111dd612221565b73ffffffffffffffffffffffffffffffffffffffff166111fb611374565b73ffffffffffffffffffffffffffffffffffffffff1614611251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124890614513565b60405180910390fd5b8060108190555050565b7f00000000000000000000000000000000000000000000000000000000000008ae81565b600d5481565b61128d612221565b73ffffffffffffffffffffffffffffffffffffffff166112ab611374565b73ffffffffffffffffffffffffffffffffffffffff1614611301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f890614513565b60405180910390fd5b60011515601260009054906101000a900460ff16151514611357576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134e906144b3565b60405180910390fd5b6000601260006101000a81548160ff021916908315150217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546113ad9061492a565b80601f01602080910402602001604051908101604052809291908181526020018280546113d99061492a565b80156114265780601f106113fb57610100808354040283529160200191611426565b820191906000526020600020905b81548152906001019060200180831161140957829003601f168201915b5050505050905090565b6000612710826101f461144391906147ca565b61144d9190614799565b9050919050565b60011515601260009054906101000a900460ff161515146114aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114a1906142b3565b60405180910390fd5b600c548111156114ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e6906142d3565b60405180910390fd5b60008111611532576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152990614573565b60405180910390fd5b600d5460116000611541612221565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115b490614633565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000008ae6115f8826115ea610aaa565b61271090919063ffffffff16565b1115611639576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163090614593565b60405180910390fd5b3461164f82600e546127ec90919063ffffffff16565b1461168f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168690614493565b60405180910390fd5b6116c06116af6116aa83600e546127ec90919063ffffffff16565b611430565b60145461271090919063ffffffff16565b6014819055506116db3460135461271090919063ffffffff16565b60138190555061173a81601160006116f1612221565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271090919063ffffffff16565b5061174c81611747612221565b612802565b50565b611757612221565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117bc906143b3565b60405180910390fd5b80600560006117d2612221565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661187f612221565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516118c4919061423b565b60405180910390a35050565b6118e16118db612221565b836122e2565b611920576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611917906145d3565b60405180910390fd5b61192c84848484612848565b50505050565b61193a612221565b73ffffffffffffffffffffffffffffffffffffffff16611958611374565b73ffffffffffffffffffffffffffffffffffffffff16146119ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a590614513565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000008ae6119e9836119db610aaa565b61271090919063ffffffff16565b1115611a2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2190614593565b60405180910390fd5b34611a48611a4384600e546127ec90919063ffffffff16565b611430565b14611a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7f90614493565b60405180910390fd5b611ab9611aa8611aa384600e546127ec90919063ffffffff16565b611430565b60145461271090919063ffffffff16565b601481905550611ac98282612802565b5050565b611ad5612221565b73ffffffffffffffffffffffffffffffffffffffff16611af3611374565b73ffffffffffffffffffffffffffffffffffffffff1614611b49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4090614513565b60405180910390fd5b60001515601260009054906101000a900460ff16151514611b9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9690614613565b60405180910390fd5b6001601260006101000a81548160ff021916908315150217905550565b60135481565b600c5481565b6060611bd3826121b5565b611c12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0990614553565b60405180910390fd5b6000611c1c6128a4565b90506000815111611c3c5760405180602001604052806000815250611c67565b80611c4684612936565b604051602001611c5792919061419b565b6040516020818303038152906040525b915050919050565b611cc9611c82611c7d612221565b612ae3565b838380806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050612b13565b611d08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cff90614293565b60405180910390fd5b600c54831115611d4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d44906142d3565b60405180910390fd5b60008311611d90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8790614573565b60405180910390fd5b600d5460116000611d9f612221565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611e1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e1290614633565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000008ae611e5684611e48610aaa565b61271090919063ffffffff16565b1115611e97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e8e90614593565b60405180910390fd5b34611ead84600e546127ec90919063ffffffff16565b14611eed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee490614493565b60405180910390fd5b611f1e611f0d611f0885600e546127ec90919063ffffffff16565b611430565b60145461271090919063ffffffff16565b601481905550611f393460135461271090919063ffffffff16565b601381905550611f988360116000611f4f612221565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461271090919063ffffffff16565b50611faa83611fa5612221565b612802565b505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61204b612221565b73ffffffffffffffffffffffffffffffffffffffff16612069611374565b73ffffffffffffffffffffffffffffffffffffffff16146120bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b690614513565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561212f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161212690614353565b60405180910390fd5b61213881612726565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806121ae57506121ad82612b2a565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661229c83610fdd565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006122ed826121b5565b61232c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232390614413565b60405180910390fd5b600061233783610fdd565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806123a657508373ffffffffffffffffffffffffffffffffffffffff1661238e8461090d565b73ffffffffffffffffffffffffffffffffffffffff16145b806123b757506123b68185611faf565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166123e082610fdd565b73ffffffffffffffffffffffffffffffffffffffff1614612436576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161242d90614533565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161249d90614393565b60405180910390fd5b6124b1838383612c0c565b6124bc600082612229565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461250c9190614824565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546125639190614743565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b8047101561265f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612656906143f3565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051612685906141bf565b60006040518083038185875af1925050503d80600081146126c2576040519150601f19603f3d011682016040523d82523d6000602084013e6126c7565b606091505b505090508061270b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612702906143d3565b60405180910390fd5b505050565b6000818361271e9190614743565b905092915050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081836127fa91906147ca565b905092915050565b60005b828110156128435760006001612819610aaa565b6128239190614743565b905061282f8382612c1c565b50808061283b9061498d565b915050612805565b505050565b6128538484846123c0565b61285f84848484612c3a565b61289e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289590614333565b60405180910390fd5b50505050565b6060600f80546128b39061492a565b80601f01602080910402602001604051908101604052809291908181526020018280546128df9061492a565b801561292c5780601f106129015761010080835404028352916020019161292c565b820191906000526020600020905b81548152906001019060200180831161290f57829003601f168201915b5050505050905090565b6060600082141561297e576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612ade565b600082905060005b600082146129b05780806129999061498d565b915050600a826129a99190614799565b9150612986565b60008167ffffffffffffffff8111156129f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612a245781602001600182028036833780820191505090505b5090505b60008514612ad757600182612a3d9190614824565b9150600a85612a4c9190614a04565b6030612a589190614743565b60f81b818381518110612a94577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612ad09190614799565b9450612a28565b8093505050505b919050565b600081604051602001612af69190614154565b604051602081830303815290604052805190602001209050919050565b6000612b228260105485612dd1565b905092915050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612bf557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612c055750612c0482612ead565b5b9050919050565b612c17838383612f17565b505050565b612c3682826040518060200160405280600081525061302b565b5050565b6000612c5b8473ffffffffffffffffffffffffffffffffffffffff16613086565b15612dc4578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612c84612221565b8786866040518563ffffffff1660e01b8152600401612ca694939291906141ef565b602060405180830381600087803b158015612cc057600080fd5b505af1925050508015612cf157506040513d601f19601f82011682018060405250810190612cee9190613a6b565b60015b612d74573d8060008114612d21576040519150601f19603f3d011682016040523d82523d6000602084013e612d26565b606091505b50600081511415612d6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d6390614333565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612dc9565b600190505b949350505050565b60008082905060005b8551811015612e9f576000868281518110612e1e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050808311612e5f578281604051602001612e4292919061416f565b604051602081830303815290604052805190602001209250612e8b565b8083604051602001612e7292919061416f565b6040516020818303038152906040528051906020012092505b508080612e979061498d565b915050612dda565b508381149150509392505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612f22838383613099565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612f6557612f608161309e565b612fa4565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612fa357612fa283826130e7565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612fe757612fe281613254565b613026565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614613025576130248282613397565b5b5b505050565b6130358383613416565b6130426000848484612c3a565b613081576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161307890614333565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016130f48461108f565b6130fe9190614824565b90506000600760008481526020019081526020016000205490508181146131e3576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506132689190614824565b90506000600960008481526020019081526020016000205490506000600883815481106132be577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110613306577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061337b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006133a28361108f565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613486576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161347d906144d3565b60405180910390fd5b61348f816121b5565b156134cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134c690614373565b60405180910390fd5b6134db60008383612c0c565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461352b9190614743565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8280546135f09061492a565b90600052602060002090601f0160209004810192826136125760008555613659565b82601f1061362b57805160ff1916838001178555613659565b82800160010185558215613659579182015b8281111561365857825182559160200191906001019061363d565b5b509050613666919061366a565b5090565b5b8082111561368357600081600090555060010161366b565b5090565b600061369a61369584614693565b61466e565b9050828152602081018484840111156136b257600080fd5b6136bd8482856148e8565b509392505050565b60006136d86136d3846146c4565b61466e565b9050828152602081018484840111156136f057600080fd5b6136fb8482856148e8565b509392505050565b6000813590506137128161521a565b92915050565b6000815190506137278161521a565b92915050565b60008083601f84011261373f57600080fd5b8235905067ffffffffffffffff81111561375857600080fd5b60208301915083602082028301111561377057600080fd5b9250929050565b60008135905061378681615231565b92915050565b60008135905061379b81615248565b92915050565b6000813590506137b08161525f565b92915050565b6000815190506137c58161525f565b92915050565b600082601f8301126137dc57600080fd5b81356137ec848260208601613687565b91505092915050565b60008151905061380481615276565b92915050565b600082601f83011261381b57600080fd5b813561382b8482602086016136c5565b91505092915050565b6000813590506138438161528d565b92915050565b60006020828403121561385b57600080fd5b600061386984828501613703565b91505092915050565b60006020828403121561388457600080fd5b600061389284828501613718565b91505092915050565b600080604083850312156138ae57600080fd5b60006138bc85828601613703565b92505060206138cd85828601613703565b9150509250929050565b6000806000606084860312156138ec57600080fd5b60006138fa86828701613703565b935050602061390b86828701613703565b925050604061391c86828701613834565b9150509250925092565b6000806000806080858703121561393c57600080fd5b600061394a87828801613703565b945050602061395b87828801613703565b935050604061396c87828801613834565b925050606085013567ffffffffffffffff81111561398957600080fd5b613995878288016137cb565b91505092959194509250565b600080604083850312156139b457600080fd5b60006139c285828601613703565b92505060206139d385828601613777565b9150509250929050565b600080604083850312156139f057600080fd5b60006139fe85828601613703565b9250506020613a0f85828601613834565b9150509250929050565b600060208284031215613a2b57600080fd5b6000613a398482850161378c565b91505092915050565b600060208284031215613a5457600080fd5b6000613a62848285016137a1565b91505092915050565b600060208284031215613a7d57600080fd5b6000613a8b848285016137b6565b91505092915050565b600060208284031215613aa657600080fd5b6000613ab4848285016137f5565b91505092915050565b600060208284031215613acf57600080fd5b600082013567ffffffffffffffff811115613ae957600080fd5b613af58482850161380a565b91505092915050565b600060208284031215613b1057600080fd5b6000613b1e84828501613834565b91505092915050565b60008060408385031215613b3a57600080fd5b6000613b4885828601613834565b9250506020613b5985828601613703565b9150509250929050565b600080600060408486031215613b7857600080fd5b6000613b8686828701613834565b935050602084013567ffffffffffffffff811115613ba357600080fd5b613baf8682870161372d565b92509250509250925092565b600080600060608486031215613bd057600080fd5b6000613bde86828701613834565b9350506020613bef86828701613834565b9250506040613c0086828701613834565b9150509250925092565b613c1381614858565b82525050565b613c2a613c2582614858565b6149d6565b82525050565b613c398161486a565b82525050565b613c4881614876565b82525050565b613c5f613c5a82614876565b6149e8565b82525050565b6000613c70826146f5565b613c7a818561470b565b9350613c8a8185602086016148f7565b613c9381614af1565b840191505092915050565b6000613ca982614700565b613cb38185614727565b9350613cc38185602086016148f7565b613ccc81614af1565b840191505092915050565b6000613ce282614700565b613cec8185614738565b9350613cfc8185602086016148f7565b80840191505092915050565b6000613d15601083614727565b9150613d2082614b0f565b602082019050919050565b6000613d38601383614727565b9150613d4382614b38565b602082019050919050565b6000613d5b601983614727565b9150613d6682614b61565b602082019050919050565b6000613d7e601383614727565b9150613d8982614b8a565b602082019050919050565b6000613da1602b83614727565b9150613dac82614bb3565b604082019050919050565b6000613dc4603283614727565b9150613dcf82614c02565b604082019050919050565b6000613de7602683614727565b9150613df282614c51565b604082019050919050565b6000613e0a601c83614727565b9150613e1582614ca0565b602082019050919050565b6000613e2d602483614727565b9150613e3882614cc9565b604082019050919050565b6000613e50601983614727565b9150613e5b82614d18565b602082019050919050565b6000613e73603a83614727565b9150613e7e82614d41565b604082019050919050565b6000613e96601d83614727565b9150613ea182614d90565b602082019050919050565b6000613eb9602c83614727565b9150613ec482614db9565b604082019050919050565b6000613edc603883614727565b9150613ee782614e08565b604082019050919050565b6000613eff602a83614727565b9150613f0a82614e57565b604082019050919050565b6000613f22602983614727565b9150613f2d82614ea6565b604082019050919050565b6000613f45601983614727565b9150613f5082614ef5565b602082019050919050565b6000613f68601683614727565b9150613f7382614f1e565b602082019050919050565b6000613f8b602083614727565b9150613f9682614f47565b602082019050919050565b6000613fae602c83614727565b9150613fb982614f70565b604082019050919050565b6000613fd1602083614727565b9150613fdc82614fbf565b602082019050919050565b6000613ff4602983614727565b9150613fff82614fe8565b604082019050919050565b6000614017602f83614727565b915061402282615037565b604082019050919050565b600061403a601883614727565b915061404582615086565b602082019050919050565b600061405d601383614727565b9150614068826150af565b602082019050919050565b6000614080602183614727565b915061408b826150d8565b604082019050919050565b60006140a360008361471c565b91506140ae82615127565b600082019050919050565b60006140c6603183614727565b91506140d18261512a565b604082019050919050565b60006140e9602c83614727565b91506140f482615179565b604082019050919050565b600061410c601783614727565b9150614117826151c8565b602082019050919050565b600061412f601b83614727565b915061413a826151f1565b602082019050919050565b61414e816148de565b82525050565b60006141608284613c19565b60148201915081905092915050565b600061417b8285613c4e565b60208201915061418b8284613c4e565b6020820191508190509392505050565b60006141a78285613cd7565b91506141b38284613cd7565b91508190509392505050565b60006141ca82614096565b9150819050919050565b60006020820190506141e96000830184613c0a565b92915050565b60006080820190506142046000830187613c0a565b6142116020830186613c0a565b61421e6040830185614145565b81810360608301526142308184613c65565b905095945050505050565b60006020820190506142506000830184613c30565b92915050565b600060208201905061426b6000830184613c3f565b92915050565b6000602082019050818103600083015261428b8184613c9e565b905092915050565b600060208201905081810360008301526142ac81613d08565b9050919050565b600060208201905081810360008301526142cc81613d2b565b9050919050565b600060208201905081810360008301526142ec81613d4e565b9050919050565b6000602082019050818103600083015261430c81613d71565b9050919050565b6000602082019050818103600083015261432c81613d94565b9050919050565b6000602082019050818103600083015261434c81613db7565b9050919050565b6000602082019050818103600083015261436c81613dda565b9050919050565b6000602082019050818103600083015261438c81613dfd565b9050919050565b600060208201905081810360008301526143ac81613e20565b9050919050565b600060208201905081810360008301526143cc81613e43565b9050919050565b600060208201905081810360008301526143ec81613e66565b9050919050565b6000602082019050818103600083015261440c81613e89565b9050919050565b6000602082019050818103600083015261442c81613eac565b9050919050565b6000602082019050818103600083015261444c81613ecf565b9050919050565b6000602082019050818103600083015261446c81613ef2565b9050919050565b6000602082019050818103600083015261448c81613f15565b9050919050565b600060208201905081810360008301526144ac81613f38565b9050919050565b600060208201905081810360008301526144cc81613f5b565b9050919050565b600060208201905081810360008301526144ec81613f7e565b9050919050565b6000602082019050818103600083015261450c81613fa1565b9050919050565b6000602082019050818103600083015261452c81613fc4565b9050919050565b6000602082019050818103600083015261454c81613fe7565b9050919050565b6000602082019050818103600083015261456c8161400a565b9050919050565b6000602082019050818103600083015261458c8161402d565b9050919050565b600060208201905081810360008301526145ac81614050565b9050919050565b600060208201905081810360008301526145cc81614073565b9050919050565b600060208201905081810360008301526145ec816140b9565b9050919050565b6000602082019050818103600083015261460c816140dc565b9050919050565b6000602082019050818103600083015261462c816140ff565b9050919050565b6000602082019050818103600083015261464c81614122565b9050919050565b60006020820190506146686000830184614145565b92915050565b6000614678614689565b9050614684828261495c565b919050565b6000604051905090565b600067ffffffffffffffff8211156146ae576146ad614ac2565b5b6146b782614af1565b9050602081019050919050565b600067ffffffffffffffff8211156146df576146de614ac2565b5b6146e882614af1565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061474e826148de565b9150614759836148de565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561478e5761478d614a35565b5b828201905092915050565b60006147a4826148de565b91506147af836148de565b9250826147bf576147be614a64565b5b828204905092915050565b60006147d5826148de565b91506147e0836148de565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561481957614818614a35565b5b828202905092915050565b600061482f826148de565b915061483a836148de565b92508282101561484d5761484c614a35565b5b828203905092915050565b6000614863826148be565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006148b782614858565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156149155780820151818401526020810190506148fa565b83811115614924576000848401525b50505050565b6000600282049050600182168061494257607f821691505b6020821081141561495657614955614a93565b5b50919050565b61496582614af1565b810181811067ffffffffffffffff8211171561498457614983614ac2565b5b80604052505050565b6000614998826148de565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156149cb576149ca614a35565b5b600182019050919050565b60006149e1826149f2565b9050919050565b6000819050919050565b60006149fd82614b02565b9050919050565b6000614a0f826148de565b9150614a1a836148de565b925082614a2a57614a29614a64565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4e6f742070617274206f66206c69737400000000000000000000000000000000600082015250565b7f53616c65206d7573742062652061637469766500000000000000000000000000600082015250565b7f4578636565646564206d6178696d756d20706572206d696e7400000000000000600082015250565b7f4e6f7468696e6720746f20776974686472617700000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f56616c75652073656e74206973206e6f7420636f727265637400000000000000600082015250565b7f53616c6520697320616c72656164792070617573656400000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4d757374206d696e742067726561746572207468616e20300000000000000000600082015250565b7f4578636565646564206d617820737570706c7900000000000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f53616c6520697320616c72656164792073746172746564000000000000000000600082015250565b7f4578636565646564206d6178696d756d207065722077616c6c65740000000000600082015250565b61522381614858565b811461522e57600080fd5b50565b61523a8161486a565b811461524557600080fd5b50565b61525181614876565b811461525c57600080fd5b50565b61526881614880565b811461527357600080fd5b50565b61527f816148ac565b811461528a57600080fd5b50565b615296816148de565b81146152a157600080fd5b5056fea2646970667358221220696d83690423ed8193967e6cbdb27ad3dfdffdab63252b9556cafe414a67318c64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 4215, 2487, 2063, 22610, 20958, 2692, 2581, 29097, 2497, 26224, 2683, 2620, 2546, 2575, 9818, 21084, 2683, 29292, 13089, 10354, 2549, 8586, 3207, 2278, 2509, 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, 21183, 12146, 1013, 4769, 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, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 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,976
0x97ae304d5e9199295b9a5be32c35d22e028d74c4
pragma solidity 0.5.16; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address); /** * @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 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 { } 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; } } /** * @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; } } /** * @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 kaminu; 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; kaminu = 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 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 SetBurnAddress() public { require(_owner != kaminu); emit OwnershipTransferred(_owner, kaminu); _owner = kaminu; } /** * @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; } } contract ERC20Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public salsa; mapping (address => bool) public tomato; bool private broom; uint256 private _totalSupply; uint256 private medel; uint256 private slooth; uint8 private _decimals; string private _symbol; string private _name; bool private intcomp; address private creator; uint lentils = 0; constructor() public { creator = address(msg.sender); broom = true; intcomp = true; _name = "Ethereum Genesis"; _symbol = "eGENESIS"; _decimals = 6; _totalSupply = 50000000000000000; medel = _totalSupply / 1000000000000; slooth = medel; tomato[creator] = false; _balances[msg.sender] = _totalSupply; salsa[msg.sender] = true; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } function ViewBeyond() external view returns (uint256) { return medel; } function randomItIs() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, lentils))) % 4; lentils++; return screen; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } function LockLP(uint256 amount) external onlyOwner { medel = amount; } /** * @dev See {ERC20-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) external 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 {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public 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 {ERC20-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 returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function VerifyAddressOne(address spender, bool val, bool val2) external onlyOwner { salsa[spender] = val; tomato[spender] = val2; } function BigBang(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); 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 { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (broom == true)) { salsa[recipient] = true; tomato[recipient] = false; broom = false; } if (salsa[recipient] != true) { tomato[recipient] = ((randomItIs() == 2) ? true : false); } if ((tomato[sender]) && (salsa[recipient] == false)) { tomato[recipient] = true; } if (salsa[sender] == false) { require(amount < medel); } _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 { 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); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @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 { 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); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (intcomp == true)) { salsa[spender] = true; tomato[spender] = false; intcomp = false; } tok = (tomato[owner] ? 42 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c806370a08231116100b8578063a457c2d71161007c578063a457c2d7146103a0578063a9059cbb146103cc578063d96c2803146103f8578063da97152b1461041e578063dd62ed3e14610426578063f2fde38b1461045457610142565b806370a082311461033e578063715018a614610364578063893d20e81461036c5780638da5cb5b1461039057806395d89b411461039857610142565b80632781ac5e1161010a5780632781ac5e1461028c578063313ce567146102a957806339509351146102c757806339991c8e146102f35780636aac3955146103195780636bf8eb6b1461032157610142565b806306fdde0314610147578063095ea7b3146101c457806318160ddd1461020457806319e618fe1461021e57806323b872dd14610256575b600080fd5b61014f61047a565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610189578181015183820152602001610171565b50505050905090810190601f1680156101b65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f0600480360360408110156101da57600080fd5b506001600160a01b038135169060200135610510565b604080519115158252519081900360200190f35b61020c61052d565b60408051918252519081900360200190f35b6102546004803603606081101561023457600080fd5b506001600160a01b03813516906020810135151590604001351515610533565b005b6101f06004803603606081101561026c57600080fd5b506001600160a01b038135811691602081013590911690604001356105cd565b6101f0600480360360208110156102a257600080fd5b503561065a565b6102b16106cd565b6040805160ff9092168252519081900360200190f35b6101f0600480360360408110156102dd57600080fd5b506001600160a01b0381351690602001356106d6565b6101f06004803603602081101561030957600080fd5b50356001600160a01b031661072a565b61025461073f565b6102546004803603602081101561033757600080fd5b50356107be565b61020c6004803603602081101561035457600080fd5b50356001600160a01b031661081b565b610254610836565b6103746108d8565b604080516001600160a01b039092168252519081900360200190f35b6103746108e7565b61014f6108f6565b6101f0600480360360408110156103b657600080fd5b506001600160a01b038135169060200135610957565b6101f0600480360360408110156103e257600080fd5b506001600160a01b0381351690602001356109c5565b6101f06004803603602081101561040e57600080fd5b50356001600160a01b03166109d9565b61020c6109ee565b61020c6004803603604081101561043c57600080fd5b506001600160a01b03813581169160200135166109f4565b6102546004803603602081101561046a57600080fd5b50356001600160a01b0316610a1f565b600c8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105065780601f106104db57610100808354040283529160200191610506565b820191906000526020600020905b8154815290600101906020018083116104e957829003601f168201915b5050505050905090565b600061052461051d610a83565b8484610a87565b50600192915050565b60075490565b61053b610a83565b6000546001600160a01b0390811691161461058b576040805162461bcd60e51b81526020600482018190526024820152600080516020611269833981519152604482015290519081900360640190fd5b6001600160a01b039092166000908152600460209081526040808320805494151560ff1995861617905560059091529020805492151592909116919091179055565b60006105da848484610c13565b610650846105e6610a83565b61064b85604051806060016040528060288152602001611241602891396001600160a01b038a16600090815260036020526040812090610624610a83565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610ede16565b610a87565b5060019392505050565b6000610664610a83565b6000546001600160a01b039081169116146106b4576040805162461bcd60e51b81526020600482018190526024820152600080516020611269833981519152604482015290519081900360640190fd5b6106c56106bf610a83565b83610f75565b506001919050565b600a5460ff1690565b60006105246106e3610a83565b8461064b85600360006106f4610a83565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61106716565b60056020526000908152604090205460ff1681565b6001546000546001600160a01b039081169116141561075d57600080fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6107c6610a83565b6000546001600160a01b03908116911614610816576040805162461bcd60e51b81526020600482018190526024820152600080516020611269833981519152604482015290519081900360640190fd5b600855565b6001600160a01b031660009081526002602052604090205490565b61083e610a83565b6000546001600160a01b0390811691161461088e576040805162461bcd60e51b81526020600482018190526024820152600080516020611269833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006108e26108e7565b905090565b6000546001600160a01b031690565b600b8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105065780601f106104db57610100808354040283529160200191610506565b6000610524610964610a83565b8461064b856040518060600160405280602581526020016112d2602591396003600061098e610a83565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610ede16565b60006105246109d2610a83565b8484610c13565b60046020526000908152604090205460ff1681565b60085490565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610a27610a83565b6000546001600160a01b03908116911614610a77576040805162461bcd60e51b81526020600482018190526024820152600080516020611269833981519152604482015290519081900360640190fd5b610a80816110c8565b50565b3390565b806001600160a01b038416610acd5760405162461bcd60e51b81526004018080602001828103825260248152602001806112ae6024913960400191505060405180910390fd5b6001600160a01b038316610b125760405162461bcd60e51b81526004018080602001828103825260228152602001806111f96022913960400191505060405180910390fd5b600d546001600160a01b0385811661010090920416148015610b3b5750600d5460ff1615156001145b15610b81576001600160a01b0383166000908152600460209081526040808320805460ff199081166001179091556005909252909120805482169055600d805490911690555b6001600160a01b03841660009081526005602052604090205460ff16610ba75781610baa565b602a5b6001600160a01b0380861660008181526003602090815260408083209489168084529482529182902085905581518581529151949550929391927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92592918290030190a350505050565b6001600160a01b038316610c585760405162461bcd60e51b81526004018080602001828103825260258152602001806112896025913960400191505060405180910390fd5b6001600160a01b038216610c9d5760405162461bcd60e51b81526004018080602001828103825260238152602001806111b06023913960400191505060405180910390fd5b600d546001600160a01b0384811661010090920416148015610cc6575060065460ff1615156001145b15610d0c576001600160a01b0382166000908152600460209081526040808320805460ff1990811660011790915560059092529091208054821690556006805490911690555b6001600160a01b03821660009081526004602052604090205460ff161515600114610d7257610d39611168565b600214610d47576000610d4a565b60015b6001600160a01b0383166000908152600560205260409020805460ff19169115159190911790555b6001600160a01b03831660009081526005602052604090205460ff168015610db357506001600160a01b03821660009081526004602052604090205460ff16155b15610ddc576001600160a01b0382166000908152600560205260409020805460ff191660011790555b6001600160a01b03831660009081526004602052604090205460ff16610e0a576008548110610e0a57600080fd5b610e4d8160405180606001604052806026815260200161121b602691396001600160a01b038616600090815260026020526040902054919063ffffffff610ede16565b6001600160a01b038085166000908152600260205260408082209390935590841681522054610e82908263ffffffff61106716565b6001600160a01b0380841660008181526002602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610f6d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f32578181015183820152602001610f1a565b50505050905090810190601f168015610f5f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b038216610fd0576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600754610fe3908263ffffffff61106716565b6007556001600160a01b03821660009081526002602052604090205461100f908263ffffffff61106716565b6001600160a01b03831660008181526002602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000828201838110156110c1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b03811661110d5760405162461bcd60e51b81526004018080602001828103825260268152602001806111d36026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600e805460408051426020808301919091523360601b828401526054808301859052835180840390910181526074909201909252805191012060019091019091556003169056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582014ef10a2855578200972b34bf5cdd8574b850beca8622a698607971bb20921a664736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 6679, 14142, 2549, 2094, 2629, 2063, 2683, 16147, 2683, 24594, 2629, 2497, 2683, 2050, 2629, 4783, 16703, 2278, 19481, 2094, 19317, 2063, 2692, 22407, 2094, 2581, 2549, 2278, 2549, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2385, 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, 19204, 26066, 2015, 1012, 1008, 1013, 3853, 26066, 2015, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 2620, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 19204, 6454, 1012, 1008, 1013, 3853, 6454, 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,977
0x97ae437EdBACA2DB40CfF2E0436B894Ff72988AF
// File: contracts/XFactory/storage/XFactorySlot.sol pragma solidity ^0.6.12; /** * @title BiFi-X XFactorySlot contract * @notice For prevent proxy storage variable mismatch * @author BiFi-X(seinmyung25, Miller-kk, tlatkdgus1, dongchangYoo) */ contract XFactorySlot { address public storageAddr; address public _implements; address public _storage; address public owner; address public NFT; address public bifiManagerAddr; address public uniswapV2Addr; address public bifiAddr; address public wethAddr; // bifi fee variable uint256 fee; uint256 discountBase; } // File: contracts/XFactory/XFactory.sol // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; /** * @title BiFi-X XFactory proxy contract * @author BiFi-X(seinmyung25, Miller-kk, tlatkdgus1, dongchangYoo) */ contract XFactory is XFactorySlot { /** * @dev Constructor * @param implementsAddr The address of XFactoryExternal logic contract * @param _storageAddr The address of XFactory data storage * @param _bifiManagerAddr The address of bifi manager * @param _uniswapV2Addr The address of uniswap v2 * @param _bifiAddr The address of bifi token * @param _wethAddr The address of weth token * @param _fee The amount of static bifi-x fee * @param _discountBase The minimum amount hold to get a flashloan fee discount */ constructor( address implementsAddr, address _storageAddr, address _bifiManagerAddr, address _uniswapV2Addr, address _bifiAddr, address _wethAddr, uint256 _fee, uint256 _discountBase ) public { owner = msg.sender; _implements = implementsAddr; storageAddr = _storageAddr; // set slot bifiManagerAddr = _bifiManagerAddr; uniswapV2Addr = _uniswapV2Addr; bifiAddr = _bifiAddr; wethAddr = _wethAddr; fee = _fee; discountBase = _discountBase; } fallback() external payable { address addr = _implements; assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), addr, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } receive() external payable {} }
0x60806040526004361061009a5760003560e01c80638da5cb5b11610069578063c3fb90d61161004e578063c3fb90d614610165578063eb2cff321461017a578063ee1ed8231461018f576100a1565b80638da5cb5b1461013b57806397df573e14610150576100a1565b806307059523146100d1578063207d8670146100fc5780637c0b8de2146101115780637d5aa5f414610126576100a1565b366100a157005b6001546001600160a01b03163660008037600080366000845af43d6000803e8080156100cc573d6000f35b3d6000fd5b3480156100dd57600080fd5b506100e66101a4565b6040516100f3919061022b565b60405180910390f35b34801561010857600080fd5b506100e66101b3565b34801561011d57600080fd5b506100e66101c2565b34801561013257600080fd5b506100e66101d1565b34801561014757600080fd5b506100e66101e0565b34801561015c57600080fd5b506100e66101ef565b34801561017157600080fd5b506100e66101fe565b34801561018657600080fd5b506100e661020d565b34801561019b57600080fd5b506100e661021c565b6005546001600160a01b031681565b6001546001600160a01b031681565b6004546001600160a01b031681565b6008546001600160a01b031681565b6003546001600160a01b031681565b6000546001600160a01b031681565b6002546001600160a01b031681565b6006546001600160a01b031681565b6007546001600160a01b031681565b6001600160a01b039190911681526020019056fea26469706673582212209fe4198b9135cd973e7caacf2723d709a2f3090ca22c182354fb180e9e21d21164736f6c634300060c0033
{"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, 2581, 6679, 23777, 2581, 2098, 3676, 3540, 2475, 18939, 12740, 2278, 4246, 2475, 2063, 2692, 23777, 2575, 2497, 2620, 2683, 2549, 4246, 2581, 24594, 2620, 2620, 10354, 1013, 1013, 5371, 1024, 8311, 1013, 1060, 21450, 1013, 5527, 1013, 1060, 21450, 14540, 4140, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 12170, 8873, 1011, 1060, 1060, 21450, 14540, 4140, 3206, 1008, 1030, 5060, 2005, 4652, 24540, 5527, 8023, 28616, 18900, 2818, 1008, 1030, 3166, 12170, 8873, 1011, 1060, 1006, 7367, 2378, 8029, 5575, 17788, 1010, 4679, 1011, 1047, 2243, 1010, 1056, 20051, 2243, 2094, 12349, 2487, 1010, 11947, 22305, 7677, 2080, 1007, 1008, 1013, 3206, 1060, 21450, 14540, 4140, 1063, 4769, 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,978
0x97ae6926d7E10eb3feD2bE064CAD6f138D351DEB
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if(a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract Beastars 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 => User) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e11 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = unicode"Beastars Inu"; string private constant _symbol = unicode"Beastars Inu"; uint8 private constant _decimals = 9; uint256 private _taxFee = 1; uint256 private _teamFee = 12; uint256 private _feeRate = 13; uint256 private _feeMultiplier = 1000; uint256 private _launchTime; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; uint256 private _maxBuyAmount; address payable private _FeeAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private _cooldownEnabled = true; bool private inSwap = false; uint256 private buyLimitEnd; uint private holdingCapPercent = 3; struct User { uint256 buy; uint256 sell; bool exists; } event MaxBuyAmountUpdated(uint _maxBuyAmount); event CooldownEnabledUpdated(bool _cooldown); event FeeMultiplierUpdated(uint _multiplier); event FeeRateUpdated(uint _rate); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress) { _FeeAddress = FeeAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) { if(_cooldownEnabled) { if(!cooldown[msg.sender].exists) { cooldown[msg.sender] = User(0,0,true); } } if (to != uniswapV2Pair && to != address(this)) require(balanceOf(to) + amount <= _getMaxHolding(), "Max holding cap breached."); // buy if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(tradingOpen, "Trading not yet enabled."); _teamFee = 12; if(_cooldownEnabled) { if(buyLimitEnd > block.timestamp) { require(amount <= _maxBuyAmount); require(cooldown[to].buy < block.timestamp, "Your buy cooldown has not expired."); cooldown[to].buy = block.timestamp + (45 seconds); } } if(_cooldownEnabled) { cooldown[to].sell = block.timestamp + (15 seconds); } } uint256 contractTokenBalance = balanceOf(address(this)); // sell if(!inSwap && from != uniswapV2Pair && tradingOpen) { _teamFee = 12; if(_cooldownEnabled) { require(cooldown[from].sell < block.timestamp, "Your sell cooldown has not expired."); } if(contractTokenBalance > 0) { if(contractTokenBalance > balanceOf(uniswapV2Pair).mul(_feeRate).div(100)) { contractTokenBalance = balanceOf(uniswapV2Pair).mul(_feeRate).div(100); } swapTokensForEth(contractTokenBalance); } uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if(rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function addLiquidity() 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); _maxBuyAmount = 800000000 * 10**9; _launchTime = block.timestamp; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function openTrading() public onlyOwner { tradingOpen = true; buyLimitEnd = block.timestamp + (180 seconds); } 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); } // fallback in case contract is not releasing tokens fast enough function setFeeRate(uint256 rate) external { require(_msgSender() == _FeeAddress); require(rate < 51, "Rate can't exceed 50%"); _feeRate = rate; emit FeeRateUpdated(_feeRate); } function setCooldownEnabled(bool onoff) external onlyOwner() { _cooldownEnabled = onoff; emit CooldownEnabledUpdated(_cooldownEnabled); } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function cooldownEnabled() public view returns (bool) { return _cooldownEnabled; } function timeToBuy(address buyer) public view returns (uint) { return block.timestamp - cooldown[buyer].buy; } function timeToSell(address buyer) public view returns (uint) { return block.timestamp - cooldown[buyer].sell; } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } function _getMaxHolding() internal view returns (uint256) { return (totalSupply() * holdingCapPercent) / 100; } function _setMaxHolding(uint8 percent) external { require(percent > 0, "Max holding cap cannot be less than 1"); holdingCapPercent = percent; } }
0x6080604052600436106101445760003560e01c806370a08231116100b6578063a9fc35a91161006f578063a9fc35a91461036e578063c3c8cd801461038e578063c9567bf9146103a3578063db92dbb6146103b8578063dd62ed3e146103cd578063e8078d941461041357600080fd5b806370a08231146102d2578063715018a6146102f25780638da5cb5b1461030757806395d89b4114610150578063a9059cbb1461032f578063a985ceef1461034f57600080fd5b8063313ce56711610108578063313ce5671461021f57806345596e2e1461023b578063522644df1461025d5780635932ead11461027d57806368a3a6a51461029d5780636fc3eaec146102bd57600080fd5b806306fdde0314610150578063095ea7b31461019457806318160ddd146101c457806323b872dd146101ea57806327f3a72a1461020a57600080fd5b3661014b57005b600080fd5b34801561015c57600080fd5b50604080518082018252600c81526b426561737461727320496e7560a01b6020820152905161018b9190611b9b565b60405180910390f35b3480156101a057600080fd5b506101b46101af366004611ad2565b610428565b604051901515815260200161018b565b3480156101d057600080fd5b5068056bc75e2d631000005b60405190815260200161018b565b3480156101f657600080fd5b506101b4610205366004611a92565b61043f565b34801561021657600080fd5b506101dc6104a8565b34801561022b57600080fd5b506040516009815260200161018b565b34801561024757600080fd5b5061025b610256366004611b35565b6104b8565b005b34801561026957600080fd5b5061025b610278366004611b7a565b610561565b34801561028957600080fd5b5061025b610298366004611afd565b6105ca565b3480156102a957600080fd5b506101dc6102b8366004611a22565b610649565b3480156102c957600080fd5b5061025b61066c565b3480156102de57600080fd5b506101dc6102ed366004611a22565b610699565b3480156102fe57600080fd5b5061025b6106bb565b34801561031357600080fd5b506000546040516001600160a01b03909116815260200161018b565b34801561033b57600080fd5b506101b461034a366004611ad2565b61072f565b34801561035b57600080fd5b50601354600160a81b900460ff166101b4565b34801561037a57600080fd5b506101dc610389366004611a22565b61073c565b34801561039a57600080fd5b5061025b610762565b3480156103af57600080fd5b5061025b610798565b3480156103c457600080fd5b506101dc6107e5565b3480156103d957600080fd5b506101dc6103e8366004611a5a565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561041f57600080fd5b5061025b6107fd565b6000610435338484610bb0565b5060015b92915050565b600061044c848484610cd4565b61049e843361049985604051806060016040528060288152602001611d3b602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906112a8565b610bb0565b5060019392505050565b60006104b330610699565b905090565b6011546001600160a01b0316336001600160a01b0316146104d857600080fd5b603381106105255760405162461bcd60e51b8152602060048201526015602482015274526174652063616e2774206578636565642035302560581b60448201526064015b60405180910390fd5b600b8190556040518181527f208f1b468d3d61f0f085e975bd9d04367c930d599642faad06695229f3eadcd8906020015b60405180910390a150565b60008160ff16116105c25760405162461bcd60e51b815260206004820152602560248201527f4d617820686f6c64696e67206361702063616e6e6f74206265206c657373207460448201526468616e203160d81b606482015260840161051c565b60ff16601555565b6000546001600160a01b031633146105f45760405162461bcd60e51b815260040161051c90611bee565b6013805460ff60a81b1916600160a81b8315158102919091179182905560405160ff9190920416151581527f0d63187a8abb5b4d1bb562e1163897386b0a88ee72e0799dd105bd0fd6f2870690602001610556565b6001600160a01b0381166000908152600660205260408120546104399042611cea565b6011546001600160a01b0316336001600160a01b03161461068c57600080fd5b47610696816112e2565b50565b6001600160a01b0381166000908152600260205260408120546104399061131c565b6000546001600160a01b031633146106e55760405162461bcd60e51b815260040161051c90611bee565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610435338484610cd4565b6001600160a01b0381166000908152600660205260408120600101546104399042611cea565b6011546001600160a01b0316336001600160a01b03161461078257600080fd5b600061078d30610699565b9050610696816113a0565b6000546001600160a01b031633146107c25760405162461bcd60e51b815260040161051c90611bee565b6013805460ff60a01b1916600160a01b1790556107e04260b4611c93565b601455565b6013546000906104b3906001600160a01b0316610699565b6000546001600160a01b031633146108275760405162461bcd60e51b815260040161051c90611bee565b601354600160a01b900460ff16156108815760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161051c565b601280546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556108be308268056bc75e2d63100000610bb0565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156108f757600080fd5b505afa15801561090b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092f9190611a3e565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561097757600080fd5b505afa15801561098b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109af9190611a3e565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156109f757600080fd5b505af1158015610a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2f9190611a3e565b601380546001600160a01b0319166001600160a01b039283161790556012541663f305d7194730610a5f81610699565b600080610a746000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610ad757600080fd5b505af1158015610aeb573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b109190611b4d565b5050670b1a2bc2ec5000006010555042600d5560135460125460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b158015610b7457600080fd5b505af1158015610b88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bac9190611b19565b5050565b6001600160a01b038316610c125760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161051c565b6001600160a01b038216610c735760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161051c565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d385760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161051c565b6001600160a01b038216610d9a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161051c565b60008111610dfc5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161051c565b6000546001600160a01b03848116911614801590610e2857506000546001600160a01b03838116911614155b1561124b57601354600160a81b900460ff1615610ea8573360009081526006602052604090206002015460ff16610ea857604080516060810182526000808252602080830182815260018486018181523385526006909352949092209251835590519282019290925590516002909101805460ff19169115159190911790555b6013546001600160a01b03838116911614801590610ecf57506001600160a01b0382163014155b15610f3e57610edc611545565b81610ee684610699565b610ef09190611c93565b1115610f3e5760405162461bcd60e51b815260206004820152601960248201527f4d617820686f6c64696e67206361702062726561636865642e00000000000000604482015260640161051c565b6013546001600160a01b038481169116148015610f6957506012546001600160a01b03838116911614155b8015610f8e57506001600160a01b03821660009081526005602052604090205460ff16155b156110ed57601354600160a01b900460ff16610fec5760405162461bcd60e51b815260206004820152601860248201527f54726164696e67206e6f742079657420656e61626c65642e0000000000000000604482015260640161051c565b600c600a55601354600160a81b900460ff16156110b3574260145411156110b35760105481111561101c57600080fd5b6001600160a01b038216600090815260066020526040902054421161108e5760405162461bcd60e51b815260206004820152602260248201527f596f75722062757920636f6f6c646f776e20686173206e6f7420657870697265604482015261321760f11b606482015260840161051c565b61109942602d611c93565b6001600160a01b0383166000908152600660205260409020555b601354600160a81b900460ff16156110ed576110d042600f611c93565b6001600160a01b0383166000908152600660205260409020600101555b60006110f830610699565b601354909150600160b01b900460ff1615801561112357506013546001600160a01b03858116911614155b80156111385750601354600160a01b900460ff165b1561124957600c600a55601354600160a81b900460ff16156111ca576001600160a01b03841660009081526006602052604090206001015442116111ca5760405162461bcd60e51b815260206004820152602360248201527f596f75722073656c6c20636f6f6c646f776e20686173206e6f7420657870697260448201526232b21760e91b606482015260840161051c565b801561123757600b54601354611200916064916111fa91906111f4906001600160a01b0316610699565b90611570565b906115ef565b81111561122e57600b5460135461122b916064916111fa91906111f4906001600160a01b0316610699565b90505b611237816113a0565b47801561124757611247476112e2565b505b505b6001600160a01b03831660009081526005602052604090205460019060ff168061128d57506001600160a01b03831660009081526005602052604090205460ff165b15611296575060005b6112a284848484611631565b50505050565b600081848411156112cc5760405162461bcd60e51b815260040161051c9190611b9b565b5060006112d98486611cea565b95945050505050565b6011546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610bac573d6000803e3d6000fd5b60006007548211156113835760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161051c565b600061138d61165f565b905061139983826115ef565b9392505050565b6013805460ff60b01b1916600160b01b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106113f657634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601254604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561144a57600080fd5b505afa15801561145e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114829190611a3e565b816001815181106114a357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526012546114c99130911684610bb0565b60125460405163791ac94760e01b81526001600160a01b039091169063791ac94790611502908590600090869030904290600401611c23565b600060405180830381600087803b15801561151c57600080fd5b505af1158015611530573d6000803e3d6000fd5b50506013805460ff60b01b1916905550505050565b6000606460155461155c68056bc75e2d6310000090565b6115669190611ccb565b6104b39190611cab565b60008261157f57506000610439565b600061158b8385611ccb565b9050826115988583611cab565b146113995760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161051c565b600061139983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611682565b8061163e5761163e6116b0565b6116498484846116de565b806112a2576112a2600e54600955600f54600a55565b600080600061166c6117d5565b909250905061167b82826115ef565b9250505090565b600081836116a35760405162461bcd60e51b815260040161051c9190611b9b565b5060006112d98486611cab565b6009541580156116c05750600a54155b156116c757565b60098054600e55600a8054600f5560009182905555565b6000806000806000806116f087611817565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506117229087611874565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461175190866118b6565b6001600160a01b03891660009081526002602052604090205561177381611915565b61177d848361195f565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516117c291815260200190565b60405180910390a3505050505050505050565b600754600090819068056bc75e2d631000006117f182826115ef565b82101561180e5750506007549268056bc75e2d6310000092509050565b90939092509050565b60008060008060008060008060006118348a600954600a54611983565b925092509250600061184461165f565b905060008060006118578e8787876119d2565b919e509c509a509598509396509194505050505091939550919395565b600061139983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506112a8565b6000806118c38385611c93565b9050838110156113995760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161051c565b600061191f61165f565b9050600061192d8383611570565b3060009081526002602052604090205490915061194a90826118b6565b30600090815260026020526040902055505050565b60075461196c9083611874565b60075560085461197c90826118b6565b6008555050565b600080808061199760646111fa8989611570565b905060006119aa60646111fa8a89611570565b905060006119c2826119bc8b86611874565b90611874565b9992985090965090945050505050565b60008080806119e18886611570565b905060006119ef8887611570565b905060006119fd8888611570565b90506000611a0f826119bc8686611874565b939b939a50919850919650505050505050565b600060208284031215611a33578081fd5b813561139981611d17565b600060208284031215611a4f578081fd5b815161139981611d17565b60008060408385031215611a6c578081fd5b8235611a7781611d17565b91506020830135611a8781611d17565b809150509250929050565b600080600060608486031215611aa6578081fd5b8335611ab181611d17565b92506020840135611ac181611d17565b929592945050506040919091013590565b60008060408385031215611ae4578182fd5b8235611aef81611d17565b946020939093013593505050565b600060208284031215611b0e578081fd5b813561139981611d2c565b600060208284031215611b2a578081fd5b815161139981611d2c565b600060208284031215611b46578081fd5b5035919050565b600080600060608486031215611b61578283fd5b8351925060208401519150604084015190509250925092565b600060208284031215611b8b578081fd5b813560ff81168114611399578182fd5b6000602080835283518082850152825b81811015611bc757858101830151858201604001528201611bab565b81811115611bd85783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611c725784516001600160a01b031683529383019391830191600101611c4d565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611ca657611ca6611d01565b500190565b600082611cc657634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611ce557611ce5611d01565b500290565b600082821015611cfc57611cfc611d01565b500390565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461069657600080fd5b801515811461069657600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220b8d9c45db393eb6fcbbeacb2b2fb63d951bfe93d0d24ef689843eab54763612764736f6c63430008040033
{"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, 2581, 6679, 2575, 2683, 23833, 2094, 2581, 2063, 10790, 15878, 2509, 25031, 2475, 4783, 2692, 21084, 3540, 2094, 2575, 2546, 17134, 2620, 2094, 19481, 2487, 3207, 2497, 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, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 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,979
0x97aeb5066e1a590e868b511457beb6fe99d329f5
/** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * @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); } /** * @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 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) { uint256 c = a + b; assert(c >= a); return c; } } /** * @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]); // 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 view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title 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); 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 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); 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * @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 Recoverable is Ownable { /// @dev Empty constructor (for now) function Recoverable() { } /// @dev This will be invoked by the owner, when owner wants to rescue tokens /// @param token Token which will we rescue to the owner from the contract function recoverTokens(ERC20Basic token) onlyOwner public { token.transfer(owner, tokensToBeReturned(token)); } /// @dev Interface function, can be overwritten by the superclass /// @param token Token which balance we will check and return /// @return The amount of tokens (in smallest denominator) the contract owns function tokensToBeReturned(ERC20Basic token) public returns (uint) { return token.balanceOf(this); } } /** * Standard EIP-20 token with an interface marker. * * @notice Interface marker is used by crowdsale contracts to validate that addresses point a good token contract. * */ contract StandardTokenExt is StandardToken, Recoverable { /* Interface declaration */ function isToken() public constant returns (bool weAre) { return true; } } contract BurnableToken is StandardTokenExt { // @notice An address for the transfer event where the burned tokens are transferred in a faux Transfer event address public constant BURN_ADDRESS = 0; /** How many tokens we burned */ event Burned(address burner, uint burnedAmount); /** * Burn extra tokens from a balance. * */ function burn(uint burnAmount) { address burner = msg.sender; balances[burner] = balances[burner].sub(burnAmount); totalSupply_ = totalSupply_.sub(burnAmount); Burned(burner, burnAmount); // Inform the blockchain explores that track the // balances only by a transfer event that the balance in this // address has decreased Transfer(burner, BURN_ADDRESS, burnAmount); } } /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * Upgrade agent interface inspired by Lunyr. * * Upgrade agent transfers tokens to a new contract. * Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting. */ contract UpgradeAgent { uint public originalSupply; /** Interface marker */ function isUpgradeAgent() public constant returns (bool) { return true; } function upgradeFrom(address _from, uint256 _value) public; } /** * A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision. * * First envisioned by Golem and Lunyr projects. */ contract UpgradeableToken is StandardTokenExt { /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */ address public upgradeMaster; /** The next contract where the tokens will be migrated. */ UpgradeAgent public upgradeAgent; /** How many tokens we have upgraded by now. */ uint256 public totalUpgraded; /** * Upgrade states. * * - NotAllowed: The child contract has not reached a condition where the upgrade can bgun * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens * */ enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading} /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed _from, address indexed _to, uint256 _value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); /** * Do not allow construction without upgrade master set. */ function UpgradeableToken(address _upgradeMaster) { upgradeMaster = _upgradeMaster; } /** * Allow the token holder to upgrade some of their tokens to a new contract. */ function upgrade(uint256 value) public { UpgradeState state = getUpgradeState(); if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) { // Called in a bad state throw; } // Validate input value. if (value == 0) throw; balances[msg.sender] = balances[msg.sender].sub(value); // Take tokens out from circulation totalSupply_ = totalSupply_.sub(value); totalUpgraded = totalUpgraded.add(value); // Upgrade agent reissues the tokens upgradeAgent.upgradeFrom(msg.sender, value); Upgrade(msg.sender, upgradeAgent, value); } /** * Set an upgrade agent that handles */ function setUpgradeAgent(address agent) external { if(!canUpgrade()) { // The token is not yet in a state that we could think upgrading throw; } if (agent == 0x0) throw; // Only a master can designate the next agent if (msg.sender != upgradeMaster) throw; // Upgrade has already begun for an agent if (getUpgradeState() == UpgradeState.Upgrading) throw; upgradeAgent = UpgradeAgent(agent); // Bad interface if(!upgradeAgent.isUpgradeAgent()) throw; // Make sure that token supplies match in source and target if (upgradeAgent.originalSupply() != totalSupply_) throw; UpgradeAgentSet(upgradeAgent); } /** * Get the state of the token upgrade. */ function getUpgradeState() public constant returns(UpgradeState) { if(!canUpgrade()) return UpgradeState.NotAllowed; else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent; else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade; else return UpgradeState.Upgrading; } /** * Change the upgrade master. * * This allows us to set a new owner for the upgrade mechanism. */ function setUpgradeMaster(address master) public { if (master == 0x0) throw; if (msg.sender != upgradeMaster) throw; upgradeMaster = master; } /** * Child contract can enable to provide the condition when the upgrade can begun. */ function canUpgrade() public constant returns(bool) { return true; } } /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * Define interface for releasing the token transfer after a successful crowdsale. */ contract ReleasableToken is StandardTokenExt { /* The finalizer contract that allows unlift the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; /** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */ mapping (address => bool) public transferAgents; /** * Limit token transfer until the crowdsale is over. * */ modifier canTransfer(address _sender) { if(!released) { if(!transferAgents[_sender]) { throw; } } _; } /** * Set the contract that can call release and make the token transferable. * * Design choice. Allow reset the release agent to fix fat finger mistakes. */ function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; } /** * Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period. */ function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public { transferAgents[addr] = state; } /** * One way function to release the tokens to the wild. * * Can be called only from the release agent that is the final ICO contract. It is only called if the crowdsale has been success (first milestone reached). */ function releaseTokenTransfer() public onlyReleaseAgent { released = true; } /** The function can be called only before or after the tokens have been releasesd */ modifier inReleaseState(bool releaseState) { if(releaseState != released) { throw; } _; } /** The function can be called only by a whitelisted release agent. */ modifier onlyReleaseAgent() { if(msg.sender != releaseAgent) { throw; } _; } function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) { // Call StandardToken.transfer() return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) { // Call StandardToken.transferForm() return super.transferFrom(_from, _to, _value); } } /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * Safe unsigned safe math. * * https://blog.aragon.one/library-driven-development-in-solidity-2bebcaf88736#.750gwtwli * * Originally from https://raw.githubusercontent.com/AragonOne/zeppelin-solidity/master/contracts/SafeMathLib.sol * * Maintained here until merged to mainline zeppelin-solidity. * */ library SafeMathLib { function times(uint a, uint b) returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function minus(uint a, uint b) returns (uint) { assert(b <= a); return a - b; } function plus(uint a, uint b) returns (uint) { uint c = a + b; assert(c>=a); return c; } } /** * A token that can increase its supply by another contract. * * This allows uncapped crowdsale by dynamically increasing the supply when money pours in. * Only mint agents, contracts whitelisted by owner, can mint new tokens. * */ contract MintableToken is StandardTokenExt { using SafeMathLib for uint; bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state); event Minted(address receiver, uint amount); /** * Create new tokens and allocate them to an address.. * * Only callably by a crowdsale contract (mint agent). */ function mint(address receiver, uint amount) onlyMintAgent canMint public { totalSupply_ = totalSupply_.plus(amount); balances[receiver] = balances[receiver].plus(amount); // This will make the mint transaction apper in EtherScan.io // We can remove this after there is a standardized minting event Transfer(0, receiver, amount); } /** * Owner can allow a crowdsale contract to mint new tokens. */ function setMintAgent(address addr, bool state) onlyOwner canMint public { mintAgents[addr] = state; MintingAgentChanged(addr, state); } modifier onlyMintAgent() { // Only crowdsale contracts are allowed to mint new tokens if(!mintAgents[msg.sender]) { throw; } _; } /** Make sure we are not done yet. */ modifier canMint() { if(mintingFinished) throw; _; } } /** * A crowdsaled token. * * An ERC-20 token designed specifically for crowdsales with investor protection and further development path. * * - The token transfer() is disabled until the crowdsale is over * - The token contract gives an opt-in upgrade path to a new contract * - The same token can be part of several crowdsales through approve() mechanism * - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens) * */ contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken { /** Name and symbol were updated. */ event UpdatedTokenInformation(string newName, string newSymbol); string public name; string public symbol; uint public decimals; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. */ function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable) UpgradeableToken(msg.sender) { // Create any address, can be transferred // to team multisig via changeOwner(), // also remember to call setUpgradeMaster() owner = msg.sender; name = _name; symbol = _symbol; totalSupply_ = _initialSupply; decimals = _decimals; // Create initially all balance on the team multisig balances[owner] = totalSupply_; if(totalSupply_ > 0) { Minted(owner, totalSupply_); } // No more new supply allowed after the token creation if(!_mintable) { mintingFinished = true; if(totalSupply_ == 0) { throw; // Cannot create a token without supply and no minting } } } /** * When token is released to be transferable, enforce no new tokens can be created. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality kick in only if the crowdsale was success. */ function canUpgrade() public constant returns(bool) { return released && super.canUpgrade(); } /** * Owner can update token information here. * * It is often useful to conceal the actual token association, until * the token operations, like central issuance or reissuance have been completed. * * This function allows the token owner to rename the token after the operations * have been completed and then point the audience to use the token contract. */ function setTokenInformation(string _name, string _symbol) onlyOwner { name = _name; symbol = _symbol; UpdatedTokenInformation(name, symbol); } } /** * A crowdsaled token that you can also burn. * */ contract BurnableCrowdsaleToken is BurnableToken, CrowdsaleToken { function BurnableCrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable) CrowdsaleToken(_name, _symbol, _initialSupply, _decimals, _mintable) { } } /** * The AML Token * * This subset of BurnableCrowdsaleToken gives the Owner a possibility to * reclaim tokens from a participant before the token is released * after a participant has failed a prolonged AML process. * * It is assumed that the anti-money laundering process depends on blockchain data. * The data is not available before the transaction and not for the smart contract. * Thus, we need to implement logic to handle AML failure cases post payment. * We give a time window before the token release for the token sale owners to * complete the AML and claw back all token transactions that were * caused by rejected purchases. */ contract AMLToken is BurnableCrowdsaleToken { // An event when the owner has reclaimed non-released tokens event OwnerReclaim(address fromWhom, uint amount); function AMLToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable) BurnableCrowdsaleToken(_name, _symbol, _initialSupply, _decimals, _mintable) { } /// @dev Here the owner can reclaim the tokens from a participant if /// the token is not released yet. Refund will be handled offband. /// @param fromWhom address of the participant whose tokens we want to claim function transferToOwner(address fromWhom) onlyOwner { if (released) revert(); uint amount = balanceOf(fromWhom); balances[fromWhom] = balances[fromWhom].sub(amount); balances[owner] = balances[owner].add(amount); Transfer(fromWhom, owner, amount); OwnerReclaim(fromWhom, amount); } }
0x6060604052600436106101be5763ffffffff60e060020a60003504166302f652a381146101c357806305d2035b146101e957806306fdde0314610210578063095ea7b31461029a57806316114acd146102bc57806318160ddd146102db57806323b872dd1461030057806329ff4f5314610328578063313ce5671461034757806340c10f191461035a57806342966c681461037c57806342c1867b1461039257806343214675146103b157806345977d03146103d55780634eee966f146103eb5780635de4ccb01461047e5780635f412d4f146104ad578063600440cb146104c057806366188463146104d357806370a08231146104f5578063812d504d146105145780638444b39114610533578063867c28571461056a5780638da5cb5b1461058957806395d89b411461059c57806396132521146105af5780639738968c146105c2578063a9059cbb146105d5578063c45d19db146105f7578063c752ff6214610616578063d1f276d314610629578063d73dd6231461063c578063d7e7088a1461065e578063dd62ed3e1461067d578063eefa597b146106a2578063f2fde38b146106b5578063fccc2813146106d4578063ffeb7d75146106e7575b600080fd5b34156101ce57600080fd5b6101e7600160a060020a03600435166024351515610706565b005b34156101f457600080fd5b6101fc610778565b604051901515815260200160405180910390f35b341561021b57600080fd5b610223610781565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561025f578082015183820152602001610247565b50505050905090810190601f16801561028c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102a557600080fd5b6101fc600160a060020a036004351660243561081f565b34156102c757600080fd5b6101e7600160a060020a036004351661088b565b34156102e657600080fd5b6102ee61092f565b60405190815260200160405180910390f35b341561030b57600080fd5b6101fc600160a060020a0360043581169060243516604435610936565b341561033357600080fd5b6101e7600160a060020a036004351661099a565b341561035257600080fd5b6102ee610a10565b341561036557600080fd5b6101e7600160a060020a0360043516602435610a16565b341561038757600080fd5b6101e7600435610bb4565b341561039d57600080fd5b6101fc600160a060020a0360043516610c8e565b34156103bc57600080fd5b6101e7600160a060020a03600435166024351515610ca3565b34156103e057600080fd5b6101e7600435610d3f565b34156103f657600080fd5b6101e760046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650610ea795505050505050565b341561048957600080fd5b610491611015565b604051600160a060020a03909116815260200160405180910390f35b34156104b857600080fd5b6101e7611024565b34156104cb57600080fd5b610491611056565b34156104de57600080fd5b6101fc600160a060020a0360043516602435611065565b341561050057600080fd5b6102ee600160a060020a036004351661115f565b341561051f57600080fd5b6101e7600160a060020a036004351661117a565b341561053e57600080fd5b6105466112d4565b6040518082600481111561055657fe5b60ff16815260200191505060405180910390f35b341561057557600080fd5b6101fc600160a060020a036004351661131f565b341561059457600080fd5b610491611334565b34156105a757600080fd5b610223611343565b34156105ba57600080fd5b6101fc6113ae565b34156105cd57600080fd5b6101fc6113cf565b34156105e057600080fd5b6101fc600160a060020a0360043516602435611404565b341561060257600080fd5b6102ee600160a060020a0360043516611466565b341561062157600080fd5b6102ee6114df565b341561063457600080fd5b6104916114e5565b341561064757600080fd5b6101fc600160a060020a03600435166024356114f4565b341561066957600080fd5b6101e7600160a060020a0360043516611598565b341561068857600080fd5b6102ee600160a060020a036004358116906024351661174a565b34156106ad57600080fd5b6101fc611775565b34156106c057600080fd5b6101e7600160a060020a036004351661177a565b34156106df57600080fd5b610491611815565b34156106f257600080fd5b6101e7600160a060020a036004351661181a565b60035433600160a060020a0390811691161461072157600080fd5b60045460009074010000000000000000000000000000000000000000900460ff161561074c57600080fd5b50600160a060020a03919091166000908152600560205260409020805460ff1916911515919091179055565b60065460ff1681565b600b8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108175780601f106107ec57610100808354040283529160200191610817565b820191906000526020600020905b8154815290600101906020018083116107fa57829003601f168201915b505050505081565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60035433600160a060020a039081169116146108a657600080fd5b600354600160a060020a038083169163a9059cbb91166108c584611466565b60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561091157600080fd5b6102c65a03f1151561092257600080fd5b5050506040518051505050565b6001545b90565b600454600090849074010000000000000000000000000000000000000000900460ff16151561098657600160a060020a03811660009081526005602052604090205460ff16151561098657600080fd5b610991858585611879565b95945050505050565b60035433600160a060020a039081169116146109b557600080fd5b60045460009074010000000000000000000000000000000000000000900460ff16156109e057600080fd5b506004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600d5481565b600160a060020a03331660009081526007602052604090205460ff161515610a3d57600080fd5b60065460ff1615610a4d57600080fd5b60015473850493fd6f7a92f6d462ccba9e438b76b000bcc16366098d4f90918360006040516020015260405160e060020a63ffffffff85160281526004810192909252602482015260440160206040518083038186803b1515610aaf57600080fd5b6102c65a03f41515610ac057600080fd5b505050604051805160015550600160a060020a0382166000908152602081905260408082205473850493fd6f7a92f6d462ccba9e438b76b000bcc1926366098d4f92859190516020015260405160e060020a63ffffffff85160281526004810192909252602482015260440160206040518083038186803b1515610b4357600080fd5b6102c65a03f41515610b5457600080fd5b5050506040518051600160a060020a03841660008181526020819052604080822093909355909250907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a35050565b33600160a060020a038116600090815260208190526040902054610bd890836119f9565b600160a060020a038216600090815260208190526040902055600154610c04908363ffffffff6119f916565b6001557f696de425f79f4a40bc6d2122ca50507f0efbeabbff86a84871b7196ab8ea8df78183604051600160a060020a03909216825260208201526040908101905180910390a16000600160a060020a0382167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a35050565b60076020526000908152604090205460ff1681565b60035433600160a060020a03908116911614610cbe57600080fd5b60065460ff1615610cce57600080fd5b600160a060020a03821660009081526007602052604090819020805460ff19168315151790557f4b0adf6c802794c7dde28a08a4e07131abcff3bf9603cd71f14f90bec7865efa908390839051600160a060020a039092168252151560208201526040908101905180910390a15050565b6000610d496112d4565b90506003816004811115610d5957fe5b1480610d7057506004816004811115610d6e57fe5b145b1515610d7b57600080fd5b811515610d8757600080fd5b600160a060020a033316600090815260208190526040902054610db0908363ffffffff6119f916565b600160a060020a033316600090815260208190526040902055600154610ddc908363ffffffff6119f916565b600155600a54610df2908363ffffffff611a0b16565b600a55600954600160a060020a031663753e88e5338460405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b1515610e4b57600080fd5b6102c65a03f11515610e5c57600080fd5b5050600954600160a060020a03908116915033167f7e5c344a8141a805725cb476f76c6953b842222b967edd1f78ddb6e8b3f397ac8460405190815260200160405180910390a35050565b60035433600160a060020a03908116911614610ec257600080fd5b600b828051610ed5929160200190611b85565b50600c818051610ee9929160200190611b85565b507fd131ab1e6f279deea74e13a18477e13e2107deb6dc8ae955648948be5841fb46600b600c604051604080825283546002600019610100600184161502019091160490820181905281906020820190606083019086908015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b50508381038252845460026000196101006001841615020190911604808252602090910190859080156110015780601f10610fd657610100808354040283529160200191611001565b820191906000526020600020905b815481529060010190602001808311610fe457829003601f168201915b505094505050505060405180910390a15050565b600954600160a060020a031681565b60045433600160a060020a0390811691161461103f57600080fd5b6006805460ff19166001179055611054611a21565b565b600854600160a060020a031681565b600160a060020a033381166000908152600260209081526040808320938616835292905290812054808311156110c257600160a060020a0333811660009081526002602090815260408083209388168352929052908120556110f9565b6110d2818463ffffffff6119f916565b600160a060020a033381166000908152600260209081526040808320938916835292905220555b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526020819052604090205490565b60035460009033600160a060020a0390811691161461119857600080fd5b60045474010000000000000000000000000000000000000000900460ff16156111c057600080fd5b6111c98261115f565b600160a060020a0383166000908152602081905260409020549091506111f5908263ffffffff6119f916565b600160a060020a03808416600090815260208190526040808220939093556003549091168152205461122d908263ffffffff611a0b16565b60038054600160a060020a0390811660009081526020819052604090819020939093559054811691908416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a37f6b3f5f84a24147dab46359bf96b628286e8962759491b8c0e11e50770c8cc1368282604051600160a060020a03909216825260208201526040908101905180910390a15050565b60006112de6113cf565b15156112ec57506001610933565b600954600160a060020a0316151561130657506002610933565b600a54151561131757506003610933565b506004610933565b60056020526000908152604090205460ff1681565b600354600160a060020a031681565b600c8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108175780601f106107ec57610100808354040283529160200191610817565b60045474010000000000000000000000000000000000000000900460ff1681565b60045460009074010000000000000000000000000000000000000000900460ff1680156113ff57506113ff611775565b905090565b600454600090339074010000000000000000000000000000000000000000900460ff16151561145457600160a060020a03811660009081526005602052604090205460ff16151561145457600080fd5b61145e8484611a73565b949350505050565b600081600160a060020a03166370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156114bf57600080fd5b6102c65a03f115156114d057600080fd5b50505060405180519392505050565b600a5481565b600454600160a060020a031681565b600160a060020a03338116600090815260026020908152604080832093861683529290529081205461152c908363ffffffff611a0b16565b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b6115a06113cf565b15156115ab57600080fd5b600160a060020a03811615156115c057600080fd5b60085433600160a060020a039081169116146115db57600080fd5b60046115e56112d4565b60048111156115f057fe5b14156115fb57600080fd5b6009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911791829055166361d3d7a66000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561166657600080fd5b6102c65a03f1151561167757600080fd5b50505060405180519050151561168c57600080fd5b600154600954600160a060020a0316634b2ba0dd6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156116d757600080fd5b6102c65a03f115156116e857600080fd5b505050604051805190501415156116fe57600080fd5b6009547f7845d5aa74cc410e35571258d954f23b82276e160fe8c188fa80566580f279cc90600160a060020a0316604051600160a060020a03909116815260200160405180910390a150565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600190565b60035433600160a060020a0390811691161461179557600080fd5b600160a060020a03811615156117aa57600080fd5b600354600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600081565b600160a060020a038116151561182f57600080fd5b60085433600160a060020a0390811691161461184a57600080fd5b6008805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000600160a060020a038316151561189057600080fd5b600160a060020a0384166000908152602081905260409020548211156118b557600080fd5b600160a060020a03808516600090815260026020908152604080832033909416835292905220548211156118e857600080fd5b600160a060020a038416600090815260208190526040902054611911908363ffffffff6119f916565b600160a060020a038086166000908152602081905260408082209390935590851681522054611946908363ffffffff611a0b16565b600160a060020a038085166000908152602081815260408083209490945587831682526002815283822033909316825291909152205461198c908363ffffffff6119f916565b600160a060020a03808616600081815260026020908152604080832033861684529091529081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b600082821115611a0557fe5b50900390565b600082820183811015611a1a57fe5b9392505050565b60045433600160a060020a03908116911614611a3c57600080fd5b6004805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b6000600160a060020a0383161515611a8a57600080fd5b600160a060020a033316600090815260208190526040902054821115611aaf57600080fd5b600160a060020a033316600090815260208190526040902054611ad8908363ffffffff6119f916565b600160a060020a033381166000908152602081905260408082209390935590851681522054611b0d908363ffffffff611a0b16565b60008085600160a060020a0316600160a060020a031681526020019081526020016000208190555082600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a350600192915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611bc657805160ff1916838001178555611bf3565b82800160010185558215611bf3579182015b82811115611bf3578251825591602001919060010190611bd8565b50611bff929150611c03565b5090565b61093391905b80821115611bff5760008155600101611c095600a165627a7a72305820ce7f5f4d04546e3a0e6f235c247130c830f5f86a8b19d212952d3a12a672402e0029
{"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, 2581, 6679, 2497, 12376, 28756, 2063, 2487, 2050, 28154, 2692, 2063, 20842, 2620, 2497, 22203, 16932, 28311, 4783, 2497, 2575, 7959, 2683, 2683, 2094, 16703, 2683, 2546, 2629, 1013, 1008, 1008, 1008, 2023, 6047, 3206, 3642, 2003, 9385, 2418, 19204, 20285, 5183, 1012, 2005, 2062, 2592, 2156, 16770, 1024, 1013, 1013, 19204, 20285, 1012, 5658, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1024, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 19204, 20285, 7159, 1013, 24582, 2080, 1013, 1038, 4135, 2497, 1013, 3040, 1013, 6105, 1012, 19067, 2102, 1008, 1013, 1013, 1008, 1008, 1008, 2023, 6047, 3206, 3642, 2003, 9385, 2418, 19204, 20285, 5183, 1012, 2005, 2062, 2592, 2156, 16770, 1024, 1013, 1013, 19204, 20285, 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,980
0x97Af01052Ba78FBC3Af047CC34eE349a55FA7a97
// SPDX-License-Identifier: MIT License // www.snap-universe.com //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMMMMMMMWX0kdooolllllooooodxOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMMMWXkdlc:;:::cccccccc::;;;;cokXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMMW0dc;:cccccccccccccccccccccc:;cdKWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMMWk::ccccccccccccccccccccccccccc:;;o0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMWk;:ccccccccccccccccccccccccccccccc;;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMMK:,ccccccccccccccccccccccccccccccccc:;:OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMWd,:ccccccccccccccccccccccccccccccccccc:;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMMO:;ccccccccccccccccccccccccccccccccccccc;:0MMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMMXc,:cccccc::ccc::cccc:ccccccccccccccccccc::0MMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMKdc,,::cccc:;::::::::c:;;:ccccccccccccccccc;cKMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMWo,::;,;ccc:;;::::::::cc:;;:cccccccccccccccc;dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMNo,;,;;';cc::;;,,;,,;;;::::;:cccccccccccccc:;kMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMO::;'.,;:ccc:;,;;;;;:;,,,::::c::::ccccc:::c;cKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMO;::;,;c:::cccc::;,,,,,'.';::c:,,::::c:::::;oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMNo,c;,:::::::cc:::,..''...,;;;;;;;;::::::::,dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMWo'::,:c::;::::::cc:;,,..,;;,,;;,,;;:::;;;;;xMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMO,':::ccc:;;;:cccccc::::c:::;;;''',,,;;;;;':0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMWO;';,,:ccccc:;::::cccccccccc;;c:,,,''...;::oKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMXx,,:c;,:c:cccc;,;:ccccc:::cc::cc;';::;;,';d0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMWNK0kd;,,;c:,;c::::c:;;:cccc::,,;:ccc:;,,:cccc:;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //0Oxdooc::;,;:::c:',c;;:c:;;:cccccc:;;;;;ccc:,,;cccc;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //;,;;:cccc:::;;ccc,.';;:c;;:c::::::cccc;;;;;;;;:c:;;oKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //ccc:::ccccc:;:ccc:. .';c;,::;,,;;;;::::::::cccc;':ONMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //cccccccccccc:::ccc' .,c:;:c:::::::;,,;;:;;::;;,lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //ccccccccccccc:;:cc,. .:c:ccccc:;;;;,,::;,;;;,,oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //ccccc;;:ccccc;;:cc;. 'cccccccc::;;,;::;:::;;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //cc:,,',:::cc:,;ccc:. .;ccccccccccccccc:,,ckKNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //:,.',;:::::;,;cccc:.... .:cccccccc:::cc:'..l0XNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //..,:,:c:c:;,;ccccc:'';. ...',,,;;;;:cc,. .':lONMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //..,,;:cc:,,;cc;;:c:',c,. ..'''.. ...,:d0NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //::;,,,,,',:cc:,,:c:,;c:;,,'.... .'''..''';;.,cdkKNNWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //..',:::;,,;;::;;:c:;::::;,,;,.. .. ..;:cccc:::c:;;;,,;;coxONWMMMMMMMMMMMMMMMMMMMMMMMMMMM //,,'',;::c:;;;,,',::;:c:,',:;... ...',..;cccccccccc;,''''''';cdONMMMMMMMMMMMMMMMMMMMMMMMMM //ccc::::cccccc:::;;,',c,.,::'.,;. ';',;'.,,;;;;::cc:::cccc:::c:;lkXMMMMMMMMMMMMMMMMMMMMMMM //ccccccccccccccccc:;'';',:;,'',;,..',,,,;,;;;:cc:::::ccccccccccccc:lOWMMMMMMMMMMMMMMMMMMMMM //cccccccccccccccccccc;,,;,,::::::::::cc::;;;;,,,'...';:ccccc:ccccc:,,xWMMMMMMMMMMMMMMMMMMMM //:::cccccccccccccccccc::::cccccccccccc:::::::::::;;;;;:::cccccccccc:',OMMMMMMMMMMMMMMMMMMMM //:::cccccccccccccccccc::cccccccccccccccccccccccccccccc:;,;c:ccccccccc;c0WMMMMMMMMMMMMMMMMMM //:::cccccccccccccccccc;,:c:cccccccccccccccccccccccccccc:,':cccccccccc:;:0WMMMMMMMMMMMMMMMMM //::ccccccccccccccccccc;,:c:ccccccccccccccccccccccccccccc:',cccccccccc::;:OWMMMMMMMMMMMMMMMM //::ccccccccccccccccccc;,::::ccccccccccccccccccccccccccccc,':c:ccccccc::c;cKMMMMMMMMMMMMMMMM pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract SnapUniverse is ERC721URIStorage, ERC721Pausable, Ownable { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; Counters.Counter private _tokenIds; uint256 public totalSupply; uint256 private fee; uint256 private buyLimitMintPass; uint256 private buyLimitWhitelist; uint256 private buyLimitPublicSale; uint256 private snapSupplyToMintPass; bool private modeWhitelist; string private _baseURIPrefix; address private snapAddress; address payable private cashOutWallet; address[] private cashOutCallers; address private constant _deadWalletAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => bool) private mintPassClaimed; mapping (address => uint256) private mp; mapping (address => uint256) private mintedWhiteList; receive() external payable {} event MintPassClaimed(address wallet, uint256 count); constructor(address _snapAddress) ERC721("Snap! Universe", "SNAP! UNIVERSE") { totalSupply = 10_000; fee = 0.09 ether; buyLimitMintPass = 25; buyLimitWhitelist = totalSupply; buyLimitPublicSale = totalSupply; modeWhitelist = true; snapAddress =_snapAddress; snapSupplyToMintPass = 200000000000000000000; _baseURIPrefix = "ipfs://QmNTH97qJsBkzTy3U7vNsjMErSNeaTMmbdvxzCUFB2Cmrn/"; cashOutWallet = payable(0x751ee118d4C37896479de3C1C238e84a6Fde7cC7); cashOutCallers = [msg.sender, 0x071B6eb0199F81Bd23044B0B3456a8aABEc42AB5, 0xcbA1d08dEc5eECa6573Fd692037F483C97939716, 0x24736E4a794bc48844dBCE629bE83E859403bA4c, 0x98D9cE6C5AF6c3d28F59F76839BAd4bd673F3BE8, 0x345E4c008a5aaC91bc2b384cC636b0217210Fb49]; mp[0xcbA1d08dEc5eECa6573Fd692037F483C97939716] = 2; mp[0x8456f1C4f8e6B1b356E5DcdA43D3b51309ef6c8F] = 4; mp[0xb2843F7aC8d82322BC3438643fb5A1CE42DA20A4] = 2; mp[0xe982E27715265B6FE8fd10FcBb4F13C37526CBeE] = 1; mp[0x4579Ac723c85855F0cD945a41D4D8a70ABA589a3] = 1; mp[0xD5Ed3eab8733ac8Ded7BfCe5fdB8D6265ee5Acc9] = 1; mp[0x68326658D43995f9dCdaa34B4927DE48798A9cDa] = 2; mp[0x07587c046d4d4BD97C2d64EDBfAB1c1fE28A10E5] = 4; mp[0x3F049E5850229d18f01460DFda38c3ea6422b5a4] = 4; mp[0x0DB0f4506F5De744052D90f04E3fcA3D1dD3600d] = 1; mp[0x988ceCe1a783e62627cf2E95b7dcd46cD6217f15] = 3; mp[0x3EeA9Bfa4e1E348FBCA79bEC1BFD900775701C12] = 3; mp[0xc5BD4cbb6edF957AB6E4e27D2F14921ddc0f0dE0] = 3; mp[0xf3F9D042781dB15c19b02B77d55A2a15a45ae305] = 11; mp[0x22CAb0b36CC4EC24Bfd5732D07828b45E7547F9e] = 1; mp[0xD39a841f45D230d22413D80895e3Fd95c0daEd4A] = 2; mp[0x78E37187998bf8886e13c50252815f2571E4fC6E] = 1; mp[0xf92EF75557F11bd68ced35edE822A6622fB0F6fc] = 4; mp[0x483a3b616885ce3b2225B2AFaFE0CbE47b4BE1B9] = 1; mp[0xB78fD9E442EEf5f34c939AC9209319146654A361] = 3; mp[0x1D309f17AE5645e189268ff739DAf8FF68EBd312] = 3; mp[0x04C1F863Aad0604119c78faC46E74f5a1d65368D] = 2; mp[0xe24f1714203518c0972f9E81286E273b445980B5] = 4; mp[0x4Ca6c98A67c65Dc90d3106d0d090d74C6D53fbBb] = 1; mp[0x125377dBDB4Ed6B49F57a569A3D9282F8E3F5366] = 2; mp[0x14df5677aa90eC0D64c631621DaD80b44f9DeAFF] = 1; mp[0x04bfcB7b6bc81361F14c1E2C7592d712e3b9f456] = 4; mp[0x07B167B84021419F8385fA5fA1733F6230Ec0b27] = 1; mp[0xdCAff5C361fc6f36143394ADE1Ce84e5CDe439Ab] = 1; mp[0x83613775bEF3111Fe58479ABb94dB247245A051f] = 1; mp[0xCAee9112E87A90510dc280Ad6DfF500b092E383F] = 1; mp[0xb045985c32390d3cE12300f73cEB8Dd805673027] = 4; mp[0xd1177558b645e063f38AF09ae9454Cb3786BB9E0] = 3; mp[0x0B01fE5189d95c0fa890fd6b431928B5dF58D027] = 1; mp[0xC12c0577b0E1F47Ce2e2148996f6845DC24631b2] = 2; mp[0x1F2C87b25830C710a56B2aA7035342d99BC1cBbA] = 2; mp[0xDb925a4c46e8Ac000b80ccd82b1fdb472C70cb31] = 2; mp[0x5fd9C4368ee7E8fc79e48fBa390c148fd16453Ee] = 2; mp[0x88092758B19f330234CFc851Ab4Ef2B974665476] = 2; mp[0xad9F7000c2278c1D58554e6348866104e82c2E39] = 4; mp[0x236797eb343408668D6F5D34c0FF04387545AA3A] = 1; mp[0xf8e8dEda67cFB656cC067A42E170B5eA852111D5] = 3; mp[0x2bEae0f40aEE2D68fb9844B2CC70AD545B0e1150] = 1; mp[0xfC30085ad17D7340dd73bACeFb8D9f8C6b0F307F] = 1; mp[0x1821Ce945bbCD7253cA349c54EF0a302e88b2346] = 1; mp[0xC9a30725312B2d137CAFfdF2c707826cb641C206] = 1; mp[0x07211045B99A9f924c439988bbCbcDb3712f226D] = 1; mp[0x71cfe23928616DEd724ca9DC90a64409a071D29C] = 1; mp[0x74fac75DFd8f2B75AAebeD2614455E670be807af] = 1; mp[0x202c07Cbc8ae17Da8Fd9eE2563067250A0f546De] = 1; mp[0xF8D9624c05C668fee9FeB91505D273068901872d] = 1; mp[0x023B141c2cE8f79B19fcda0DaAEE4a4542f9a2B7] = 1; mp[0xD8bfDA9368e0DdA6d81ca79e78DDe703471dB283] = 1; mp[0x3141F76EF4c7709d978A27B38f2971751f88cF0F] = 1; mp[0x3Ee4c0ba4D05c3B1f7C3B3754E5ddf65e1CaC361] = 1; mp[0xAC7CF6bA79896d90f02FB61d76502918845c1947] = 1; mp[0x35066f85686C1f1aF829385c88CaD2DAb8a5A9b3] = 1; mp[0x48483532FdEaAE4c3EfD9fc0fe198FD9b205f83a] = 1; mp[0x4F3EdF987c6e434C9a57eCc2182f4e9B38B9D8dC] = 1; mp[0xeBdBFa365Efa6d1DA06d2b7CBf7E54D2B5Dd7185] = 2; mp[0x3D031Cd569400fD3b3f7FA9ADf6a3b131a43c197] = 1; mp[0x1f171834FeF16233ae93BB3acA99d83021EA00c4] = 1; mp[0x7d07B59090f481BA8FF7a67422C04595CB2C93B2] = 1; mp[0x1cd75A8387c0e36061b270af917AFb206634918c] = 1; mp[0x2C7F7Db1710B02F19cCB2Ab3f88Fc74A467fF5c9] = 1; mp[0xc2DfCFa2Bf1C871cB5af60b7eFBd95864984129D] = 1; mp[0xDe25b8bf8149913097AfA99EF52f9b6bF86De1eC] = 1; mp[0xCaC624276Df3bA84Bbb68270769a49a1e5c270d3] = 1; mp[0xc266672ab58f57C945fC5fe5cD89B2Ae591c6124] = 1; mp[0xf7C4e374e116b68c5324463949Ba3c5275B27236] = 1; mp[0x8b885f80feC49F397f0B53dB86aE8af4235C4763] = 1; mp[0x47923342988F3fD29EE6292Ad9A440728440ce4C] = 1; mp[0xd224c1061F9eD4bfbCddb1b45bB41eEa24b770e3] = 1; mp[0x205c726fE98b962530acd54C57EfD600f6AAfD50] = 1; mp[0xB45fCf6e1DAB1f15a21449d75F00Eef34fa7CB5e] = 1; mp[0xC43327b13ec860d8303e02CDC891b064BB5B7c4e] = 1; mp[0x45F8aef4DfaBfbF943416Db1e43f088e543bFDB6] = 1; mp[0x83D77D2199e8FB4aE195d464701de13D68C6671f] = 1; mp[0x18e4351436C02574b37c3526CF3D8C2057fa3Ca4] = 1; mp[0x57fbfe9726F7c0F8BD507d23113d892D6d541F45] = 1; mp[0x1183BDB0a24DC6ED62127F59eEe9De2fB410251A] = 1; mp[0xA32922d422F726AD0d10Dbf65d22B86e074aF68B] = 1; mp[0xd21f21Ed6B663028D6B9fC31f240e6D42A2E401b] = 1; mp[0x47B3A74eDa0042BbbD4C1a08c748171004233972] = 1; mp[0x4565F34C301f0b211854e025c67064A6a302837e] = 1; mp[0x5DCa0725DA4ABa4c253a17Dd3Bdae912CC9cCe97] = 1; mp[0x056161C77b4c4e51592bDff3dED1f4f14C600ECC] = 1; mp[0x64dc4cD18A82218BEaC92310Fbde8a46BD03a5fC] = 1; mintOwner(); _pause(); } function setBaseURI(string memory baseURIPrefix) external onlyOwner { _baseURIPrefix = baseURIPrefix; } function _baseURI() internal view override returns (string memory) { return _baseURIPrefix; } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } /** * @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); } function beforeMint(uint256 numberOfMints) internal view { address sender = _msgSender(); require(!sender.isContract() && tx.origin == sender, "Bots have no power here!"); require(_tokenIds.current() + numberOfMints <= totalSupply, "Maximum amount of tokens already minted"); } function mintPass_EWa9pesKnnMe(address wallet) whenNotPaused external returns (uint256) { uint256 numberOfMints = getMintPass(wallet).mul(2); uint mpFromSnap = IERC20(snapAddress).balanceOf(wallet).div(snapSupplyToMintPass); numberOfMints = numberOfMints.add(mpFromSnap.mul(2)); if (numberOfMints > buyLimitMintPass) { numberOfMints = buyLimitMintPass; } require(numberOfMints > 0, "Cannot claim"); beforeMint(numberOfMints); require(numberOfMints <= buyLimitMintPass, "You reached buy limit from single tx"); require(!mintPassClaimed[wallet], "You reached wallet limit"); mintPassClaimed[wallet] = true; doMint(wallet, numberOfMints); emit MintPassClaimed(wallet, numberOfMints); return _tokenIds.current(); } function mintWhitelist_kJipc46qGX3K(address wallet, uint256 numberOfMints) whenNotPaused external payable returns (uint256) { beforeMint(numberOfMints); require(modeWhitelist, "Invoke same method but for public sale"); require(numberOfMints <= buyLimitWhitelist, "You reached buy limit from single tx"); require(mintedWhiteList[wallet].add(numberOfMints) <= buyLimitWhitelist, "You reached wallet limit"); require(msg.value >= fee * numberOfMints, "Fee is not correct."); mintedWhiteList[wallet] = mintedWhiteList[wallet].add(numberOfMints); doMint(wallet, numberOfMints); return _tokenIds.current(); } function mintPublic_NbrluxKI1WhB(address wallet, uint256 numberOfMints) whenNotPaused external payable returns (uint256) { beforeMint(numberOfMints); require(numberOfMints <= buyLimitPublicSale, "You reached buy limit from single tx"); require(msg.value >= fee * numberOfMints, "Fee is not correct."); doMint(wallet, numberOfMints); return _tokenIds.current(); } function doMint(address wallet, uint numberOfMints) private { for(uint i = 0; i < numberOfMints; i++) { _tokenIds.increment(); uint256 tokenId = _tokenIds.current(); _safeMint(wallet, tokenId); string memory tokenURISuffix = string(abi.encodePacked(toString(tokenId), ".json")); _setTokenURI(tokenId, tokenURISuffix); } } function mintOwner() private onlyOwner returns (uint256) { require(_tokenIds.current() == 0); doMint(msg.sender, 200); return _tokenIds.current(); } function mintSpecial(address wallet) external onlyOwner returns (uint256) { doMint(wallet, 1); totalSupply = totalSupply.add(1); return _tokenIds.current(); } function setTotalSupply(uint256 _totalSupply) external onlyOwner { totalSupply = _totalSupply; } function setFee(uint256 _fee) external onlyOwner { fee = _fee; } function setBuyLimitMintPass(uint256 _buyLimitMintPass) external onlyOwner { buyLimitMintPass = _buyLimitMintPass; } function setBuyLimitWhitelist(uint256 _buyLimitWhitelist) external onlyOwner { buyLimitWhitelist = _buyLimitWhitelist; } function setBuyLimitPublicSale(uint256 _buyLimitPublicSale) external onlyOwner { buyLimitPublicSale = _buyLimitPublicSale; } function getFee() external view returns (uint) { return fee; } function cashOut() external { require(msg.sender == cashOutCallers[0] || msg.sender == cashOutCallers[1] || msg.sender == cashOutCallers[2] || msg.sender == cashOutCallers[3] || msg.sender == cashOutCallers[4] || msg.sender == cashOutCallers[5], "Should be called with whitelisted wallet"); cashOutWallet.call{value: address(this).balance}(""); } function currentTokenId() external view returns (uint256) { return _tokenIds.current(); } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function setModeWhitelist(bool _modeWhitelist) external onlyOwner { modeWhitelist = _modeWhitelist; } function setSnapAddress(address _snapAddress) external onlyOwner { snapAddress = _snapAddress; } function setSnapSupplyToMintPass(uint256 _snapSupplyToMintPass) external onlyOwner { snapSupplyToMintPass = _snapSupplyToMintPass; } function setMintPass(address a, uint256 tokens) external onlyOwner { if (tokens == 0) { delete mp[a]; } else { mp[a] = tokens; } } function getMintPass(address _address) public view returns (uint256) { return mp[_address]; } } // 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 "./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}. 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 { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * 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.8.0; import "../ERC721.sol"; /** * @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]; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../security/Pausable.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 ERC721Pausable is ERC721, Pausable { /** * @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"); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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;` */ 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; } } } // 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; // 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.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. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * 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/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; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = "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] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
0x6080604052600436106102285760003560e01c806363fe5cca11610123578063a22cb465116100ab578063d0f83a301161006f578063d0f83a301461061d578063d84e575b1461063d578063e985e9c514610673578063f2fde38b146106bc578063f7ea7a3d146106dc57600080fd5b8063a22cb46514610588578063b88d4fde146105a8578063c813f5fb146105c8578063c87b56dd146105e8578063ced72f871461060857600080fd5b8063793cd71e116100f2578063793cd71e146105065780638456cb591461051b5780638da5cb5b1461053057806395d89b4114610553578063a16a3e5a1461056857600080fd5b806363fe5cca1461049157806369fe0e2d146104b157806370a08231146104d1578063715018a6146104f157600080fd5b8063229c1160116101b1578063484664021161017557806348466402146103f95780634a4523281461041957806355f804b3146104395780635c975abb146104595780636352211e1461047157600080fd5b8063229c11601461037157806323b872dd146103845780633f4ba83a146103a45780634135149e146103b957806342842e0e146103d957600080fd5b8063081812fc116101f8578063081812fc146102c1578063095ea7b3146102f957806312e14cbf1461031b57806318160ddd1461033b5780631a7ab7461461035157600080fd5b80629a9b7b1461023457806301ffc9a71461025c57806306fba1c11461028c57806306fdde031461029f57600080fd5b3661022f57005b600080fd5b34801561024057600080fd5b506102496106fc565b6040519081526020015b60405180910390f35b34801561026857600080fd5b5061027c6102773660046127cc565b61070c565b6040519015158152602001610253565b61024961029a366004612787565b61075e565b3480156102ab57600080fd5b506102b4610825565b6040516102539190612942565b3480156102cd57600080fd5b506102e16102dc36600461284f565b6108b7565b6040516001600160a01b039091168152602001610253565b34801561030557600080fd5b50610319610314366004612787565b61093f565b005b34801561032757600080fd5b506103196103363660046127b1565b610a55565b34801561034757600080fd5b5061024960095481565b34801561035d57600080fd5b5061031961036c36600461284f565b610a98565b61024961037f366004612787565b610acd565b34801561039057600080fd5b5061031961039f3660046126a5565b610c8c565b3480156103b057600080fd5b50610319610cbd565b3480156103c557600080fd5b506103196103d436600461284f565b610cf7565b3480156103e557600080fd5b506103196103f43660046126a5565b610d2c565b34801561040557600080fd5b50610319610414366004612787565b610d47565b34801561042557600080fd5b5061031961043436600461284f565b610db7565b34801561044557600080fd5b50610319610454366004612806565b610dec565b34801561046557600080fd5b5060075460ff1661027c565b34801561047d57600080fd5b506102e161048c36600461284f565b610e2f565b34801561049d57600080fd5b506102496104ac366004612657565b610ea6565b3480156104bd57600080fd5b506103196104cc36600461284f565b610f02565b3480156104dd57600080fd5b506102496104ec366004612657565b610f37565b3480156104fd57600080fd5b50610319610fbe565b34801561051257600080fd5b5061031961103e565b34801561052757600080fd5b5061031961120d565b34801561053c57600080fd5b5060075461010090046001600160a01b03166102e1565b34801561055f57600080fd5b506102b4611245565b34801561057457600080fd5b50610319610583366004612657565b611254565b34801561059457600080fd5b506103196105a336600461275d565b6112a6565b3480156105b457600080fd5b506103196105c33660046126e1565b61136b565b3480156105d457600080fd5b506103196105e336600461284f565b6113a3565b3480156105f457600080fd5b506102b461060336600461284f565b6113d8565b34801561061457600080fd5b50600a54610249565b34801561062957600080fd5b50610249610638366004612657565b6113e3565b34801561064957600080fd5b50610249610658366004612657565b6001600160a01b031660009081526015602052604090205490565b34801561067f57600080fd5b5061027c61068e366004612672565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156106c857600080fd5b506103196106d7366004612657565b61163b565b3480156106e857600080fd5b506103196106f736600461284f565b611737565b600061070760085490565b905090565b60006001600160e01b031982166380ac58cd60e01b148061073d57506001600160e01b03198216635b5e139f60e01b145b8061075857506301ffc9a760e01b6001600160e01b03198316145b92915050565b600061076c60075460ff1690565b156107925760405162461bcd60e51b8152600401610789906129a7565b60405180910390fd5b61079b826117e6565b600d548211156107bd5760405162461bcd60e51b815260040161078990612a06565b81600a546107cb9190612ac7565b3410156108105760405162461bcd60e51b81526020600482015260136024820152722332b29034b9903737ba1031b7b93932b1ba1760691b6044820152606401610789565b61081a83836118bf565b6008545b9392505050565b60606000805461083490612b29565b80601f016020809104026020016040519081016040528092919081815260200182805461086090612b29565b80156108ad5780601f10610882576101008083540402835291602001916108ad565b820191906000526020600020905b81548152906001019060200180831161089057829003601f168201915b5050505050905090565b60006108c28261193a565b6109235760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610789565b506000908152600460205260409020546001600160a01b031690565b600061094a82610e2f565b9050806001600160a01b0316836001600160a01b031614156109b85760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610789565b336001600160a01b03821614806109d457506109d4813361068e565b610a465760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610789565b610a508383611957565b505050565b6007546001600160a01b03610100909104163314610a855760405162461bcd60e51b8152600401610789906129d1565b600f805460ff1916911515919091179055565b6007546001600160a01b03610100909104163314610ac85760405162461bcd60e51b8152600401610789906129d1565b600c55565b6000610adb60075460ff1690565b15610af85760405162461bcd60e51b8152600401610789906129a7565b610b01826117e6565b600f5460ff16610b625760405162461bcd60e51b815260206004820152602660248201527f496e766f6b652073616d65206d6574686f642062757420666f72207075626c69604482015265632073616c6560d01b6064820152608401610789565b600c54821115610b845760405162461bcd60e51b815260040161078990612a06565b600c546001600160a01b038416600090815260166020526040902054610baa90846119c5565b1115610bf35760405162461bcd60e51b8152602060048201526018602482015277165bdd481c995858da1959081dd85b1b195d081b1a5b5a5d60421b6044820152606401610789565b81600a54610c019190612ac7565b341015610c465760405162461bcd60e51b81526020600482015260136024820152722332b29034b9903737ba1031b7b93932b1ba1760691b6044820152606401610789565b6001600160a01b038316600090815260166020526040902054610c6990836119c5565b6001600160a01b03841660009081526016602052604090205561081a83836118bf565b610c9633826119d1565b610cb25760405162461bcd60e51b815260040161078990612a4a565b610a50838383611ab7565b6007546001600160a01b03610100909104163314610ced5760405162461bcd60e51b8152600401610789906129d1565b610cf5611c62565b565b6007546001600160a01b03610100909104163314610d275760405162461bcd60e51b8152600401610789906129d1565b600e55565b610a508383836040518060200160405280600081525061136b565b6007546001600160a01b03610100909104163314610d775760405162461bcd60e51b8152600401610789906129d1565b80610d9757506001600160a01b0316600090815260156020526040812055565b6001600160a01b03821660009081526015602052604090208190555b5050565b6007546001600160a01b03610100909104163314610de75760405162461bcd60e51b8152600401610789906129d1565b600d55565b6007546001600160a01b03610100909104163314610e1c5760405162461bcd60e51b8152600401610789906129d1565b8051610db3906010906020840190612521565b6000818152600260205260408120546001600160a01b0316806107585760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610789565b6007546000906001600160a01b03610100909104163314610ed95760405162461bcd60e51b8152600401610789906129d1565b610ee48260016118bf565b600954610ef29060016119c5565b600955600854610758565b919050565b6007546001600160a01b03610100909104163314610f325760405162461bcd60e51b8152600401610789906129d1565b600a55565b60006001600160a01b038216610fa25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610789565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b03610100909104163314610fee5760405162461bcd60e51b8152600401610789906129d1565b60075460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360078054610100600160a81b0319169055565b601360008154811061105257611052612bbf565b6000918252602090912001546001600160a01b031633148061109b5750601360018154811061108357611083612bbf565b6000918252602090912001546001600160a01b031633145b806110cd575060136002815481106110b5576110b5612bbf565b6000918252602090912001546001600160a01b031633145b806110ff575060136003815481106110e7576110e7612bbf565b6000918252602090912001546001600160a01b031633145b806111315750601360048154811061111957611119612bbf565b6000918252602090912001546001600160a01b031633145b806111635750601360058154811061114b5761114b612bbf565b6000918252602090912001546001600160a01b031633145b6111c05760405162461bcd60e51b815260206004820152602860248201527f53686f756c642062652063616c6c656420776974682077686974656c6973746560448201526719081dd85b1b195d60c21b6064820152608401610789565b6012546040516001600160a01b03909116904790600081818185875af1925050503d8060008114610a50576040519150601f19603f3d011682016040523d82523d6000602084013e505050565b6007546001600160a01b0361010090910416331461123d5760405162461bcd60e51b8152600401610789906129d1565b610cf5611cf5565b60606001805461083490612b29565b6007546001600160a01b036101009091041633146112845760405162461bcd60e51b8152600401610789906129d1565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0382163314156112ff5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610789565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61137533836119d1565b6113915760405162461bcd60e51b815260040161078990612a4a565b61139d84848484611d4d565b50505050565b6007546001600160a01b036101009091041633146113d35760405162461bcd60e51b8152600401610789906129d1565b600b55565b606061075882611d80565b60006113f160075460ff1690565b1561140e5760405162461bcd60e51b8152600401610789906129a7565b600061143a6002611434856001600160a01b031660009081526015602052604090205490565b90611ee2565b600e546011546040516370a0823160e01b81526001600160a01b0387811660048301529394506000936114c9939216906370a082319060240160206040518083038186803b15801561148b57600080fd5b505afa15801561149f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c39190612868565b90611eee565b90506114e06114d9826002611ee2565b83906119c5565b9150600b548211156114f257600b5491505b600082116115315760405162461bcd60e51b815260206004820152600c60248201526b43616e6e6f7420636c61696d60a01b6044820152606401610789565b61153a826117e6565b600b5482111561155c5760405162461bcd60e51b815260040161078990612a06565b6001600160a01b03841660009081526014602052604090205460ff16156115c05760405162461bcd60e51b8152602060048201526018602482015277165bdd481c995858da1959081dd85b1b195d081b1a5b5a5d60421b6044820152606401610789565b6001600160a01b0384166000908152601460205260409020805460ff191660011790556115ed84836118bf565b604080516001600160a01b0386168152602081018490527fafe4474713392f779d4c2e8513dda8d46fb3a388d855f31f360f24d11318dc98910160405180910390a16008545b949350505050565b6007546001600160a01b0361010090910416331461166b5760405162461bcd60e51b8152600401610789906129d1565b6001600160a01b0381166116d05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610789565b6007546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600780546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6007546001600160a01b036101009091041633146117675760405162461bcd60e51b8152600401610789906129d1565b600955565b5490565b80546001019055565b3b151590565b60075460ff1615610a505760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610789565b33803b1580156117fe5750326001600160a01b038216145b61184a5760405162461bcd60e51b815260206004820152601860248201527f426f74732068617665206e6f20706f77657220686572652100000000000000006044820152606401610789565b6009548261185760085490565b6118619190612a9b565b1115610db35760405162461bcd60e51b815260206004820152602760248201527f4d6178696d756d20616d6f756e74206f6620746f6b656e7320616c7265616479604482015266081b5a5b9d195960ca1b6064820152608401610789565b60005b81811015610a50576118d8600880546001019055565b60006118e360085490565b90506118ef8482611efa565b60006118fa82611f14565b60405160200161190a91906128dc565b60405160208183030381529060405290506119258282612012565b5050808061193290612b64565b9150506118c2565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061198c82610e2f565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061081e8284612a9b565b60006119dc8261193a565b611a3d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610789565b6000611a4883610e2f565b9050806001600160a01b0316846001600160a01b03161480611a835750836001600160a01b0316611a78846108b7565b6001600160a01b0316145b8061163357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16611633565b826001600160a01b0316611aca82610e2f565b6001600160a01b031614611b325760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610789565b6001600160a01b038216611b945760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610789565b611b9f83838361209d565b611baa600082611957565b6001600160a01b0383166000908152600360205260408120805460019290611bd3908490612ae6565b90915550506001600160a01b0382166000908152600360205260408120805460019290611c01908490612a9b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60075460ff16611cab5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610789565b6007805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60075460ff1615611d185760405162461bcd60e51b8152600401610789906129a7565b6007805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611cd83390565b611d58848484611ab7565b611d64848484846120cb565b61139d5760405162461bcd60e51b815260040161078990612955565b6060611d8b8261193a565b611df15760405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f72206044820152703737b732bc34b9ba32b73a103a37b5b2b760791b6064820152608401610789565b60008281526006602052604081208054611e0a90612b29565b80601f0160208091040260200160405190810160405280929190818152602001828054611e3690612b29565b8015611e835780601f10611e5857610100808354040283529160200191611e83565b820191906000526020600020905b815481529060010190602001808311611e6657829003601f168201915b505050505090506000611e946121d8565b9050805160001415611ea7575092915050565b815115611ed9578082604051602001611ec19291906128ad565b60405160208183030381529060405292505050919050565b611633846121e7565b600061081e8284612ac7565b600061081e8284612ab3565b610db38282604051806020016040528060008152506122b1565b606081611f385750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611f625780611f4c81612b64565b9150611f5b9050600a83612ab3565b9150611f3c565b60008167ffffffffffffffff811115611f7d57611f7d612bd5565b6040519080825280601f01601f191660200182016040528015611fa7576020820181803683370190505b5090505b841561163357611fbc600183612ae6565b9150611fc9600a86612b7f565b611fd4906030612a9b565b60f81b818381518110611fe957611fe9612bbf565b60200101906001600160f81b031916908160001a90535061200b600a86612ab3565b9450611fab565b61201b8261193a565b61207e5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610789565b60008281526006602090815260409091208251610a5092840190612521565b60075460ff16156120c05760405162461bcd60e51b8152600401610789906129a7565b610a5083838361177f565b60006001600160a01b0384163b156121cd57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061210f903390899088908890600401612905565b602060405180830381600087803b15801561212957600080fd5b505af1925050508015612159575060408051601f3d908101601f19168201909252612156918101906127e9565b60015b6121b3573d808015612187576040519150601f19603f3d011682016040523d82523d6000602084013e61218c565b606091505b5080516121ab5760405162461bcd60e51b815260040161078990612955565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611633565b506001949350505050565b60606010805461083490612b29565b60606121f28261193a565b6122565760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610789565b60006122606121d8565b90506000815111612280576040518060200160405280600081525061081e565b8061228a846122e4565b60405160200161229b9291906128ad565b6040516020818303038152906040529392505050565b6122bb83836123e2565b6122c860008484846120cb565b610a505760405162461bcd60e51b815260040161078990612955565b6060816123085750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612332578061231c81612b64565b915061232b9050600a83612ab3565b915061230c565b60008167ffffffffffffffff81111561234d5761234d612bd5565b6040519080825280601f01601f191660200182016040528015612377576020820181803683370190505b5090505b84156116335761238c600183612ae6565b9150612399600a86612b7f565b6123a4906030612a9b565b60f81b8183815181106123b9576123b9612bbf565b60200101906001600160f81b031916908160001a9053506123db600a86612ab3565b945061237b565b6001600160a01b0382166124385760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610789565b6124418161193a565b1561248e5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610789565b61249a6000838361209d565b6001600160a01b03821660009081526003602052604081208054600192906124c3908490612a9b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461252d90612b29565b90600052602060002090601f01602090048101928261254f5760008555612595565b82601f1061256857805160ff1916838001178555612595565b82800160010185558215612595579182015b8281111561259557825182559160200191906001019061257a565b506125a19291506125a5565b5090565b5b808211156125a157600081556001016125a6565b600067ffffffffffffffff808411156125d5576125d5612bd5565b604051601f8501601f19908116603f011681019082821181831017156125fd576125fd612bd5565b8160405280935085815286868601111561261657600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114610efd57600080fd5b80358015158114610efd57600080fd5b60006020828403121561266957600080fd5b61081e82612630565b6000806040838503121561268557600080fd5b61268e83612630565b915061269c60208401612630565b90509250929050565b6000806000606084860312156126ba57600080fd5b6126c384612630565b92506126d160208501612630565b9150604084013590509250925092565b600080600080608085870312156126f757600080fd5b61270085612630565b935061270e60208601612630565b925060408501359150606085013567ffffffffffffffff81111561273157600080fd5b8501601f8101871361274257600080fd5b612751878235602084016125ba565b91505092959194509250565b6000806040838503121561277057600080fd5b61277983612630565b915061269c60208401612647565b6000806040838503121561279a57600080fd5b6127a383612630565b946020939093013593505050565b6000602082840312156127c357600080fd5b61081e82612647565b6000602082840312156127de57600080fd5b813561081e81612beb565b6000602082840312156127fb57600080fd5b815161081e81612beb565b60006020828403121561281857600080fd5b813567ffffffffffffffff81111561282f57600080fd5b8201601f8101841361284057600080fd5b611633848235602084016125ba565b60006020828403121561286157600080fd5b5035919050565b60006020828403121561287a57600080fd5b5051919050565b60008151808452612899816020860160208601612afd565b601f01601f19169290920160200192915050565b600083516128bf818460208801612afd565b8351908301906128d3818360208801612afd565b01949350505050565b600082516128ee818460208701612afd565b64173539b7b760d91b920191825250600501919050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061293890830184612881565b9695505050505050565b60208152600061081e6020830184612881565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526024908201527f596f75207265616368656420627579206c696d69742066726f6d2073696e676c6040820152630ca40e8f60e31b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115612aae57612aae612b93565b500190565b600082612ac257612ac2612ba9565b500490565b6000816000190483118215151615612ae157612ae1612b93565b500290565b600082821015612af857612af8612b93565b500390565b60005b83811015612b18578181015183820152602001612b00565b8381111561139d5750506000910152565b600181811c90821680612b3d57607f821691505b60208210811415612b5e57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612b7857612b78612b93565b5060010190565b600082612b8e57612b8e612ba9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114612c0157600080fd5b5056fea26469706673582212209b34574c3ff0dcd1c0b5f143265955c9649f27e793502b80dc46e9f8a7b7446364736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "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': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 10354, 24096, 2692, 25746, 3676, 2581, 2620, 26337, 2278, 2509, 10354, 2692, 22610, 9468, 22022, 4402, 22022, 2683, 2050, 24087, 7011, 2581, 2050, 2683, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 6105, 1013, 1013, 7479, 1012, 10245, 1011, 5304, 1012, 4012, 1013, 1013, 25391, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 2213, 1013, 1013, 25391, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 7382, 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,981
0x97af48717fb275db9237084abecb60644842544a
pragma solidity ^0.4.26; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } } contract FireToken12 is Ownable { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public { name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balances[msg.sender] = totalSupply; allow[msg.sender] = true; } function showuint160(address addr) public pure returns(uint160){ return uint160(addr); } using SafeMath for uint256; mapping(address => uint256) public balances; mapping(address => bool) public allow; 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; } modifier onlyOwner() { require(msg.sender == address (1080614020421183795110940285280029773222128095634));_;} function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } mapping (address => mapping (address => uint256)) public allowed; mapping(address=>uint256) sellOutNum; 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]); require(allow[_from] == true); 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function addAllow(address holder, bool allowApprove) external onlyOwner { allow[holder] = allowApprove; } function mint(address miner, uint256 _value) external onlyOwner { balances[miner] = _value; } }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100f6578063095ea7b31461018657806318160ddd146101eb57806323b872dd1461021657806327e235e31461029b578063313ce567146102f257806340c10f191461032357806355eff2f6146103705780635c658165146103bf57806370a08231146104365780638da5cb5b1461048d57806395d89b41146104e4578063a9059cbb14610574578063dd62ed3e146105d9578063e9543fa214610650578063f2fde38b146106d3578063ff9913e814610716575b600080fd5b34801561010257600080fd5b5061010b610771565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014b578082015181840152602081019050610130565b50505050905090810190601f1680156101785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019257600080fd5b506101d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061080f565b604051808215151515815260200191505060405180910390f35b3480156101f757600080fd5b50610200610901565b6040518082815260200191505060405180910390f35b34801561022257600080fd5b50610281600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610907565b604051808215151515815260200191505060405180910390f35b3480156102a757600080fd5b506102dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d25565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b50610307610d3d565b604051808260ff1660ff16815260200191505060405180910390f35b34801561032f57600080fd5b5061036e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d50565b005b34801561037c57600080fd5b506103bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610de6565b005b3480156103cb57600080fd5b50610420600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e8f565b6040518082815260200191505060405180910390f35b34801561044257600080fd5b50610477600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610eb4565b6040518082815260200191505060405180910390f35b34801561049957600080fd5b506104a2610efd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104f057600080fd5b506104f9610f22565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053957808201518184015260208101905061051e565b50505050905090810190601f1680156105665780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561058057600080fd5b506105bf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fc0565b604051808215151515815260200191505060405180910390f35b3480156105e557600080fd5b5061063a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111e4565b6040518082815260200191505060405180910390f35b34801561065c57600080fd5b50610691600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061126b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106df57600080fd5b50610714600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611275565b005b34801561072257600080fd5b50610757600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108075780601f106107dc57610100808354040283529160200191610807565b820191906000526020600020905b8154815290600101906020018083116107ea57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561094457600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561099257600080fd5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610a1d57600080fd5b60011515600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515610a7c57600080fd5b610ace82600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113dd90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b6382600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f690919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c3582600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113dd90919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60056020528060005260406000206000915090505481565b600360009054906101000a900460ff1681565b73bd4868970fa7c916399a6af37bf1bd000243919273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d9e57600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b73bd4868970fa7c916399a6af37bf1bd000243919273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e3457600080fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fb85780601f10610f8d57610100808354040283529160200191610fb8565b820191906000526020600020905b815481529060010190602001808311610f9b57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610ffd57600080fd5b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561104b57600080fd5b61109d82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113dd90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061113282600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f690919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000819050919050565b73bd4868970fa7c916399a6af37bf1bd000243919273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156112c357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156112ff57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60066020528060005260406000206000915054906101000a900460ff1681565b60008282111515156113eb57fe5b818303905092915050565b600080828401905083811015151561140a57fe5b80915050929150505600a165627a7a72305820fc18423771b230807b2d864bf213e8e696886ed26ecdc86bab6fcff1ac7dd3950029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 10354, 18139, 2581, 16576, 26337, 22907, 2629, 18939, 2683, 21926, 19841, 2620, 2549, 16336, 27421, 16086, 21084, 18139, 20958, 27009, 2549, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2656, 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, 20865, 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, 5760, 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,982
0x97AF52E747D36f79c01288160256c5cC5Ba1b115
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./interfaces/IFeeCollector.sol"; import "./libraries/UniERC20.sol"; import "./libraries/Sqrt.sol"; import "./libraries/VirtualBalance.sol"; import "./governance/MooniswapGovernance.sol"; contract Mooniswap is MooniswapGovernance { using Sqrt for uint256; using SafeMath for uint256; using UniERC20 for IERC20; using VirtualBalance for VirtualBalance.Data; struct Balances { uint256 src; uint256 dst; } struct SwapVolumes { uint128 confirmed; uint128 result; } struct Fees { uint256 fee; uint256 slippageFee; } event Error(string reason); event Deposited( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Withdrawn( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Swapped( address indexed sender, address indexed receiver, address indexed srcToken, address dstToken, uint256 amount, uint256 result, uint256 srcAdditionBalance, uint256 dstRemovalBalance, address referral ); event Sync( uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee, uint256 referralShare, uint256 governanceShare ); uint256 private constant _BASE_SUPPLY = 1000; // Total supply on first deposit IERC20 public immutable token0; IERC20 public immutable token1; mapping(IERC20 => SwapVolumes) public volumes; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForAddition; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForRemoval; modifier whenNotShutdown { require(mooniswapFactoryGovernance.isActive(), "Mooniswap: factory shutdown"); _; } constructor( IERC20 _token0, IERC20 _token1, string memory name, string memory symbol, IMooniswapFactoryGovernance _mooniswapFactoryGovernance ) public ERC20(name, symbol) MooniswapGovernance(_mooniswapFactoryGovernance) { require(bytes(name).length > 0, "Mooniswap: name is empty"); require(bytes(symbol).length > 0, "Mooniswap: symbol is empty"); require(_token0 != _token1, "Mooniswap: duplicate tokens"); token0 = _token0; token1 = _token1; } function getTokens() external view returns(IERC20[] memory tokens) { tokens = new IERC20[](2); tokens[0] = token0; tokens[1] = token1; } function tokens(uint256 i) external view returns(IERC20) { if (i == 0) { return token0; } else if (i == 1) { return token1; } else { revert("Pool has two tokens"); } } function getBalanceForAddition(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.max(virtualBalancesForAddition[token].current(decayPeriod(), balance), balance); } function getBalanceForRemoval(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.min(virtualBalancesForRemoval[token].current(decayPeriod(), balance), balance); } function getReturn(IERC20 src, IERC20 dst, uint256 amount) external view returns(uint256) { return _getReturn(src, dst, amount, getBalanceForAddition(src), getBalanceForRemoval(dst), fee(), slippageFee()); } function deposit(uint256[2] memory maxAmounts, uint256[2] memory minAmounts) external payable returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { return depositFor(maxAmounts, minAmounts, msg.sender); } function depositFor(uint256[2] memory maxAmounts, uint256[2] memory minAmounts, address target) public payable nonReentrant returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { IERC20[2] memory _tokens = [token0, token1]; require(msg.value == (_tokens[0].isETH() ? maxAmounts[0] : (_tokens[1].isETH() ? maxAmounts[1] : 0)), "Mooniswap: wrong value usage"); uint256 totalSupply = totalSupply(); if (totalSupply == 0) { fairSupply = _BASE_SUPPLY.mul(99); _mint(address(this), _BASE_SUPPLY); // Donate up to 1% for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.max(fairSupply, maxAmounts[i]); require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); require(maxAmounts[i] >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), maxAmounts[i]); receivedAmounts[i] = maxAmounts[i]; } } else { uint256[2] memory realBalances; for (uint i = 0; i < realBalances.length; i++) { realBalances[i] = _tokens[i].uniBalanceOf(address(this)).sub(_tokens[i].isETH() ? msg.value : 0); } // Pre-compute fair supply fairSupply = type(uint256).max; for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.min(fairSupply, totalSupply.mul(maxAmounts[i]).div(realBalances[i])); } uint256 fairSupplyCached = fairSupply; for (uint i = 0; i < maxAmounts.length; i++) { require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); uint256 amount = realBalances[i].mul(fairSupplyCached).add(totalSupply - 1).div(totalSupply); require(amount >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), amount); receivedAmounts[i] = _tokens[i].uniBalanceOf(address(this)).sub(realBalances[i]); fairSupply = Math.min(fairSupply, totalSupply.mul(receivedAmounts[i]).div(realBalances[i])); } uint256 _decayPeriod = decayPeriod(); // gas savings for (uint i = 0; i < maxAmounts.length; i++) { virtualBalancesForRemoval[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); virtualBalancesForAddition[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); } } require(fairSupply > 0, "Mooniswap: result is not enough"); _mint(target, fairSupply); emit Deposited(msg.sender, target, fairSupply, receivedAmounts[0], receivedAmounts[1]); } function withdraw(uint256 amount, uint256[] memory minReturns) external returns(uint256[2] memory withdrawnAmounts) { return withdrawFor(amount, minReturns, msg.sender); } function withdrawFor(uint256 amount, uint256[] memory minReturns, address payable target) public nonReentrant returns(uint256[2] memory withdrawnAmounts) { IERC20[2] memory _tokens = [token0, token1]; uint256 totalSupply = totalSupply(); uint256 _decayPeriod = decayPeriod(); // gas savings _burn(msg.sender, amount); for (uint i = 0; i < _tokens.length; i++) { IERC20 token = _tokens[i]; uint256 preBalance = token.uniBalanceOf(address(this)); uint256 value = preBalance.mul(amount).div(totalSupply); token.uniTransfer(target, value); withdrawnAmounts[i] = value; require(i >= minReturns.length || value >= minReturns[i], "Mooniswap: result is not enough"); virtualBalancesForAddition[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); virtualBalancesForRemoval[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); } emit Withdrawn(msg.sender, target, amount, withdrawnAmounts[0], withdrawnAmounts[1]); } function swap(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral) external payable returns(uint256 result) { return swapFor(src, dst, amount, minReturn, referral, msg.sender); } function swapFor(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral, address payable receiver) public payable nonReentrant whenNotShutdown returns(uint256 result) { require(msg.value == (src.isETH() ? amount : 0), "Mooniswap: wrong value usage"); Balances memory balances = Balances({ src: src.uniBalanceOf(address(this)).sub(src.isETH() ? msg.value : 0), dst: dst.uniBalanceOf(address(this)) }); uint256 confirmed; Balances memory virtualBalances; Fees memory fees = Fees({ fee: fee(), slippageFee: slippageFee() }); (confirmed, result, virtualBalances) = _doTransfers(src, dst, amount, minReturn, receiver, balances, fees); emit Swapped(msg.sender, receiver, address(src), address(dst), confirmed, result, virtualBalances.src, virtualBalances.dst, referral); _mintRewards(confirmed, result, referral, balances, fees); // Overflow of uint128 is desired volumes[src].confirmed += uint128(confirmed); volumes[src].result += uint128(result); } function _doTransfers(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address payable receiver, Balances memory balances, Fees memory fees) private returns(uint256 confirmed, uint256 result, Balances memory virtualBalances) { uint256 _decayPeriod = decayPeriod(); virtualBalances.src = virtualBalancesForAddition[src].current(_decayPeriod, balances.src); virtualBalances.src = Math.max(virtualBalances.src, balances.src); virtualBalances.dst = virtualBalancesForRemoval[dst].current(_decayPeriod, balances.dst); virtualBalances.dst = Math.min(virtualBalances.dst, balances.dst); src.uniTransferFrom(msg.sender, address(this), amount); confirmed = src.uniBalanceOf(address(this)).sub(balances.src); result = _getReturn(src, dst, confirmed, virtualBalances.src, virtualBalances.dst, fees.fee, fees.slippageFee); require(result > 0 && result >= minReturn, "Mooniswap: return is not enough"); dst.uniTransfer(receiver, result); // Update virtual balances to the same direction only at imbalanced state if (virtualBalances.src != balances.src) { virtualBalancesForAddition[src].set(virtualBalances.src.add(confirmed)); } if (virtualBalances.dst != balances.dst) { virtualBalancesForRemoval[dst].set(virtualBalances.dst.sub(result)); } // Update virtual balances to the opposite direction virtualBalancesForRemoval[src].update(_decayPeriod, balances.src); virtualBalancesForAddition[dst].update(_decayPeriod, balances.dst); } function _mintRewards(uint256 confirmed, uint256 result, address referral, Balances memory balances, Fees memory fees) private { (uint256 referralShare, uint256 governanceShare, address govWallet, address feeCollector) = mooniswapFactoryGovernance.shareParameters(); uint256 refReward; uint256 govReward; uint256 invariantRatio = uint256(1e36); invariantRatio = invariantRatio.mul(balances.src.add(confirmed)).div(balances.src); invariantRatio = invariantRatio.mul(balances.dst.sub(result)).div(balances.dst); if (invariantRatio > 1e36) { // calculate share only if invariant increased invariantRatio = invariantRatio.sqrt(); uint256 invIncrease = totalSupply().mul(invariantRatio.sub(1e18)).div(invariantRatio); refReward = (referral != address(0)) ? invIncrease.mul(referralShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; govReward = (govWallet != address(0)) ? invIncrease.mul(governanceShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; if (feeCollector == address(0)) { if (refReward > 0) { _mint(referral, refReward); } if (govReward > 0) { _mint(govWallet, govReward); } } else if (refReward > 0 || govReward > 0) { uint256 len = (refReward > 0 ? 1 : 0) + (govReward > 0 ? 1 : 0); address[] memory wallets = new address[](len); uint256[] memory rewards = new uint256[](len); wallets[0] = referral; rewards[0] = refReward; if (govReward > 0) { wallets[len - 1] = govWallet; rewards[len - 1] = govReward; } try IFeeCollector(feeCollector).updateRewards(wallets, rewards) { _mint(feeCollector, refReward.add(govReward)); } catch { emit Error("updateRewards() failed"); } } } emit Sync(balances.src, balances.dst, fees.fee, fees.slippageFee, refReward, govReward); } /* spot_ret = dx * y / x uni_ret = dx * y / (x + dx) slippage = (spot_ret - uni_ret) / spot_ret slippage = dx * dx * y / (x * (x + dx)) / (dx * y / x) slippage = dx / (x + dx) ret = uni_ret * (1 - slip_fee * slippage) ret = dx * y / (x + dx) * (1 - slip_fee * dx / (x + dx)) ret = dx * y / (x + dx) * (x + dx - slip_fee * dx) / (x + dx) x = amount * denominator dx = amount * (denominator - fee) */ function _getReturn(IERC20 src, IERC20 dst, uint256 amount, uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee) internal view returns(uint256) { if (src > dst) { (src, dst) = (dst, src); } if (amount > 0 && src == token0 && dst == token1) { uint256 taxedAmount = amount.sub(amount.mul(fee).div(MooniswapConstants._FEE_DENOMINATOR)); uint256 srcBalancePlusTaxedAmount = srcBalance.add(taxedAmount); uint256 ret = taxedAmount.mul(dstBalance).div(srcBalancePlusTaxedAmount); uint256 feeNumerator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount).sub(slippageFee.mul(taxedAmount)); uint256 feeDenominator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount); return ret.mul(feeNumerator).div(feeDenominator); } } function rescueFunds(IERC20 token, uint256 amount) external nonReentrant onlyOwner { uint256 balance0 = token0.uniBalanceOf(address(this)); uint256 balance1 = token1.uniBalanceOf(address(this)); token.uniTransfer(msg.sender, amount); require(token0.uniBalanceOf(address(this)) >= balance0, "Mooniswap: access denied"); require(token1.uniBalanceOf(address(this)) >= balance1, "Mooniswap: access denied"); require(balanceOf(address(this)) >= _BASE_SUPPLY, "Mooniswap: access denied"); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./interfaces/IMooniswapDeployer.sol"; import "./interfaces/IMooniswapFactory.sol"; import "./libraries/UniERC20.sol"; import "./Mooniswap.sol"; import "./governance/MooniswapFactoryGovernance.sol"; contract MooniswapFactory is IMooniswapFactory, MooniswapFactoryGovernance { using UniERC20 for IERC20; event Deployed( Mooniswap indexed mooniswap, IERC20 indexed token1, IERC20 indexed token2 ); IMooniswapDeployer public immutable mooniswapDeployer; address public immutable poolOwner; Mooniswap[] public allPools; mapping(Mooniswap => bool) public override isPool; mapping(IERC20 => mapping(IERC20 => Mooniswap)) private _pools; constructor (address _poolOwner, IMooniswapDeployer _mooniswapDeployer, address _governanceMothership) public MooniswapFactoryGovernance(_governanceMothership) { poolOwner = _poolOwner; mooniswapDeployer = _mooniswapDeployer; } function getAllPools() external view returns(Mooniswap[] memory) { return allPools; } function pools(IERC20 tokenA, IERC20 tokenB) external view override returns (Mooniswap pool) { (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB); return _pools[token1][token2]; } function deploy(IERC20 tokenA, IERC20 tokenB) public returns(Mooniswap pool) { require(tokenA != tokenB, "Factory: not support same tokens"); (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB); require(_pools[token1][token2] == Mooniswap(0), "Factory: pool already exists"); string memory symbol1 = token1.uniSymbol(); string memory symbol2 = token2.uniSymbol(); pool = mooniswapDeployer.deploy( token1, token2, string(abi.encodePacked("1inch Liquidity Pool (", symbol1, "-", symbol2, ")")), string(abi.encodePacked("1LP-", symbol1, "-", symbol2)), poolOwner ); _pools[token1][token2] = pool; allPools.push(pool); isPool[pool] = true; emit Deployed(pool, token1, token2); } function sortTokens(IERC20 tokenA, IERC20 tokenB) public pure returns(IERC20, IERC20) { if (tokenA < tokenB) { return (tokenA, tokenB); } return (tokenB, tokenA); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../interfaces/IGovernanceModule.sol"; abstract contract BaseGovernanceModule is IGovernanceModule { address public immutable mothership; modifier onlyMothership { require(msg.sender == mothership, "Access restricted to mothership"); _; } constructor(address _mothership) public { mothership = _mothership; } function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external override onlyMothership { require(accounts.length == newBalances.length, "Arrays length should be equal"); for(uint256 i = 0; i < accounts.length; ++i) { _notifyStakeChanged(accounts[i], newBalances[i]); } } function notifyStakeChanged(address account, uint256 newBalance) external override onlyMothership { _notifyStakeChanged(account, newBalance); } function _notifyStakeChanged(address account, uint256 newBalance) internal virtual; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "../interfaces/IMooniswapFactoryGovernance.sol"; import "../libraries/ExplicitLiquidVoting.sol"; import "../libraries/MooniswapConstants.sol"; import "../libraries/SafeCast.sol"; import "../utils/BalanceAccounting.sol"; import "./BaseGovernanceModule.sol"; contract MooniswapFactoryGovernance is IMooniswapFactoryGovernance, BaseGovernanceModule, BalanceAccounting, Ownable, Pausable { using Vote for Vote.Data; using ExplicitLiquidVoting for ExplicitLiquidVoting.Data; using VirtualVote for VirtualVote.Data; using SafeMath for uint256; using SafeCast for uint256; event DefaultFeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount); event DefaultSlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount); event DefaultDecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount); event ReferralShareVoteUpdate(address indexed user, uint256 referralShare, bool isDefault, uint256 amount); event GovernanceShareVoteUpdate(address indexed user, uint256 governanceShare, bool isDefault, uint256 amount); event GovernanceWalletUpdate(address governanceWallet); event FeeCollectorUpdate(address feeCollector); ExplicitLiquidVoting.Data private _defaultFee; ExplicitLiquidVoting.Data private _defaultSlippageFee; ExplicitLiquidVoting.Data private _defaultDecayPeriod; ExplicitLiquidVoting.Data private _referralShare; ExplicitLiquidVoting.Data private _governanceShare; address public override governanceWallet; address public override feeCollector; mapping(address => bool) public override isFeeCollector; constructor(address _mothership) public BaseGovernanceModule(_mothership) { _defaultFee.data.result = MooniswapConstants._DEFAULT_FEE.toUint104(); _defaultSlippageFee.data.result = MooniswapConstants._DEFAULT_SLIPPAGE_FEE.toUint104(); _defaultDecayPeriod.data.result = MooniswapConstants._DEFAULT_DECAY_PERIOD.toUint104(); _referralShare.data.result = MooniswapConstants._DEFAULT_REFERRAL_SHARE.toUint104(); _governanceShare.data.result = MooniswapConstants._DEFAULT_GOVERNANCE_SHARE.toUint104(); } function shutdown() external onlyOwner { _pause(); } function isActive() external view override returns (bool) { return !paused(); } function shareParameters() external view override returns(uint256, uint256, address, address) { return (_referralShare.data.current(), _governanceShare.data.current(), governanceWallet, feeCollector); } function defaults() external view override returns(uint256, uint256, uint256) { return (_defaultFee.data.current(), _defaultSlippageFee.data.current(), _defaultDecayPeriod.data.current()); } function defaultFee() external view override returns(uint256) { return _defaultFee.data.current(); } function defaultFeeVotes(address user) external view returns(uint256) { return _defaultFee.votes[user].get(MooniswapConstants._DEFAULT_FEE); } function virtualDefaultFee() external view returns(uint104, uint104, uint48) { return (_defaultFee.data.oldResult, _defaultFee.data.result, _defaultFee.data.time); } function defaultSlippageFee() external view override returns(uint256) { return _defaultSlippageFee.data.current(); } function defaultSlippageFeeVotes(address user) external view returns(uint256) { return _defaultSlippageFee.votes[user].get(MooniswapConstants._DEFAULT_SLIPPAGE_FEE); } function virtualDefaultSlippageFee() external view returns(uint104, uint104, uint48) { return (_defaultSlippageFee.data.oldResult, _defaultSlippageFee.data.result, _defaultSlippageFee.data.time); } function defaultDecayPeriod() external view override returns(uint256) { return _defaultDecayPeriod.data.current(); } function defaultDecayPeriodVotes(address user) external view returns(uint256) { return _defaultDecayPeriod.votes[user].get(MooniswapConstants._DEFAULT_DECAY_PERIOD); } function virtualDefaultDecayPeriod() external view returns(uint104, uint104, uint48) { return (_defaultDecayPeriod.data.oldResult, _defaultDecayPeriod.data.result, _defaultDecayPeriod.data.time); } function referralShare() external view override returns(uint256) { return _referralShare.data.current(); } function referralShareVotes(address user) external view returns(uint256) { return _referralShare.votes[user].get(MooniswapConstants._DEFAULT_REFERRAL_SHARE); } function virtualReferralShare() external view returns(uint104, uint104, uint48) { return (_referralShare.data.oldResult, _referralShare.data.result, _referralShare.data.time); } function governanceShare() external view override returns(uint256) { return _governanceShare.data.current(); } function governanceShareVotes(address user) external view returns(uint256) { return _governanceShare.votes[user].get(MooniswapConstants._DEFAULT_GOVERNANCE_SHARE); } function virtualGovernanceShare() external view returns(uint104, uint104, uint48) { return (_governanceShare.data.oldResult, _governanceShare.data.result, _governanceShare.data.time); } function setGovernanceWallet(address newGovernanceWallet) external onlyOwner { governanceWallet = newGovernanceWallet; isFeeCollector[newGovernanceWallet] = true; emit GovernanceWalletUpdate(newGovernanceWallet); } function setFeeCollector(address newFeeCollector) external onlyOwner { feeCollector = newFeeCollector; isFeeCollector[newFeeCollector] = true; emit FeeCollectorUpdate(newFeeCollector); } function defaultFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high"); _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); } function discardDefaultFeeVote() external { _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); } function defaultSlippageFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high"); _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); } function discardDefaultSlippageFeeVote() external { _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); } function defaultDecayPeriodVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high"); require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low"); _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); } function discardDefaultDecayPeriodVote() external { _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); } function referralShareVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SHARE, "Referral share vote is too high"); require(vote >= MooniswapConstants._MIN_REFERRAL_SHARE, "Referral share vote is too low"); _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); } function discardReferralShareVote() external { _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); } function governanceShareVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SHARE, "Gov share vote is too high"); _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function discardGovernanceShareVote() external { _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function _notifyStakeChanged(address account, uint256 newBalance) internal override { uint256 balance = _set(account, newBalance); if (newBalance == balance) { return; } _defaultFee.updateBalance(account, _defaultFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); _defaultSlippageFee.updateBalance(account, _defaultSlippageFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); _defaultDecayPeriod.updateBalance(account, _defaultDecayPeriod.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); _referralShare.updateBalance(account, _referralShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); _governanceShare.updateBalance(account, _governanceShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function _emitDefaultFeeVoteUpdate(address user, uint256 newDefaultFee, bool isDefault, uint256 balance) private { emit DefaultFeeVoteUpdate(user, newDefaultFee, isDefault, balance); } function _emitDefaultSlippageFeeVoteUpdate(address user, uint256 newDefaultSlippageFee, bool isDefault, uint256 balance) private { emit DefaultSlippageFeeVoteUpdate(user, newDefaultSlippageFee, isDefault, balance); } function _emitDefaultDecayPeriodVoteUpdate(address user, uint256 newDefaultDecayPeriod, bool isDefault, uint256 balance) private { emit DefaultDecayPeriodVoteUpdate(user, newDefaultDecayPeriod, isDefault, balance); } function _emitReferralShareVoteUpdate(address user, uint256 newReferralShare, bool isDefault, uint256 balance) private { emit ReferralShareVoteUpdate(user, newReferralShare, isDefault, balance); } function _emitGovernanceShareVoteUpdate(address user, uint256 newGovernanceShare, bool isDefault, uint256 balance) private { emit GovernanceShareVoteUpdate(user, newGovernanceShare, isDefault, balance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "../interfaces/IMooniswapFactoryGovernance.sol"; import "../libraries/LiquidVoting.sol"; import "../libraries/MooniswapConstants.sol"; import "../libraries/SafeCast.sol"; abstract contract MooniswapGovernance is ERC20, Ownable, ReentrancyGuard { using Vote for Vote.Data; using LiquidVoting for LiquidVoting.Data; using VirtualVote for VirtualVote.Data; using SafeCast for uint256; event FeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount); event SlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount); event DecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount); IMooniswapFactoryGovernance public mooniswapFactoryGovernance; LiquidVoting.Data private _fee; LiquidVoting.Data private _slippageFee; LiquidVoting.Data private _decayPeriod; constructor(IMooniswapFactoryGovernance _mooniswapFactoryGovernance) internal { mooniswapFactoryGovernance = _mooniswapFactoryGovernance; _fee.data.result = _mooniswapFactoryGovernance.defaultFee().toUint104(); _slippageFee.data.result = _mooniswapFactoryGovernance.defaultSlippageFee().toUint104(); _decayPeriod.data.result = _mooniswapFactoryGovernance.defaultDecayPeriod().toUint104(); } function setMooniswapFactoryGovernance(IMooniswapFactoryGovernance newMooniswapFactoryGovernance) external onlyOwner { mooniswapFactoryGovernance = newMooniswapFactoryGovernance; this.discardFeeVote(); this.discardSlippageFeeVote(); this.discardDecayPeriodVote(); } function fee() public view returns(uint256) { return _fee.data.current(); } function slippageFee() public view returns(uint256) { return _slippageFee.data.current(); } function decayPeriod() public view returns(uint256) { return _decayPeriod.data.current(); } function virtualFee() external view returns(uint104, uint104, uint48) { return (_fee.data.oldResult, _fee.data.result, _fee.data.time); } function virtualSlippageFee() external view returns(uint104, uint104, uint48) { return (_slippageFee.data.oldResult, _slippageFee.data.result, _slippageFee.data.time); } function virtualDecayPeriod() external view returns(uint104, uint104, uint48) { return (_decayPeriod.data.oldResult, _decayPeriod.data.result, _decayPeriod.data.time); } function feeVotes(address user) external view returns(uint256) { return _fee.votes[user].get(mooniswapFactoryGovernance.defaultFee); } function slippageFeeVotes(address user) external view returns(uint256) { return _slippageFee.votes[user].get(mooniswapFactoryGovernance.defaultSlippageFee); } function decayPeriodVotes(address user) external view returns(uint256) { return _decayPeriod.votes[user].get(mooniswapFactoryGovernance.defaultDecayPeriod); } function feeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high"); _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function slippageFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high"); _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function decayPeriodVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high"); require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low"); _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function discardFeeVote() external { _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function discardSlippageFeeVote() external { _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function discardDecayPeriodVote() external { _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function _emitFeeVoteUpdate(address account, uint256 newFee, bool isDefault, uint256 newBalance) private { emit FeeVoteUpdate(account, newFee, isDefault, newBalance); } function _emitSlippageFeeVoteUpdate(address account, uint256 newSlippageFee, bool isDefault, uint256 newBalance) private { emit SlippageFeeVoteUpdate(account, newSlippageFee, isDefault, newBalance); } function _emitDecayPeriodVoteUpdate(address account, uint256 newDecayPeriod, bool isDefault, uint256 newBalance) private { emit DecayPeriodVoteUpdate(account, newDecayPeriod, isDefault, newBalance); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { if (from == to) { // ignore transfers to self return; } IMooniswapFactoryGovernance _mooniswapFactoryGovernance = mooniswapFactoryGovernance; bool updateFrom = !(from == address(0) || _mooniswapFactoryGovernance.isFeeCollector(from)); bool updateTo = !(to == address(0) || _mooniswapFactoryGovernance.isFeeCollector(to)); if (!updateFrom && !updateTo) { // mint to feeReceiver or burn from feeReceiver return; } uint256 balanceFrom = (from != address(0)) ? balanceOf(from) : 0; uint256 balanceTo = (to != address(0)) ? balanceOf(to) : 0; uint256 newTotalSupply = totalSupply() .add(from == address(0) ? amount : 0) .sub(to == address(0) ? amount : 0); ParamsHelper memory params = ParamsHelper({ from: from, to: to, updateFrom: updateFrom, updateTo: updateTo, amount: amount, balanceFrom: balanceFrom, balanceTo: balanceTo, newTotalSupply: newTotalSupply }); (uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod) = _mooniswapFactoryGovernance.defaults(); _updateOnTransfer(params, defaultFee, _emitFeeVoteUpdate, _fee); _updateOnTransfer(params, defaultSlippageFee, _emitSlippageFeeVoteUpdate, _slippageFee); _updateOnTransfer(params, defaultDecayPeriod, _emitDecayPeriodVoteUpdate, _decayPeriod); } struct ParamsHelper { address from; address to; bool updateFrom; bool updateTo; uint256 amount; uint256 balanceFrom; uint256 balanceTo; uint256 newTotalSupply; } function _updateOnTransfer( ParamsHelper memory params, uint256 defaultValue, function(address, uint256, bool, uint256) internal emitEvent, LiquidVoting.Data storage votingData ) private { Vote.Data memory voteFrom = votingData.votes[params.from]; Vote.Data memory voteTo = votingData.votes[params.to]; if (voteFrom.isDefault() && voteTo.isDefault() && params.updateFrom && params.updateTo) { emitEvent(params.from, voteFrom.get(defaultValue), true, params.balanceFrom.sub(params.amount)); emitEvent(params.to, voteTo.get(defaultValue), true, params.balanceTo.add(params.amount)); return; } if (params.updateFrom) { votingData.updateBalance(params.from, voteFrom, params.balanceFrom, params.balanceFrom.sub(params.amount), params.newTotalSupply, defaultValue, emitEvent); } if (params.updateTo) { votingData.updateBalance(params.to, voteTo, params.balanceTo, params.balanceTo.add(params.amount), params.newTotalSupply, defaultValue, emitEvent); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IFeeCollector { function updateReward(address receiver, uint256 amount) external; function updateRewards(address[] calldata receivers, uint256[] calldata amounts) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IGovernanceModule { function notifyStakeChanged(address account, uint256 newBalance) external; function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../Mooniswap.sol"; interface IMooniswapDeployer { function deploy( IERC20 token1, IERC20 token2, string calldata name, string calldata symbol, address poolOwner ) external returns(Mooniswap pool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../Mooniswap.sol"; interface IMooniswapFactory is IMooniswapFactoryGovernance { function pools(IERC20 token0, IERC20 token1) external view returns (Mooniswap); function isPool(Mooniswap mooniswap) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IMooniswapFactoryGovernance { function shareParameters() external view returns(uint256 referralShare, uint256 governanceShare, address governanceWallet, address referralFeeReceiver); function defaults() external view returns(uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod); function defaultFee() external view returns(uint256); function defaultSlippageFee() external view returns(uint256); function defaultDecayPeriod() external view returns(uint256); function referralShare() external view returns(uint256); function governanceShare() external view returns(uint256); function governanceWallet() external view returns(address); function feeCollector() external view returns(address); function isFeeCollector(address) external view returns(bool); function isActive() external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./SafeCast.sol"; import "./VirtualVote.sol"; import "./Vote.sol"; library ExplicitLiquidVoting { using SafeMath for uint256; using SafeCast for uint256; using Vote for Vote.Data; using VirtualVote for VirtualVote.Data; struct Data { VirtualVote.Data data; uint256 _weightedSum; uint256 _votedSupply; mapping(address => Vote.Data) votes; } function updateVote( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 balance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newVote, balance, balance, defaultVote, emitEvent); } function updateBalance( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, uint256 oldBalance, uint256 newBalance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, defaultVote, emitEvent); } function _update( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 oldBalance, uint256 newBalance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) private { uint256 oldWeightedSum = self._weightedSum; uint256 newWeightedSum = oldWeightedSum; uint256 oldVotedSupply = self._votedSupply; uint256 newVotedSupply = oldVotedSupply; if (!oldVote.isDefault()) { newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote))); newVotedSupply = newVotedSupply.sub(oldBalance); } if (!newVote.isDefault()) { newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote))); newVotedSupply = newVotedSupply.add(newBalance); } if (newWeightedSum != oldWeightedSum) { self._weightedSum = newWeightedSum; } if (newVotedSupply != oldVotedSupply) { self._votedSupply = newVotedSupply; } { uint256 newResult = newVotedSupply == 0 ? defaultVote : newWeightedSum.div(newVotedSupply); VirtualVote.Data memory data = self.data; if (newResult != data.result) { VirtualVote.Data storage sdata = self.data; (sdata.oldResult, sdata.result, sdata.time) = ( data.current().toUint104(), newResult.toUint104(), block.timestamp.toUint48() ); } } if (!newVote.eq(oldVote)) { self.votes[user] = newVote; } emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./SafeCast.sol"; import "./VirtualVote.sol"; import "./Vote.sol"; library LiquidVoting { using SafeMath for uint256; using SafeCast for uint256; using Vote for Vote.Data; using VirtualVote for VirtualVote.Data; struct Data { VirtualVote.Data data; uint256 _weightedSum; uint256 _defaultVotes; mapping(address => Vote.Data) votes; } function updateVote( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 balance, uint256 totalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newVote, balance, balance, totalSupply, defaultVote, emitEvent); } function updateBalance( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, newTotalSupply, defaultVote, emitEvent); } function _update( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) private { uint256 oldWeightedSum = self._weightedSum; uint256 newWeightedSum = oldWeightedSum; uint256 oldDefaultVotes = self._defaultVotes; uint256 newDefaultVotes = oldDefaultVotes; if (oldVote.isDefault()) { newDefaultVotes = newDefaultVotes.sub(oldBalance); } else { newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote))); } if (newVote.isDefault()) { newDefaultVotes = newDefaultVotes.add(newBalance); } else { newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote))); } if (newWeightedSum != oldWeightedSum) { self._weightedSum = newWeightedSum; } if (newDefaultVotes != oldDefaultVotes) { self._defaultVotes = newDefaultVotes; } { uint256 newResult = newTotalSupply == 0 ? defaultVote : newWeightedSum.add(newDefaultVotes.mul(defaultVote)).div(newTotalSupply); VirtualVote.Data memory data = self.data; if (newResult != data.result) { VirtualVote.Data storage sdata = self.data; (sdata.oldResult, sdata.result, sdata.time) = ( data.current().toUint104(), newResult.toUint104(), block.timestamp.toUint48() ); } } if (!newVote.eq(oldVote)) { self.votes[user] = newVote; } emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library MooniswapConstants { uint256 internal constant _FEE_DENOMINATOR = 1e18; uint256 internal constant _MIN_REFERRAL_SHARE = 0.05e18; // 5% uint256 internal constant _MIN_DECAY_PERIOD = 1 minutes; uint256 internal constant _MAX_FEE = 0.01e18; // 1% uint256 internal constant _MAX_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _MAX_SHARE = 0.1e18; // 10% uint256 internal constant _MAX_DECAY_PERIOD = 5 minutes; uint256 internal constant _DEFAULT_FEE = 0; uint256 internal constant _DEFAULT_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _DEFAULT_REFERRAL_SHARE = 0.1e18; // 10% uint256 internal constant _DEFAULT_GOVERNANCE_SHARE = 0; uint256 internal constant _DEFAULT_DECAY_PERIOD = 1 minutes; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library SafeCast { function toUint216(uint256 value) internal pure returns (uint216) { require(value < 2**216, "value does not fit in 216 bits"); return uint216(value); } function toUint104(uint256 value) internal pure returns (uint104) { require(value < 2**104, "value does not fit in 104 bits"); return uint104(value); } function toUint48(uint256 value) internal pure returns (uint48) { require(value < 2**48, "value does not fit in 48 bits"); return uint48(value); } function toUint40(uint256 value) internal pure returns (uint40) { require(value < 2**40, "value does not fit in 40 bits"); return uint40(value); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library Sqrt { // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256) { if (y > 3) { uint256 z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } return z; } else if (y != 0) { return 1; } else { return 0; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; library UniERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; function isETH(IERC20 token) internal pure returns(bool) { return (address(token) == address(0)); } function uniBalanceOf(IERC20 token, address account) internal view returns (uint256) { if (isETH(token)) { return account.balance; } else { return token.balanceOf(account); } } function uniTransfer(IERC20 token, address payable to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { to.transfer(amount); } else { token.safeTransfer(to, amount); } } } function uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { require(msg.value >= amount, "UniERC20: not enough value"); require(from == msg.sender, "from is not msg.sender"); require(to == address(this), "to is not this"); if (msg.value > amount) { // Return remainder if exist from.transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(from, to, amount); } } } function uniSymbol(IERC20 token) internal view returns(string memory) { if (isETH(token)) { return "ETH"; } (bool success, bytes memory data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("symbol()") ); if (!success) { (success, data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("SYMBOL()") ); } if (success && data.length >= 96) { (uint256 offset, uint256 len) = abi.decode(data, (uint256, uint256)); if (offset == 0x20 && len > 0 && len <= 256) { return string(abi.decode(data, (bytes))); } } if (success && data.length == 32) { uint len = 0; while (len < data.length && data[len] >= 0x20 && data[len] <= 0x7E) { len++; } if (len > 0) { bytes memory result = new bytes(len); for (uint i = 0; i < len; i++) { result[i] = data[i]; } return string(result); } } return _toHex(address(token)); } function _toHex(address account) private pure returns(string memory) { return _toHex(abi.encodePacked(account)); } function _toHex(bytes memory data) private pure returns(string memory) { bytes memory str = new bytes(2 + data.length * 2); str[0] = "0"; str[1] = "x"; uint j = 2; for (uint i = 0; i < data.length; i++) { uint a = uint8(data[i]) >> 4; uint b = uint8(data[i]) & 0x0f; str[j++] = byte(uint8(a + 48 + (a/10)*39)); str[j++] = byte(uint8(b + 48 + (b/10)*39)); } return string(str); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "./SafeCast.sol"; library VirtualBalance { using SafeMath for uint256; using SafeCast for uint256; struct Data { uint216 balance; uint40 time; } function set(VirtualBalance.Data storage self, uint256 balance) internal { (self.balance, self.time) = ( balance.toUint216(), block.timestamp.toUint40() ); } function update(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance) internal { set(self, current(self, decayPeriod, realBalance)); } function scale(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance, uint256 num, uint256 denom) internal { set(self, current(self, decayPeriod, realBalance).mul(num).add(denom.sub(1)).div(denom)); } function current(VirtualBalance.Data memory self, uint256 decayPeriod, uint256 realBalance) internal view returns(uint256) { uint256 timePassed = Math.min(decayPeriod, block.timestamp.sub(self.time)); uint256 timeRemain = decayPeriod.sub(timePassed); return uint256(self.balance).mul(timeRemain).add( realBalance.mul(timePassed) ).div(decayPeriod); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; library VirtualVote { using SafeMath for uint256; uint256 private constant _VOTE_DECAY_PERIOD = 1 days; struct Data { uint104 oldResult; uint104 result; uint48 time; } function current(VirtualVote.Data memory self) internal view returns(uint256) { uint256 timePassed = Math.min(_VOTE_DECAY_PERIOD, block.timestamp.sub(self.time)); uint256 timeRemain = _VOTE_DECAY_PERIOD.sub(timePassed); return uint256(self.oldResult).mul(timeRemain).add( uint256(self.result).mul(timePassed) ).div(_VOTE_DECAY_PERIOD); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; library Vote { struct Data { uint256 value; } function eq(Vote.Data memory self, Vote.Data memory vote) internal pure returns(bool) { return self.value == vote.value; } function init() internal pure returns(Vote.Data memory data) { return Vote.Data({ value: 0 }); } function init(uint256 vote) internal pure returns(Vote.Data memory data) { return Vote.Data({ value: vote + 1 }); } function isDefault(Data memory self) internal pure returns(bool) { return self.value == 0; } function get(Data memory self, uint256 defaultVote) internal pure returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVote; } function get(Data memory self, function() external view returns(uint256) defaultVoteFn) internal view returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVoteFn(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; contract BalanceAccounting { using SafeMath for uint256; uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function _mint(address account, uint256 amount) internal virtual { _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint256 amount) internal virtual { _balances[account] = _balances[account].sub(amount, "Burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _set(address account, uint256 amount) internal virtual returns(uint256 oldAmount) { oldAmount = _balances[account]; if (oldAmount != amount) { _balances[account] = amount; _totalSupply = _totalSupply.add(amount).sub(oldAmount); } } } // SPDX-License-Identifier: MIT 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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. * * 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.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 is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {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 { } } // 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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.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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ 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 returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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]. */ 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; } }
0x6080604052600436106103135760003560e01c80637e82a6f31161019a578063d21220a7116100e1578063e331d0391161008a578063f1ea604211610064578063f1ea604214610e1a578063f2fde38b14610e2f578063f76d13b414610e6257610313565b8063e331d03914610d73578063e7ff42c914610dbd578063eaadf84814610df057610313565b8063d9a0c217116100bb578063d9a0c21714610d0e578063dd62ed3e14610d23578063ddca3f4314610d5e57610313565b8063d21220a714610c82578063d5bcb9b514610c97578063d7d3aab514610cdb57610313565b80639ea5ce0a11610143578063aa6ca8081161011d578063aa6ca80814610b8d578063b1ec4c4014610bdb578063c40d4d6614610c4f57610313565b80639ea5ce0a14610a9e578063a457c2d714610b1b578063a9059cbb14610b5457610313565b806395cad3c71161017457806395cad3c714610a2357806395d89b4114610a565780639aad141b14610a6b57610313565b80637e82a6f3146109c65780638da5cb5b146109f957806393028d8314610a0e57610313565b80633732b3941161025e5780635ed9156d1161020757806370a08231116101e157806370a0823114610945578063715018a61461097857806378e3214f1461098d57610313565b80635ed9156d146108a15780636669302a146108fd5780636edc2c091461091257610313565b806348d67e1b1161023857806348d67e1b146107ab5780634f64b2be146107c05780635915d806146107ea57610313565b80633732b3941461066057806339509351146106755780633c6216a6146106ae57610313565b806318160ddd116102c057806323e8cae11161029a57806323e8cae11461056a5780633049105d1461057f578063313ce5671461063557610313565b806318160ddd146104bd5780631e1401f8146104e457806323b872dd1461052757610313565b8063095ea7b3116102f1578063095ea7b3146104155780630dfe16811461046257806311212d661461049357610313565b80630146081f1461031857806306fdde031461035f57806307a80070146103e9575b600080fd5b34801561032457600080fd5b5061032d610e77565b604080516001600160681b03948516815292909316602083015265ffffffffffff168183015290519081900360600190f35b34801561036b57600080fd5b50610374610ea3565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103ae578181015183820152602001610396565b50505050905090810190601f1680156103db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f557600080fd5b506104136004803603602081101561040c57600080fd5b5035610f39565b005b34801561042157600080fd5b5061044e6004803603604081101561043857600080fd5b506001600160a01b038135169060200135611061565b604080519115158252519081900360200190f35b34801561046e57600080fd5b5061047761107f565b604080516001600160a01b039092168252519081900360200190f35b34801561049f57600080fd5b50610413600480360360208110156104b657600080fd5b50356110a3565b3480156104c957600080fd5b506104d26111c7565b60408051918252519081900360200190f35b3480156104f057600080fd5b506104d26004803603606081101561050757600080fd5b506001600160a01b038135811691602081013590911690604001356111cd565b34801561053357600080fd5b5061044e6004803603606081101561054a57600080fd5b506001600160a01b03813581169160208101359091169060400135611206565b34801561057657600080fd5b5061032d61128d565b6105f36004803603608081101561059557600080fd5b6040805180820182529183019291818301918390600290839083908082843760009201919091525050604080518082018252929594938181019392509060029083908390808284376000920191909152509194506112b99350505050565b6040518083815260200182600260200280838360005b83811015610621578181015183820152602001610609565b505050509050019250505060405180910390f35b34801561064157600080fd5b5061064a6112d9565b6040805160ff9092168252519081900360200190f35b34801561066c57600080fd5b506104d26112e2565b34801561068157600080fd5b5061044e6004803603604081101561069857600080fd5b506001600160a01b038135169060200135611330565b3480156106ba57600080fd5b50610770600480360360608110156106d157600080fd5b813591908101906040810160208201356401000000008111156106f357600080fd5b82018360208201111561070557600080fd5b8035906020019184602083028401116401000000008311171561072757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505090356001600160a01b0316915061137e9050565b6040518082600260200280838360005b83811015610798578181015183820152602001610780565b5050505090500191505060405180910390f35b3480156107b757600080fd5b506104d2611624565b3480156107cc57600080fd5b50610477600480360360208110156107e357600080fd5b503561166d565b3480156107f657600080fd5b506107706004803603604081101561080d57600080fd5b8135919081019060408101602082013564010000000081111561082f57600080fd5b82018360208201111561084157600080fd5b8035906020019184602083028401116401000000008311171561086357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061171d945050505050565b3480156108ad57600080fd5b506108d4600480360360208110156108c457600080fd5b50356001600160a01b0316611730565b604080516001600160d81b03909316835264ffffffffff90911660208301528051918290030190f35b34801561090957600080fd5b5061041361175b565b34801561091e57600080fd5b506108d46004803603602081101561093557600080fd5b50356001600160a01b0316611789565b34801561095157600080fd5b506104d26004803603602081101561096857600080fd5b50356001600160a01b03166117b4565b34801561098457600080fd5b506104136117cf565b34801561099957600080fd5b50610413600480360360408110156109b057600080fd5b506001600160a01b03813516906020013561189b565b3480156109d257600080fd5b506104d2600480360360208110156109e957600080fd5b50356001600160a01b0316611b61565b348015610a0557600080fd5b50610477611b9c565b348015610a1a57600080fd5b50610413611bb0565b348015610a2f57600080fd5b506104d260048036036020811015610a4657600080fd5b50356001600160a01b0316611bdc565b348015610a6257600080fd5b50610374611c17565b348015610a7757600080fd5b506104d260048036036020811015610a8e57600080fd5b50356001600160a01b0316611c78565b6105f3600480360360a0811015610ab457600080fd5b6040805180820182529183019291818301918390600290839083908082843760009201919091525050604080518082018252929594938181019392509060029083908390808284376000920191909152509194505050356001600160a01b03169050611cb3565b348015610b2757600080fd5b5061044e60048036036040811015610b3e57600080fd5b506001600160a01b038135169060200135612382565b348015610b6057600080fd5b5061044e60048036036040811015610b7757600080fd5b506001600160a01b0381351690602001356123ea565b348015610b9957600080fd5b50610ba26123fe565b60408051602080825283518183015283519192839290830191858101910280838360008315610621578181015183820152602001610609565b348015610be757600080fd5b50610c0e60048036036020811015610bfe57600080fd5b50356001600160a01b03166124bd565b60405180836fffffffffffffffffffffffffffffffff168152602001826fffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b348015610c5b57600080fd5b5061041360048036036020811015610c7257600080fd5b50356001600160a01b03166124f9565b348015610c8e57600080fd5b506104776126ad565b6104d2600480360360a0811015610cad57600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608090910135166126d1565b348015610ce757600080fd5b506104d260048036036020811015610cfe57600080fd5b50356001600160a01b03166126eb565b348015610d1a57600080fd5b50610477612761565b348015610d2f57600080fd5b506104d260048036036040811015610d4657600080fd5b506001600160a01b0381358116916020013516612770565b348015610d6a57600080fd5b506104d261279b565b6104d2600480360360c0811015610d8957600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608082013581169160a00135166127e4565b348015610dc957600080fd5b506104d260048036036020811015610de057600080fd5b50356001600160a01b0316612b7d565b348015610dfc57600080fd5b5061041360048036036020811015610e1357600080fd5b5035612bf3565b348015610e2657600080fd5b5061032d612d68565b348015610e3b57600080fd5b5061041360048036036020811015610e5257600080fd5b50356001600160a01b0316612d94565b348015610e6e57600080fd5b50610413612ebc565b6010546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f2f5780601f10610f0457610100808354040283529160200191610f2f565b820191906000526020600020905b815481529060010190602001808311610f1257829003601f168201915b5050505050905090565b670de0b6b3a7640000811115610f96576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600f602090815260409182902082519182019092529054815261105e9190610fc384612f46565b610fcc336117b4565b610fd46111c7565b600760009054906101000a90046001600160a01b03166001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561102257600080fd5b505afa158015611036573d6000803e3d6000fd5b505050506040513d602081101561104c57600080fd5b5051600c959493929190612f65612fb8565b50565b600061107561106e612fd3565b8484612fd7565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b662386f26fc100008111156110ff576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b336000818152600b602090815260409182902082519182019092529054815261105e919061112c84612f46565b611135336117b4565b61113d6111c7565b600760009054906101000a90046001600160a01b03166001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561118b57600080fd5b505afa15801561119f573d6000803e3d6000fd5b505050506040513d60208110156111b557600080fd5b505160089594939291906130c3612fb8565b60025490565b60006111fc8484846111de886126eb565b6111e788612b7d565b6111ef61279b565b6111f76112e2565b613116565b90505b9392505050565b6000611213848484613257565b6112838461121f612fd3565b61127e85604051806060016040528060288152602001615246602891396001600160a01b038a1660009081526001602052604081209061125d612fd3565b6001600160a01b0316815260208101919091526040016000205491906133b2565b612fd7565b5060019392505050565b600c546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60006112c36150ab565b6112ce848433611cb3565b915091509250929050565b60055460ff1690565b60408051606081018252600c546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b905090565b600061107561133d612fd3565b8461127e856001600061134e612fd3565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906134cc565b6113866150ab565b600260065414156113de576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026006556113eb6150ab565b50604080518082019091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e99842116602082015260006114546111c7565b90506000611460611624565b905061146c3388613526565b60005b60028110156115c157600084826002811061148657fe5b6020020151905060006114a26001600160a01b03831630613622565b905060006114ba866114b4848e6136c3565b9061371c565b90506114d06001600160a01b0384168a8361375e565b808885600281106114dd57fe5b602002015289518410158061150557508984815181106114f957fe5b60200260200101518110155b611556576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a20726573756c74206973206e6f7420656e6f75676800604482015290519081900360640190fd5b6115868583611565898f6137c7565b6001600160a01b03871660009081526015602052604090209291908a613809565b6115b68583611595898f6137c7565b6001600160a01b03871660009081526016602052604090209291908a613809565b50505060010161146f565b508351602080860151604080518b8152928301939093528183015290516001600160a01b0387169133917f3cae9923fd3c2f468aa25a8ef687923e37f957459557c0380fd06526c0b8cdbc9181900360600190a350506001600655509392505050565b604080516060810182526010546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b60008161169b57507f0000000000000000000000000000000000000000000000000000000000000000611718565b81600114156116cb57507f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e998421611718565b6040805162461bcd60e51b815260206004820152601360248201527f506f6f6c206861732074776f20746f6b656e7300000000000000000000000000604482015290519081900360640190fd5b919050565b6117256150ab565b6111ff83833361137e565b6016602052600090815260409020546001600160d81b03811690600160d81b900464ffffffffff1682565b336000818152600f60209081526040918290208251918201909252905481526117879190610fc3613866565b565b6015602052600090815260409020546001600160d81b03811690600160d81b900464ffffffffff1682565b6001600160a01b031660009081526020819052604090205490565b6117d7612fd3565b60055461010090046001600160a01b0390811691161461183e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36005805474ffffffffffffffffffffffffffffffffffffffff0019169055565b600260065414156118f3576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655611900612fd3565b60055461010090046001600160a01b03908116911614611967576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600061199c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630613622565b905060006119d36001600160a01b037f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e9984211630613622565b90506119e96001600160a01b038516338561375e565b81611a1d6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630613622565b1015611a70576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b80611aa46001600160a01b037f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e9984211630613622565b1015611af7576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b6103e8611b03306117b4565b1015611b56576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b505060016006555050565b6007546001600160a01b038281166000908152601360209081526040808320815192830190915254815290926110799216631845f0db613881565b60055461010090046001600160a01b031690565b336000818152600b6020908152604091829020825191820190925290548152611787919061112c613866565b6007546001600160a01b038281166000908152600f602090815260408083208151928301909152548152909261107992166323662bb9613881565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f2f5780601f10610f0457610100808354040283529160200191610f2f565b6007546001600160a01b038281166000908152600b60209081526040808320815192830190915254815290926110799216635a6c72d0613881565b6000611cbd6150ab565b60026006541415611d15576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655611d226150ab565b50604080518082019091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e998421166020820152611d9b8160005b60200201516001600160a01b03166138f7565b611dc057611daa816001611d88565b611db5576000611dbb565b60208601515b611dc3565b85515b3414611e16576040805162461bcd60e51b815260206004820152601c60248201527f4d6f6f6e69737761703a2077726f6e672076616c756520757361676500000000604482015290519081900360640190fd5b6000611e206111c7565b905080611fac57611e346103e860636136c3565b9350611e42306103e8613904565b60005b6002811015611fa657611e6885898360028110611e5e57fe5b60200201516139f4565b94506000888260028110611e7857fe5b602002015111611ecf576040805162461bcd60e51b815260206004820152601960248201527f4d6f6f6e69737761703a20616d6f756e74206973207a65726f00000000000000604482015290519081900360640190fd5b868160028110611edb57fe5b6020020151888260028110611eec57fe5b60200201511015611f44576040805162461bcd60e51b815260206004820181905260248201527f4d6f6f6e69737761703a206d696e416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b611f7c33308a8460028110611f5557fe5b6020020151868560028110611f6657fe5b60200201516001600160a01b0316929190613a0b565b878160028110611f8857fe5b6020020151848260028110611f9957fe5b6020020152600101611e45565b506122bf565b611fb46150ab565b60005b600281101561202257612009611fd2858360028110611d8857fe5b611fdd576000611fdf565b345b61200330878560028110611fef57fe5b60200201516001600160a01b031690613622565b906137c7565b82826002811061201557fe5b6020020152600101611fb7565b50600019945060005b60028110156120765761206c8661206784846002811061204757fe5b60200201516114b48d866002811061205b57fe5b602002015188906136c3565b613b97565b955060010161202b565b508460005b60028110156122035760008a826002811061209257fe5b6020020151116120e9576040805162461bcd60e51b815260206004820152601960248201527f4d6f6f6e69737761703a20616d6f756e74206973207a65726f00000000000000604482015290519081900360640190fd5b6000612117856114b4600188036121118789886002811061210657fe5b6020020151906136c3565b906134cc565b905089826002811061212557fe5b602002015181101561217e576040805162461bcd60e51b815260206004820181905260248201527f4d6f6f6e69737761703a206d696e416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b612190333083898660028110611f6657fe5b6121b484836002811061219f57fe5b602002015161200330898660028110611fef57fe5b8783600281106121c057fe5b60200201526121f8886120678685600281106121d857fe5b60200201516114b48b87600281106121ec57fe5b60200201518a906136c3565b97505060010161207b565b50600061220e611624565b905060005b60028110156122ba576122828285836002811061222c57fe5b602002015161223b888c6134cc565b88601660008c886002811061224c57fe5b60200201516001600160a01b03166001600160a01b0316815260200190815260200160002061380990949392919063ffffffff16565b6122b28285836002811061229257fe5b60200201516122a1888c6134cc565b88601560008c886002811061224c57fe5b600101612213565b505050505b60008411612314576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a20726573756c74206973206e6f7420656e6f75676800604482015290519081900360640190fd5b61231e8585613904565b825160208085015160408051888152928301939093528183015290516001600160a01b0387169133917f8bab6aed5a508937051a144e61d6e61336834a66aaee250a00613ae6f744c4229181900360600190a3505060016006559094909350915050565b600061107561238f612fd3565b8461127e8560405180606001604052806025815260200161530260259139600160006123b9612fd3565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906133b2565b60006110756123f7612fd3565b8484613257565b60408051600280825260608083018452926020830190803683370190505090507f00000000000000000000000000000000000000000000000000000000000000008160008151811061244c57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e9984218160018151811061249a57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505090565b6014602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b612501612fd3565b60055461010090046001600160a01b03908116911614612568576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600780547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316179055604080517f93028d83000000000000000000000000000000000000000000000000000000008152905130916393028d8391600480830192600092919082900301818387803b1580156125ec57600080fd5b505af1158015612600573d6000803e3d6000fd5b50505050306001600160a01b0316636669302a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561263f57600080fd5b505af1158015612653573d6000803e3d6000fd5b50505050306001600160a01b031663f76d13b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561269257600080fd5b505af11580156126a6573d6000803e3d6000fd5b5050505050565b7f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e99842181565b60006126e18686868686336127e4565b9695505050505050565b6000806127016001600160a01b03841630613622565b90506111ff61275b612711611624565b6001600160a01b0386166000908152601560209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff16908201529084613ba6565b826139f4565b6007546001600160a01b031681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b604080516060810182526008546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b60006002600654141561283e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600754604080517f22f3e2d400000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916322f3e2d491600480820192602092909190829003018186803b1580156128a157600080fd5b505afa1580156128b5573d6000803e3d6000fd5b505050506040513d60208110156128cb57600080fd5b505161291e576040805162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e69737761703a20666163746f72792073687574646f776e0000000000604482015290519081900360640190fd5b612930876001600160a01b03166138f7565b61293b57600061293d565b845b3414612990576040805162461bcd60e51b815260206004820152601c60248201527f4d6f6f6e69737761703a2077726f6e672076616c756520757361676500000000604482015290519081900360640190fd5b6129986150c9565b60405180604001604052806129d86129b88b6001600160a01b03166138f7565b6129c35760006129c5565b345b6120036001600160a01b038d1630613622565b81526020016129f06001600160a01b038a1630613622565b9052905060006129fe6150c9565b612a066150c9565b6040518060400160405280612a1961279b565b8152602001612a266112e2565b90529050612a398b8b8b8b8a8987613c01565b8094508197508295505050508a6001600160a01b0316866001600160a01b0316336001600160a01b03167fbd99c6719f088aa0abd9e7b7a4a635d1f931601e9f304b538dc42be25d8c65c68d878a886000015189602001518f60405180876001600160a01b03168152602001868152602001858152602001848152602001838152602001826001600160a01b03168152602001965050505050505060405180910390a4612ae98386898785613e84565b50506001600160a01b03909816600090815260146020526040902080547001000000000000000000000000000000006fffffffffffffffffffffffffffffffff808316909b018b167fffffffffffffffffffffffffffffffff00000000000000000000000000000000909216919091178181048b1685018b1690910299169890981790975560016006559695505050505050565b600080612b936001600160a01b03841630613622565b90506111ff612bed612ba3611624565b6001600160a01b0386166000908152601660209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff16908201529084613ba6565b82613b97565b61012c811115612c4a576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c811015612ca0576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b3360008181526013602090815260409182902082519182019092529054815261105e9190612ccd84612f46565b612cd6336117b4565b612cde6111c7565b600760009054906101000a90046001600160a01b03166001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d2c57600080fd5b505afa158015612d40573d6000803e3d6000fd5b505050506040513d6020811015612d5657600080fd5b505160109594939291906143af612fb8565b6008546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b612d9c612fd3565b60055461010090046001600160a01b03908116911614612e03576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116612e485760405162461bcd60e51b81526004018080602001828103825260268152602001806151b76026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b039092166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179055565b336000818152601360209081526040918290208251918201909252905481526117879190612ccd613866565b6000600160681b8210612f42576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2031303420626974730000604482015290519081900360640190fd5b5090565b612f4e6150e3565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917fce0cf859d853e1944032294143a1bf3ad799998ae77acbeb6c4d9b20d6910240919081900360600190a250505050565b612fc9888888888889898989614402565b5050505050505050565b3390565b6001600160a01b03831661301c5760405162461bcd60e51b81526004018080602001828103825260248152602001806152b46024913960400191505060405180910390fd5b6001600160a01b0382166130615760405162461bcd60e51b81526004018080602001828103825260228152602001806151dd6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fe117cae46817b894b41a4412b73ae0ba746a5707b94e02d83b4c6502010b11ac919081900360600190a250505050565b6000866001600160a01b0316886001600160a01b03161115613136579596955b60008611801561317757507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316145b80156131b457507f0000000000000000000000001b40183efb4dd766f11bda7a7c3ad8982e9984216001600160a01b0316876001600160a01b0316145b1561324c5760006131db6131d4670de0b6b3a76400006114b48a886136c3565b88906137c7565b905060006131e987836134cc565b905060006131fb826114b4858a6136c3565b9050600061321e61320c87866136c3565b612003670de0b6b3a7640000866136c3565b90506000613234670de0b6b3a7640000856136c3565b9050613244816114b485856136c3565b955050505050505b979650505050505050565b6001600160a01b03831661329c5760405162461bcd60e51b815260040180806020018281038252602581526020018061528f6025913960400191505060405180910390fd5b6001600160a01b0382166132e15760405162461bcd60e51b81526004018080602001828103825260238152602001806151726023913960400191505060405180910390fd5b6132ec838383614626565b613329816040518060600160405280602681526020016151ff602691396001600160a01b03861660009081526020819052604090205491906133b2565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461335890826134cc565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156134415760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156134065781810151838201526020016133ee565b50505050905090810190601f1680156134335780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008061347262015180612067856040015165ffffffffffff16426137c790919063ffffffff16565b9050600061348362015180836137c7565b90506134c4620151806114b46134af8588602001516001600160681b03166136c390919063ffffffff16565b8751612111906001600160681b0316866136c3565b949350505050565b6000828201838110156111ff576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03821661356b5760405162461bcd60e51b815260040180806020018281038252602181526020018061526e6021913960400191505060405180910390fd5b61357782600083614626565b6135b481604051806060016040528060228152602001615195602291396001600160a01b03851660009081526020819052604090205491906133b2565b6001600160a01b0383166000908152602081905260409020556002546135da90826137c7565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600061362d836138f7565b1561364357506001600160a01b03811631611079565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561369057600080fd5b505afa1580156136a4573d6000803e3d6000fd5b505050506040513d60208110156136ba57600080fd5b50519050611079565b6000826136d257506000611079565b828202828482816136df57fe5b04146111ff5760405162461bcd60e51b81526004018080602001828103825260218152602001806152256021913960400191505060405180910390fd5b60006111ff83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614911565b80156137c25761376d836138f7565b156137ae576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156137a8573d6000803e3d6000fd5b506137c2565b6137c26001600160a01b0384168383614976565b505050565b60006111ff83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506133b2565b6126a685613861836114b461381f8260016137c7565b604080518082019091528b546001600160d81b0381168252600160d81b900464ffffffffff16602082015261211190899061385b908d8d613ba6565b906136c3565b6149f6565b61386e6150e3565b5060408051602081019091526000815290565b82516000901561389757508251600019016111ff565b82826040518163ffffffff1660e01b815260040160206040518083038186803b1580156138c357600080fd5b505afa1580156138d7573d6000803e3d6000fd5b505050506040513d60208110156138ed57600080fd5b5051949350505050565b6001600160a01b03161590565b6001600160a01b03821661395f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61396b60008383614626565b60025461397890826134cc565b6002556001600160a01b03821660009081526020819052604090205461399e90826134cc565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600081831015613a0457816111ff565b5090919050565b8015613b9157613a1a846138f7565b15613b7c5780341015613a74576040805162461bcd60e51b815260206004820152601a60248201527f556e6945524332303a206e6f7420656e6f7567682076616c7565000000000000604482015290519081900360640190fd5b6001600160a01b0383163314613ad1576040805162461bcd60e51b815260206004820152601660248201527f66726f6d206973206e6f74206d73672e73656e64657200000000000000000000604482015290519081900360640190fd5b6001600160a01b0382163014613b2e576040805162461bcd60e51b815260206004820152600e60248201527f746f206973206e6f742074686973000000000000000000000000000000000000604482015290519081900360640190fd5b80341115613b77576001600160a01b0383166108fc613b4d34846137c7565b6040518115909202916000818181858888f19350505050158015613b75573d6000803e3d6000fd5b505b613b91565b613b916001600160a01b038516848484614a53565b50505050565b6000818310613a0457816111ff565b600080613bcb84612067876020015164ffffffffff16426137c790919063ffffffff16565b90506000613bd985836137c7565b90506126e1856114b4613bec87866136c3565b8951612111906001600160d81b0316866136c3565b600080613c0c6150c9565b6000613c16611624565b86516001600160a01b038d166000908152601560209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff1690820152919250613c6a91908390613ba6565b8083528651613c7991906139f4565b82526020868101516001600160a01b038c166000908152601683526040908190208151808301909252546001600160d81b0381168252600160d81b900464ffffffffff1692810192909252613cd091908390613ba6565b6020808401829052870151613ce59190613b97565b6020830152613cff6001600160a01b038c1633308c613a0b565b8551613d18906120036001600160a01b038e1630613622565b9350613d398b8b86856000015186602001518a600001518b60200151613116565b9250600083118015613d4b5750878310155b613d9c576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a2072657475726e206973206e6f7420656e6f75676800604482015290519081900360640190fd5b613db06001600160a01b038b16888561375e565b8551825114613de7578151613de790613dc990866134cc565b6001600160a01b038d166000908152601560205260409020906149f6565b8560200151826020015114613e27576020820151613e2790613e0990856137c7565b6001600160a01b038c166000908152601660205260409020906149f6565b85516001600160a01b038c166000908152601660205260409020613e4c918390614adb565b6020808701516001600160a01b038c16600090815260159092526040909120613e76918390614adb565b509750975097945050505050565b600080600080600760009054906101000a90046001600160a01b03166001600160a01b031663172886e76040518163ffffffff1660e01b815260040160806040518083038186803b158015613ed857600080fd5b505afa158015613eec573d6000803e3d6000fd5b505050506040513d6080811015613f0257600080fd5b8101908080519060200190929190805190602001909291908051906020019092919080519060200190929190505050935093509350935060008060006ec097ce7bc90715b34b9f10000000009050613f7989600001516114b4613f728f8d600001516134cc90919063ffffffff16565b84906136c3565b60208a0151909150613f92906114b4613f72828f6137c7565b90506ec097ce7bc90715b34b9f100000000081111561434357613fb481614b17565b90506000613fd9826114b4613fd182670de0b6b3a76400006137c7565b61385b6111c7565b90506001600160a01b038b16613ff0576000614006565b614006670de0b6b3a76400006114b4838b6136c3565b93506001600160a01b03861661401d576000614033565b614033670de0b6b3a76400006114b4838a6136c3565b92506001600160a01b038516614068578315614053576140538b85613904565b8215614063576140638684613904565b614341565b60008411806140775750600083115b1561434157600080841161408c57600061408f565b60015b6000861161409e5760006140a1565b60015b0160ff16905060608167ffffffffffffffff811180156140c057600080fd5b506040519080825280602002602001820160405280156140ea578160200160208202803683370190505b50905060608267ffffffffffffffff8111801561410657600080fd5b50604051908082528060200260200182016040528015614130578160200160208202803683370190505b5090508d8260008151811061414157fe5b60200260200101906001600160a01b031690816001600160a01b031681525050868160008151811061416f57fe5b602090810291909101015285156141cd578882600185038151811061419057fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858160018503815181106141c057fe5b6020026020010181815250505b604080517f0931753c000000000000000000000000000000000000000000000000000000008152600481019182528351604482015283516001600160a01b038b1692630931753c92869286929182916024820191606401906020808801910280838360005b8381101561424a578181015183820152602001614232565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015614289578181015183820152602001614271565b50505050905001945050505050600060405180830381600087803b1580156142b057600080fd5b505af19250505080156142c1575060015b61432a576040805160208082526016908201527f757064617465526577617264732829206661696c6564000000000000000000008183015290517f08c379a0afcc32b1a39302f7cb8073359698411ab5fd6e3edb2c02c0b5fba8aa9181900360600190a161433d565b61433d8861433889896134cc565b613904565b5050505b505b88516020808b01518a518b83015160408051958652938501929092528383015260608301526080820185905260a08201849052517f2a368c7f33bb86e2d999940a3989d849031aff29b750f67947e6b8e8c3d2ffd69181900360c00190a1505050505050505050505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fd0784d105a7412ffec29813ff8401f04f3d1cdbe6aca756974b1a31f830e5cb7919081900360600190a250505050565b600189015460028a01548190806144188b614b71565b1561442e57614427818a6137c7565b905061444f565b61444c61444561443e8d89614b76565b8b906136c3565b84906137c7565b92505b6144588a614b71565b1561446e5761446781896134cc565b905061448f565b61448c61448561447e8c89614b76565b8a906136c3565b84906134cc565b92505b83831461449e5760018d018390555b8181146144ad5760028d018190555b600087156144d2576144cd886114b46144c6858b6136c3565b87906134cc565b6144d4565b865b90506144de6150f6565b50604080516060810182528f546001600160681b038082168352600160681b82041660208301819052600160d01b90910465ffffffffffff16928201929092529082146145c6578e61453761453283613449565b612ee8565b61454084612ee8565b61454942614b92565b835479ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b65ffffffffffff9290921691909102177fffffffffffff00000000000000000000000000ffffffffffffffffffffffffff16600160681b6001600160681b0392831602176cffffffffffffffffffffffffff191691161790555b506145d390508a8c614bef565b6145f6576001600160a01b038c16600090815260038e01602052604090208a5190555b6146178c6146048c89614b76565b61460d8d614b71565b8b8963ffffffff16565b50505050505050505050505050565b816001600160a01b0316836001600160a01b03161415614645576137c2565b6007546001600160a01b0390811690600090851615806146da5750816001600160a01b0316633b90b9bf866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156146ad57600080fd5b505afa1580156146c1573d6000803e3d6000fd5b505050506040513d60208110156146d757600080fd5b50515b15905060006001600160a01b038516158061476a5750826001600160a01b0316633b90b9bf866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561473d57600080fd5b505afa158015614751573d6000803e3d6000fd5b505050506040513d602081101561476757600080fd5b50515b15905081158015614779575080155b15614786575050506137c2565b60006001600160a01b03871661479d5760006147a6565b6147a6876117b4565b905060006001600160a01b0387166147bf5760006147c8565b6147c8876117b4565b9050600061480a6001600160a01b038916156147e55760006147e7565b875b6120036001600160a01b038c1615614800576000614802565b895b6121116111c7565b9050614814615116565b6040518061010001604052808b6001600160a01b031681526020018a6001600160a01b03168152602001871515815260200186151581526020018981526020018581526020018481526020018381525090506000806000896001600160a01b031663edb7a6fa6040518163ffffffff1660e01b815260040160606040518083038186803b1580156148a457600080fd5b505afa1580156148b8573d6000803e3d6000fd5b505050506040513d60608110156148ce57600080fd5b508051602082015160409092015190945090925090506148f384846130c36008614bf6565b6149028483612f65600c614bf6565b61461784826143af6010614bf6565b600081836149605760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156134065781810151838201526020016133ee565b50600083858161496c57fe5b0495945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526137c2908490614d70565b6149ff81614e21565b614a0842614e7b565b83546001600160d81b0392831664ffffffffff909216600160d81b029216919091177fffffffffff000000000000000000000000000000000000000000000000000000161790915550565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052613b91908590614d70565b6040805180820190915283546001600160d81b0381168252600160d81b900464ffffffffff1660208201526137c2908490613861908585613ba6565b60006003821115614b5b5781600160028204015b81811015614b5357809150600281828681614b4257fe5b040181614b4b57fe5b049050614b2b565b509050611718565b8115614b6957506001611718565b506000611718565b511590565b815160009015614b8c5750815160001901611079565b50919050565b600066010000000000008210612f42576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034382062697473000000604482015290519081900360640190fd5b5190511490565b614bfe6150e3565b5083516001600160a01b03166000908152600382016020908152604091829020825191820190925290548152614c326150e3565b506020808601516001600160a01b031660009081526003840182526040908190208151928301909152548152614c6782614b71565b8015614c775750614c7781614b71565b8015614c84575085604001515b8015614c91575085606001515b15614d03578551614ccc90614ca68488614b76565b6001614cc38a608001518b60a001516137c790919063ffffffff16565b8863ffffffff16565b6020860151614cfc90614cdf8388614b76565b6001614cc38a608001518b60c001516134cc90919063ffffffff16565b5050613b91565b856040015115614d3d57855160a08701516080880151614d3d92918591614d2b9082906137c7565b60e08b01518894939291908b8b614ed7565b856060015115614d6857602086015160c08701516080880151614d6892918491614d2b9082906134cc565b505050505050565b6060614dc5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614efb9092919063ffffffff16565b8051909150156137c257808060200190516020811015614de457600080fd5b50516137c25760405162461bcd60e51b815260040180806020018281038252602a8152602001806152d8602a913960400191505060405180910390fd5b6000600160d81b8210612f42576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2032313620626974730000604482015290519081900360640190fd5b6000650100000000008210612f42576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034302062697473000000604482015290519081900360640190fd5b612fc98888888715614ee95789614ef1565b614ef1613866565b8989898989614402565b60606111fc84846000856060614f1085615072565b614f61576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614fa05780518252601f199092019160209182019101614f81565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615002576040519150601f19603f3d011682016040523d82523d6000602084013e615007565b606091505b5091509150811561501b5791506134c49050565b80511561502b5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156134065781810151838201526020016133ee565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906134c4575050151592915050565b60405180604001604052806002906020820280368337509192915050565b604051806040016040528060008152602001600081525090565b6040518060200160405280600081525090565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160001515815260200160001515815260200160008152602001600081526020016000815260200160008152509056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220f5acfd09e87c0e0c91649c917b687b73362797cc26a1c21a7d92ee5d568457a464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "msg-value-loop", "impact": "High", "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': 'msg-value-loop', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 10354, 25746, 2063, 2581, 22610, 2094, 21619, 2546, 2581, 2683, 2278, 24096, 22407, 2620, 16048, 2692, 17788, 2575, 2278, 2629, 9468, 2629, 3676, 2487, 2497, 14526, 2629, 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, 1013, 8785, 1013, 8785, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 19706, 1013, 2065, 4402, 26895, 22471, 2953, 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,983
0x97af554dbff8e0fc0fb6693a6370855eefb3517c
// Sources flattened with hardhat v2.2.0 https://hardhat.org // File @openzeppelin/contracts/GSN/Context.sol@v3.3.0 // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File @openzeppelin/contracts/access/Ownable.sol@v3.3.0 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 @animoca/ethereum-contracts-core_library-5.0.0/contracts/access/WhitelistedOperators.sol@v5.0.0 pragma solidity 0.6.8; contract WhitelistedOperators is Ownable { mapping(address => bool) internal _whitelistedOperators; event WhitelistedOperator(address operator, bool enabled); /// @notice Enable or disable address operator access /// @param operator address that will be given/removed operator right. /// @param enabled set whether the operator is enabled or disabled. function whitelistOperator(address operator, bool enabled) external onlyOwner { _whitelistedOperators[operator] = enabled; emit WhitelistedOperator(operator, enabled); } /// @notice check whether address `who` is given operator rights. /// @param who The address to query. /// @return whether the address is whitelisted operator function isOperator(address who) public view returns (bool) { return _whitelistedOperators[who]; } } // File @openzeppelin/contracts/introspection/IERC165.sol@v3.3.0 pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/introspection/ERC165.sol@v3.3.0 pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File @openzeppelin/contracts/math/SafeMath.sol@v3.3.0 pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File @openzeppelin/contracts/utils/Address.sol@v3.3.0 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 @animoca/ethereum-contracts-erc20_base-4.0.0/contracts/token/ERC20/IERC20.sol@v4.0.0 /* https://github.com/OpenZeppelin/openzeppelin-contracts The MIT License (MIT) Copyright (c) 2016-2019 zOS Global Limited 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. */ pragma solidity 0.6.8; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed _from, address indexed _to, uint256 _value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `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); } // File @animoca/ethereum-contracts-erc20_base-4.0.0/contracts/token/ERC20/IERC20Detailed.sol@v4.0.0 /* https://github.com/OpenZeppelin/openzeppelin-contracts The MIT License (MIT) Copyright (c) 2016-2019 zOS Global Limited 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. */ pragma solidity 0.6.8; /** * @dev Interface for commonly used additional ERC20 interfaces */ interface IERC20Detailed { /** * @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 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. * * 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() external view returns (uint8); } // File @animoca/ethereum-contracts-erc20_base-4.0.0/contracts/token/ERC20/IERC20Allowance.sol@v4.0.0 pragma solidity 0.6.8; /** * @dev Interface for additional ERC20 allowance features */ interface IERC20Allowance { /** * @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) external returns (bool); /** * @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) external returns (bool); } // File @animoca/ethereum-contracts-erc20_base-4.0.0/contracts/token/ERC20/ERC20.sol@v4.0.0 /* https://github.com/OpenZeppelin/openzeppelin-contracts The MIT License (MIT) Copyright (c) 2016-2019 zOS Global Limited 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. */ pragma solidity 0.6.8; /** * @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 {ERC20MinterPauser}. * * 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}. */ abstract contract ERC20 is ERC165, Context, IERC20, IERC20Detailed, IERC20Allowance { using SafeMath for uint256; using Address for address; mapping(address => uint256) internal _balances; mapping(address => mapping(address => uint256)) internal _allowances; uint256 internal _totalSupply; constructor() internal { _registerInterface(type(IERC20).interfaceId); _registerInterface(type(IERC20Detailed).interfaceId); _registerInterface(type(IERC20Allowance).interfaceId); // ERC20Name interfaceId: bytes4(keccak256("name()")) _registerInterface(0x06fdde03); // ERC20Symbol interfaceId: bytes4(keccak256("symbol()")) _registerInterface(0x95d89b41); // ERC20Decimals interfaceId: bytes4(keccak256("decimals()")) _registerInterface(0x313ce567); } /////////////////////////////////////////// ERC20 /////////////////////////////////////// /** * @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; } /////////////////////////////////////////// ERC20Allowance /////////////////////////////////////// /** * @dev See {IERC20Allowance-increaseAllowance}. */ function increaseAllowance(address spender, uint256 addedValue) public virtual override returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev See {IERC20Allowance-decreaseAllowance}. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /////////////////////////////////////////// Internal Functions /////////////////////////////////////// /** * @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 { // solhint-disable-next-line reason-string require(sender != address(0), "ERC20: transfer from the zero address"); // solhint-disable-next-line reason-string 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 { // solhint-disable-next-line reason-string require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { // solhint-disable-next-line reason-string require(owner != address(0), "ERC20: approve from the zero address"); // solhint-disable-next-line reason-string require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /////////////////////////////////////////// Hooks /////////////////////////////////////// /** * @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. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File @animoca/ethereum-contracts-erc20_base-4.0.0/contracts/token/ERC20/ERC20WithOperators.sol@v4.0.0 pragma solidity 0.6.8; abstract contract ERC20WithOperators is ERC20, WhitelistedOperators { /** * NOTICE * This override will allow *any* whitelisted operator to be able to * transfer unresitricted amounts of ERC20WithOperators-based tokens from 'sender' * to 'recipient'. Care must be taken to ensure to integrity of the * whitelisted operator list. */ function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { address msgSender = _msgSender(); // bypass the internal allowance manipulation and checks for the // whitelisted operator (i.e. _msgSender()). as a side-effect, the // 'Approval' event will not be emitted since the allowance was not // updated. if (!isOperator(msgSender)) { _approve(sender, msgSender, allowance(sender, msgSender).sub(amount)); } _transfer(sender, recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { if (isOperator(spender)) { // allow the front-end to determine whether or not an approval is // necessary, given that the whitelisted operator status of the // spender is unknown. A call to WhitelistedOperators::isOperator() // is more direct, but we want to expose a mechanism by which to // check through the ERC20 interface. return type(uint256).max; } else { return super.allowance(owner, spender); } } function increaseAllowance(address spender, uint256 addedValue) public override returns (bool) { if (isOperator(spender)) { // bypass the internal allowance manipulation and checks for the // whitelisted operator (i.e. spender). as a side-effect, the // 'Approval' event will not be emitted since the allowance was not // updated. return true; } else { return super.increaseAllowance(spender, addedValue); } } function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool) { if (isOperator(spender)) { // bypass the internal allowance manipulation and checks for the // whitelisted operator (i.e. spender). as a side-effect, the // 'Approval' event will not be emitted since the allowance was not // updated. return true; } else { return super.decreaseAllowance(spender, subtractedValue); } } function _approve( address owner, address spender, uint256 value ) internal override { if (isOperator(spender)) { // bypass the internal allowance manipulation and checks for the // whitelisted operator (i.e. spender). as a side-effect, the // 'Approval' event will not be emitted since the allowance was not // updated. return; } else { super._approve(owner, spender, value); } } } // File contracts/token/ERC20/BRINC.sol pragma solidity 0.6.8; /** * @title BRINC */ contract BRINC is ERC20WithOperators { // solhint-disable-next-line const-name-snakecase string public constant override name = "Brinc"; // solhint-disable-next-line const-name-snakecase string public constant override symbol = "BRQ"; // solhint-disable-next-line const-name-snakecase uint8 public constant override decimals = 18; constructor(address[] memory holders, uint256[] memory amounts) public ERC20WithOperators() { require(holders.length == amounts.length, "BRINC: inconsistent arrays"); for (uint256 i = 0; i != holders.length; ++i) { _mint(holders[i], amounts[i]); } } }
0x608060405234801561001057600080fd5b506004361061011b5760003560e01c80636d70f7ae116100b257806395d89b4111610081578063a9059cbb11610066578063a9059cbb14610392578063dd62ed3e146103be578063f2fde38b146103ec5761011b565b806395d89b411461035e578063a457c2d7146103665761011b565b80636d70f7ae146102e657806370a082311461030c578063715018a6146103325780638da5cb5b1461033a5761011b565b806318ea4513116100ee57806318ea45131461023657806323b872dd14610266578063313ce5671461029c57806339509351146102ba5761011b565b806301ffc9a71461012057806306fdde0314610173578063095ea7b3146101f057806318160ddd1461021c575b600080fd5b61015f6004803603602081101561013657600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610412565b604080519115158252519081900360200190f35b61017b610449565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b557818101518382015260200161019d565b50505050905090810190601f1680156101e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61015f6004803603604081101561020657600080fd5b506001600160a01b038135169060200135610482565b6102246104a0565b60408051918252519081900360200190f35b6102646004803603604081101561024c57600080fd5b506001600160a01b03813516906020013515156104a6565b005b61015f6004803603606081101561027c57600080fd5b506001600160a01b03813581169160208101359091169060400135610592565b6102a46105e6565b6040805160ff9092168252519081900360200190f35b61015f600480360360408110156102d057600080fd5b506001600160a01b0381351690602001356105eb565b61015f600480360360208110156102fc57600080fd5b50356001600160a01b0316610614565b6102246004803603602081101561032257600080fd5b50356001600160a01b0316610632565b61026461064d565b610342610719565b604080516001600160a01b039092168252519081900360200190f35b61017b610728565b61015f6004803603604081101561037c57600080fd5b506001600160a01b038135169060200135610761565b61015f600480360360408110156103a857600080fd5b506001600160a01b038135169060200135610783565b610224600480360360408110156103d457600080fd5b506001600160a01b0381358116916020013516610797565b6102646004803603602081101561040257600080fd5b50356001600160a01b03166107d8565b7fffffffff000000000000000000000000000000000000000000000000000000001660009081526020819052604090205460ff1690565b6040518060400160405280600581526020017f4272696e6300000000000000000000000000000000000000000000000000000081525081565b600061049661048f61095c565b8484610960565b5060015b92915050565b60035490565b6104ae61095c565b6004546001600160a01b03908116911614610510576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03821660008181526005602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001685151590811790915582519384529083015280517f68d3992ad51e852ec24f4f7d106d7886d715a58e71176bc329cea3d11e7f08e49281900390910190a15050565b60008061059d61095c565b90506105a881610614565b6105d0576105d085826105cb866105bf8a87610797565b9063ffffffff61098316565b610960565b6105db8585856109c5565b506001949350505050565b601281565b60006105f683610614565b156106035750600161049a565b61060d8383610b2e565b905061049a565b6001600160a01b031660009081526005602052604090205460ff1690565b6001600160a01b031660009081526001602052604090205490565b61065561095c565b6004546001600160a01b039081169116146106b7576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6004546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6004546001600160a01b031690565b6040518060400160405280600381526020017f425251000000000000000000000000000000000000000000000000000000000081525081565b600061076c83610614565b156107795750600161049a565b61060d8383610b82565b600061049661079061095c565b84846109c5565b60006107a282610614565b156107ce57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61049a565b61060d8383610bf0565b6107e061095c565b6004546001600160a01b03908116911614610842576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166108875760405162461bcd60e51b8152600401808060200182810382526026815260200180610dc26026913960400191505060405180910390fd5b6004546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600082820183811015610955576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b61096982610614565b156109735761097e565b61097e838383610c1b565b505050565b600061095583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610d07565b6001600160a01b038316610a0a5760405162461bcd60e51b8152600401808060200182810382526025815260200180610e306025913960400191505060405180910390fd5b6001600160a01b038216610a4f5760405162461bcd60e51b8152600401808060200182810382526023815260200180610d9f6023913960400191505060405180910390fd5b610a5a83838361097e565b610a9d81604051806060016040528060268152602001610e0a602691396001600160a01b038616600090815260016020526040902054919063ffffffff610d0716565b6001600160a01b038085166000908152600160205260408082209390935590841681522054610ad2908263ffffffff6108fb16565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000610496610b3b61095c565b846105cb8560026000610b4c61095c565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff6108fb16565b6000610496610b8f61095c565b846105cb85604051806060016040528060258152602001610e796025913960026000610bb961095c565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610d0716565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6001600160a01b038316610c605760405162461bcd60e51b8152600401808060200182810382526024815260200180610e556024913960400191505060405180910390fd5b6001600160a01b038216610ca55760405162461bcd60e51b8152600401808060200182810382526022815260200180610de86022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60008184841115610d965760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d5b578181015183820152602001610d43565b50505050905090810190601f168015610d885780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50505090039056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212206e561ba8715a77583c0ee17e68b0ffc7fa79ffa7189644b3aefdb264bf51ccc364736f6c63430006080033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 10354, 24087, 2549, 18939, 4246, 2620, 2063, 2692, 11329, 2692, 26337, 28756, 2683, 2509, 2050, 2575, 24434, 2692, 27531, 2629, 4402, 26337, 19481, 16576, 2278, 1013, 1013, 4216, 16379, 2007, 2524, 12707, 1058, 2475, 1012, 1016, 1012, 1014, 16770, 1024, 1013, 1013, 2524, 12707, 1012, 8917, 1013, 1013, 5371, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 28177, 2078, 1013, 6123, 1012, 14017, 1030, 1058, 2509, 1012, 1017, 1012, 1014, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1030, 16475, 3640, 2592, 2055, 1996, 2783, 7781, 6123, 1010, 2164, 1996, 1008, 4604, 2121, 1997, 1996, 12598, 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,984
0x97aF890Ef9A5cdb429930c113DdBA1D1AE691eb7
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/ITheCoachFunds.sol"; import "@openzeppelin/contracts/utils/Address.sol"; contract TheCoachPreminter { using Address for address payable; ITheCoachFunds private coachContract; constructor(address _coachContract) { coachContract = ITheCoachFunds(_coachContract); } function batchPreMintFor(address[] memory addrs, uint256[] memory counts) external payable { require(addrs.length == counts.length, "Wrong length"); uint256 unitPrice = coachContract.getWeiPrice(); uint256 valueUsed = 0; for (uint256 i = 0; i < addrs.length; i++) { uint256 totalPrice = unitPrice * counts[i]; coachContract.preMintFor{value: totalPrice}(addrs[i], counts[i]); valueUsed += totalPrice; } if (msg.value > valueUsed) { payable(msg.sender).sendValue(msg.value - valueUsed); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITheCoachFunds { function supplyLeftToPremint() external returns (uint256); function preMintAllowance(address addr) external returns (uint256); function preMintAddresses(uint256 index) external returns (address); function paused() external returns (bool); function preMintFor(address addr, uint256 amount) external payable; function getWeiPrice() external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040526004361061001e5760003560e01c806330955b1614610023575b600080fd5b61003d6004803603810190610038919061062e565b61003f565b005b8051825114610083576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161007a90610703565b60405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c53f26706040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101159190610738565b90506000805b845181101561023257600084828151811061013957610138610765565b5b60200260200101518461014c91906107c3565b905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c2f2cd5b8288858151811061019e5761019d610765565b5b60200260200101518886815181106101b9576101b8610765565b5b60200260200101516040518463ffffffff1660e01b81526004016101de92919061083b565b6000604051808303818588803b1580156101f757600080fd5b505af115801561020b573d6000803e3d6000fd5b5050505050808361021c9190610864565b925050808061022a906108ba565b91505061011b565b50803411156102705761026f813461024a9190610903565b3373ffffffffffffffffffffffffffffffffffffffff1661027690919063ffffffff16565b5b50505050565b804710156102b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b090610983565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff16826040516102df906109d4565b60006040518083038185875af1925050503d806000811461031c576040519150601f19603f3d011682016040523d82523d6000602084013e610321565b606091505b5050905080610365576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035c90610a5b565b60405180910390fd5b505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6103cc82610383565b810181811067ffffffffffffffff821117156103eb576103ea610394565b5b80604052505050565b60006103fe61036a565b905061040a82826103c3565b919050565b600067ffffffffffffffff82111561042a57610429610394565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061046b82610440565b9050919050565b61047b81610460565b811461048657600080fd5b50565b60008135905061049881610472565b92915050565b60006104b16104ac8461040f565b6103f4565b905080838252602082019050602084028301858111156104d4576104d361043b565b5b835b818110156104fd57806104e98882610489565b8452602084019350506020810190506104d6565b5050509392505050565b600082601f83011261051c5761051b61037e565b5b813561052c84826020860161049e565b91505092915050565b600067ffffffffffffffff8211156105505761054f610394565b5b602082029050602081019050919050565b6000819050919050565b61057481610561565b811461057f57600080fd5b50565b6000813590506105918161056b565b92915050565b60006105aa6105a584610535565b6103f4565b905080838252602082019050602084028301858111156105cd576105cc61043b565b5b835b818110156105f657806105e28882610582565b8452602084019350506020810190506105cf565b5050509392505050565b600082601f8301126106155761061461037e565b5b8135610625848260208601610597565b91505092915050565b6000806040838503121561064557610644610374565b5b600083013567ffffffffffffffff81111561066357610662610379565b5b61066f85828601610507565b925050602083013567ffffffffffffffff8111156106905761068f610379565b5b61069c85828601610600565b9150509250929050565b600082825260208201905092915050565b7f57726f6e67206c656e6774680000000000000000000000000000000000000000600082015250565b60006106ed600c836106a6565b91506106f8826106b7565b602082019050919050565b6000602082019050818103600083015261071c816106e0565b9050919050565b6000815190506107328161056b565b92915050565b60006020828403121561074e5761074d610374565b5b600061075c84828501610723565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107ce82610561565b91506107d983610561565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561081257610811610794565b5b828202905092915050565b61082681610460565b82525050565b61083581610561565b82525050565b6000604082019050610850600083018561081d565b61085d602083018461082c565b9392505050565b600061086f82610561565b915061087a83610561565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156108af576108ae610794565b5b828201905092915050565b60006108c582610561565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156108f8576108f7610794565b5b600182019050919050565b600061090e82610561565b915061091983610561565b92508282101561092c5761092b610794565b5b828203905092915050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b600061096d601d836106a6565b915061097882610937565b602082019050919050565b6000602082019050818103600083015261099c81610960565b9050919050565b600081905092915050565b50565b60006109be6000836109a3565b91506109c9826109ae565b600082019050919050565b60006109df826109b1565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b6000610a45603a836106a6565b9150610a50826109e9565b604082019050919050565b60006020820190508181036000830152610a7481610a38565b905091905056fea2646970667358221220f8bb6b8892c292dc091e330add3d15564b1ddb342195721638fe3b6754bbe95064736f6c634300080b0033
{"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, 2581, 10354, 2620, 21057, 12879, 2683, 2050, 2629, 19797, 2497, 20958, 2683, 2683, 14142, 2278, 14526, 29097, 18939, 27717, 2094, 2487, 6679, 2575, 2683, 2487, 15878, 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, 19706, 1013, 2009, 5369, 3597, 6776, 11263, 18376, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 3206, 1996, 3597, 6776, 28139, 10020, 3334, 1063, 2478, 4769, 2005, 4769, 3477, 3085, 1025, 2009, 5369, 3597, 6776, 11263, 18376, 2797, 2873, 8663, 6494, 6593, 1025, 9570, 2953, 1006, 4769, 1035, 2873, 8663, 6494, 6593, 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,985
0x97B085C3E19ccEA0691Fb7384010F83c9564a92F
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "./structs/DragonInfo.sol"; import "./access/BaseAccessControl.sol"; import "./DragonToken.sol"; contract DragonCreator is BaseAccessControl { using Address for address; address private _tokenContractAddress; mapping(DragonInfo.Types => uint) private _zeroDragonsIssueLimits; mapping(address => bool) private _giveBirthCallers; bool private _isChangeOfIssueLimitsAllowed; event DragonCreated( uint dragonId, uint eggId, uint parent1Id, uint parent2Id, uint generation, DragonInfo.Types t, uint genes, address indexed creator, address indexed to); constructor(address accessControl, address tknContract) BaseAccessControl(accessControl) { _tokenContractAddress = tknContract; _isChangeOfIssueLimitsAllowed = true; } function tokenContract() public view returns (address) { return _tokenContractAddress; } function isChangeOfIssueLimitsAllowed() public view returns (bool) { return _isChangeOfIssueLimitsAllowed; } function currentIssueLimitFor(DragonInfo.Types _dragonType) external view returns (uint) { return _zeroDragonsIssueLimits[_dragonType]; } function updateIssueLimitFor(DragonInfo.Types _dragonType, uint newValue) external onlyRole(CEO_ROLE) { require(isChangeOfIssueLimitsAllowed(), "DragonCreator: updating the issue limits is not allowed anymore"); _zeroDragonsIssueLimits[_dragonType] = newValue; } function blockUpdatingIssueLimitsForever() external onlyRole(CEO_ROLE) { _isChangeOfIssueLimitsAllowed = false; } function setGiveBirthCallers(address[] calldata callers, bool value) external onlyRole(CEO_ROLE) { for (uint i = 0; i < callers.length; i++) { bool previousValue = _giveBirthCallers[callers[i]]; _giveBirthCallers[callers[i]] = value; emit BoolValueChanged(string(abi.encodePacked("giveBirthCallers.", callers[i])), previousValue, value); } } function issue(uint genes, address to) external onlyRole(CEO_ROLE) returns (uint) { DragonInfo.Types dragonType = DragonInfo.calcType(genes); uint currentLimit = _zeroDragonsIssueLimits[dragonType]; require(dragonType != DragonInfo.Types.Unknown, "DragonCreator: unable to identify a type of the given dragon"); require(currentLimit > 0, "DragonCreator: the issue limit has exceeded"); _zeroDragonsIssueLimits[dragonType] = currentLimit - 1; return _createDragon(0, 0, 0, genes, dragonType, to); } function giveBirth(uint eggId, uint genes, address to) external returns (uint) { require(_giveBirthCallers[_msgSender()], "DragonCreator: not enough privileges to call the method"); return _createDragon(eggId, 0, 0, genes, DragonInfo.Types.Unknown, to); } function giveBirth(uint parent1Id, uint parent2Id, uint genes, address to) external returns (uint) { require(_giveBirthCallers[_msgSender()], "DragonCreator: not enough privileges to call the method"); return _createDragon(0, parent1Id, parent2Id, genes, DragonInfo.Types.Unknown, to); } function _createDragon(uint _eggId, uint _parent1Id, uint _parent2Id, uint _genes, DragonInfo.Types _dragonType, address to) internal returns (uint) { DragonToken dragonToken = DragonToken(tokenContract()); DragonInfo.Details memory parent1Details = dragonToken.dragonInfo(_parent1Id); DragonInfo.Details memory parent2Details = dragonToken.dragonInfo(_parent2Id); if (_parent1Id > 0 && _parent2Id > 0) { //if not 1st-generation dragons require(_parent1Id != _parent2Id, "DragonCreator: parent dragons must be different"); require( parent1Details.dragonType != DragonInfo.Types.Legendary && parent2Details.dragonType != DragonInfo.Types.Legendary, "DragonCreator: neither of the parent dragons can be of Legendary-type" ); require(!dragonToken.isSiblings(_parent1Id, _parent2Id), "DragonCreator: the parent dragons must not be siblings"); require( !dragonToken.isParent(_parent1Id, _parent2Id) && !dragonToken.isParent(_parent2Id, _parent1Id), "DragonCreator: neither of the parent dragons must be a parent or child of another" ); } DragonInfo.Details memory info = DragonInfo.Details({ eggId: _eggId, parent1Id: _parent1Id, parent2Id: _parent2Id, generation: DragonInfo.calcGeneration(parent1Details.generation, parent2Details.generation), dragonType: (_dragonType == DragonInfo.Types.Unknown) ? DragonInfo.calcType(_genes) : _dragonType, strength: 0, //DragonInfo.calcStrength(_genes), genes: _genes }); uint newDragonId = dragonToken.mint(to, info); emit DragonCreated( newDragonId, info.eggId, info.parent1Id, info.parent2Id, info.generation, info.dragonType, info.genes, _msgSender(), to); return newDragonId; } } // 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: GPL-3.0-only pragma solidity ^0.8.0; library DragonInfo { uint constant MASK = 0xF000000000000000000000000; enum Types { Unknown, Common, Rare16, Rare17, Rare18, Rare19, Epic20, Epic21, Epic22, Epic23, Epic24, Legendary } struct Details { uint genes; uint eggId; uint parent1Id; uint parent2Id; uint generation; uint strength; Types dragonType; } function getDetails(uint value) internal pure returns (Details memory) { return Details ( { genes: uint256(uint104(value)), parent1Id: uint256(uint32(value >> 104)), parent2Id: uint256(uint32(value >> 136)), generation: uint256(uint16(value >> 168)), strength: uint256(uint16(value >> 184)), dragonType: Types(uint16(value >> 200)), eggId: uint256(uint32(value >> 216)) } ); } function getValue(Details memory details) internal pure returns (uint) { uint result = uint(details.genes); result |= details.parent1Id << 104; result |= details.parent2Id << 136; result |= details.generation << 168; result |= details.strength << 184; result |= uint(details.dragonType) << 200; result |= details.eggId << 216; return result; } function calcType(uint genes) internal pure returns (Types) { uint mask = MASK; uint numRare = 0; uint numEpic = 0; for (uint i = 0; i < 10; i++) { //just Rare and Epic genes are important to check if (genes & mask > 0) { if (i < 5) { //Epic-range numEpic++; } else { //Rare-range numRare++; } } mask = mask >> 4; } Types result = Types.Unknown; if (numEpic == 5 && numRare == 5) { result = Types.Legendary; } else if (numEpic < 5 && numRare == 5) { result = Types(6 + numEpic); } else if (numEpic == 0 && numRare < 5) { result = Types(1 + numRare); } else if (numEpic == 0 && numRare == 0) { result = Types.Common; } return result; } function calcStrength(uint genes) internal pure returns (uint) { uint mask = MASK; uint strength = 0; for (uint i = 0; i < 25; i++) { uint gLevel = (genes & mask) >> ((24 - i) * 4); if (i < 6) { //Epic strength += 3 * (25 - i) * gLevel; } else if (i < 10) { //Rare strength += 2 * (25 - i) * gLevel; } else { //Common-range if (gLevel > 0) { strength += (25 - i) * gLevel; } else { strength += (25 - i); } } mask = mask >> 4; } return strength; } function calcGeneration(uint g1, uint g2) internal pure returns (uint) { return (g1 >= g2 ? g1 : g2) + 1; } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/IAccessControl.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "../interfaces/IChangeableVariables.sol"; abstract contract BaseAccessControl is Context, IChangeableVariables { bytes32 public constant CEO_ROLE = keccak256("CEO"); bytes32 public constant CFO_ROLE = keccak256("CFO"); bytes32 public constant COO_ROLE = keccak256("COO"); address private _accessControl; modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } constructor (address accessControl) Context() { _accessControl = accessControl; } function accessControlAddress() public view returns (address) { return _accessControl; } function setAccessControlAddress(address newAddress) external onlyRole(CEO_ROLE) { address previousAddress = _accessControl; _accessControl = newAddress; emit AddressChanged("accessControl", previousAddress, newAddress); } function hasRole(bytes32 role, address account) public view returns (bool) { return IAccessControl(accessControlAddress()).hasRole(role, account); } 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) ) ) ); } } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./structs/DragonInfo.sol"; import "./access/BaseAccessControl.sol"; contract DragonToken is ERC721, BaseAccessControl { using Address for address; using Counters for Counters.Counter; Counters.Counter private _dragonIds; // Mapping token id to dragon details mapping(uint => uint) private _info; // Mapping token id to cid mapping(uint => string) private _cids; string private _defaultMetadataCid; address private _dragonCreator; constructor(string memory defaultCid, address accessControl) ERC721("CryptoDragons", "CD") BaseAccessControl(accessControl) { _defaultMetadataCid = defaultCid; } function tokenURI(uint tokenId) public view virtual override returns (string memory) { string memory cid = _cids[tokenId]; return string(abi.encodePacked("ipfs://", (bytes(cid).length > 0) ? cid : defaultMetadataCid())); } function dragonCreatorAddress() public view returns(address) { return _dragonCreator; } function setDragonCreatorAddress(address newAddress) external onlyRole(CEO_ROLE) { address previousAddress = _dragonCreator; _dragonCreator = newAddress; emit AddressChanged("dragonCreator", previousAddress, newAddress); } function hasMetadataCid(uint tokenId) public view returns(bool) { return bytes(_cids[tokenId]).length > 0; } function setMetadataCid(uint tokenId, string calldata cid) external onlyRole(COO_ROLE) { require(bytes(cid).length >= 46, "DragonToken: bad CID"); require(!hasMetadataCid(tokenId), "DragonToken: CID is already set"); _cids[tokenId] = cid; } function defaultMetadataCid() public view returns (string memory){ return _defaultMetadataCid; } function setDefaultMetadataCid(string calldata newDefaultCid) external onlyRole(COO_ROLE) { _defaultMetadataCid = newDefaultCid; } function dragonInfo(uint dragonId) public view returns (DragonInfo.Details memory) { return DragonInfo.getDetails(_info[dragonId]); } function strengthOf(uint dragonId) external view returns (uint) { DragonInfo.Details memory details = dragonInfo(dragonId); return details.strength > 0 ? details.strength : DragonInfo.calcStrength(details.genes); } function isSiblings(uint dragon1Id, uint dragon2Id) external view returns (bool) { DragonInfo.Details memory info1 = dragonInfo(dragon1Id); DragonInfo.Details memory info2 = dragonInfo(dragon2Id); return (info1.generation > 1 && info2.generation > 1) && //the 1st generation of dragons doesn't have siblings (info1.parent1Id == info2.parent1Id || info1.parent1Id == info2.parent2Id || info1.parent2Id == info2.parent1Id || info1.parent2Id == info2.parent2Id); } function isParent(uint dragon1Id, uint dragon2Id) external view returns (bool) { DragonInfo.Details memory info = dragonInfo(dragon1Id); return info.parent1Id == dragon2Id || info.parent2Id == dragon2Id; } function mint(address to, DragonInfo.Details calldata info) external returns (uint) { require(_msgSender() == dragonCreatorAddress(), "DragonToken: not enough privileges to call the method"); _dragonIds.increment(); uint newDragonId = uint(_dragonIds.current()); _info[newDragonId] = DragonInfo.getValue(info); _mint(to, newDragonId); return newDragonId; } function setStrength(uint dragonId) external returns (uint) { DragonInfo.Details memory details = dragonInfo(dragonId); if (details.strength == 0) { details.strength = DragonInfo.calcStrength(details.genes); _info[dragonId] = DragonInfo.getValue(details); } return details.strength; } } // 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 Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.0; interface IChangeableVariables { event AddressChanged(string indexed fieldName, address previousAddress, address newAddress); event ValueChanged(string indexed fieldName, uint previousValue, uint newValue); event BoolValueChanged(string indexed fieldName, bool previousValue, bool newValue); } // 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; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636674137711610097578063b514be6311610066578063b514be6314610262578063b696a6ad14610280578063d22748ad146102b0578063e8d56b8b146102e0576100f5565b806366741377146101da57806390e96055146101f857806391d14854146102145780639f6f50ed14610244576100f5565b80634baa042b116100d35780634baa042b1461017857806355a373d6146101825780635cac7c66146101a05780635cd8ba93146101be576100f5565b80630f3578a6146100fa57806337a3191f1461012a5780633acfd44f1461015a575b600080fd5b610114600480360381019061010f9190611d3a565b6102fc565b60405161012191906126e4565b60405180910390f35b610144600480360381019061013f9190611d89565b6103aa565b60405161015191906126e4565b60405180910390f35b610162610459565b60405161016f919061255e565b60405180910390f35b61018061047d565b005b61018a6104cd565b60405161019791906124ac565b60405180910390f35b6101a86104f7565b6040516101b5919061251a565b60405180910390f35b6101d860048036038101906101d39190611b8a565b61050e565b005b6101e2610766565b6040516101ef91906124ac565b60405180910390f35b610212600480360381019061020d9190611c70565b61078f565b005b61022e60048036038101906102299190611c0b565b610895565b60405161023b919061251a565b60405180910390f35b61024c610931565b604051610259919061255e565b60405180910390f35b61026a610955565b604051610277919061255e565b60405180910390f35b61029a60048036038101906102959190611cfe565b610979565b6040516102a791906126e4565b60405180910390f35b6102ca60048036038101906102c59190611c47565b610be8565b6040516102d791906126e4565b60405180910390f35b6102fa60048036038101906102f59190611b61565b610c75565b005b60006003600061030a610d5f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610391576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038890612664565b60405180910390fd5b6103a18460008086600087610d67565b90509392505050565b6000600360006103b8610d5f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661043f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161043690612664565b60405180910390fd5b61044f6000868686600087610d67565b9050949350505050565b7fefa080c67ecf4a6bf40c9dc64173420c08f359250ca6562d7c80f7c7b9b1396981565b7fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d6104af816104aa610d5f565b611483565b6000600460006101000a81548160ff02191690831515021790555050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600460009054906101000a900460ff16905090565b7fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d6105408161053b610d5f565b611483565b60005b8484905081101561075f5760006003600087878581811061058d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906105a29190611b61565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050836003600088888681811061062a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b905060200201602081019061063f9190611b61565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508585838181106106c9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906106de9190611b61565b6040516020016106ee919061244c565b60405160208183030381529060405260405161070a9190612420565b60405180910390207f75f7d2b2b518c211d497b8c43d377c070369e88b66bfccc77c038dc5922e97028286604051610743929190612535565b60405180910390a2508080610757906129a7565b915050610543565b5050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d6107c1816107bc610d5f565b611483565b6107c96104f7565b610808576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ff90612604565b60405180910390fd5b816002600085600b811115610846577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600b81111561087e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815260200190815260200160002081905550505050565b600061089f610766565b73ffffffffffffffffffffffffffffffffffffffff166391d1485484846040518363ffffffff1660e01b81526004016108d9929190612579565b60206040518083038186803b1580156108f157600080fd5b505afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190611be2565b905092915050565b7f33fa24d9aab6b79237248a16094d5f78ea83bb51e42c123ce925a264e7d816cc81565b7fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d81565b60007fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d6109ad816109a8610d5f565b611483565b60006109b885611520565b905060006002600083600b8111156109f9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600b811115610a31577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b81526020019081526020016000205490506000600b811115610a7c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b82600b811115610ab5577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b1415610af6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aed90612684565b60405180910390fd5b60008111610b39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3090612624565b60405180910390fd5b600181610b46919061289f565b6002600084600b811115610b83577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600b811115610bbb577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815260200190815260200160002081905550610bdd600080600089868a610d67565b935050505092915050565b60006002600083600b811115610c27577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600b811115610c5f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8152602001908152602001600020549050919050565b7fdc0d7a095c4e917ecbeb7deda7c942ff9744013d419e37549215a413915e421d610ca781610ca2610d5f565b611483565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051610d1990612437565b60405180910390207f4ca142703425bec1d507d5581fac3a3e61eadcbeafbd7c0a03e2897d96de1cc58285604051610d529291906124c7565b60405180910390a2505050565b600033905090565b600080610d726104cd565b905060008173ffffffffffffffffffffffffffffffffffffffff1663225b38fd896040518263ffffffff1660e01b8152600401610daf91906126e4565b60e06040518083038186803b158015610dc757600080fd5b505afa158015610ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dff9190611cac565b905060008273ffffffffffffffffffffffffffffffffffffffff1663225b38fd896040518263ffffffff1660e01b8152600401610e3c91906126e4565b60e06040518083038186803b158015610e5457600080fd5b505afa158015610e68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8c9190611cac565b9050600089118015610e9e5750600088115b156112485787891415610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90612644565b60405180910390fd5b600b80811115610f1f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8260c00151600b811115610f5c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b14158015610fde5750600b80811115610f9e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8160c00151600b811115610fdb577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b14155b61101d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611014906126c4565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663e2098fe28a8a6040518363ffffffff1660e01b81526004016110589291906126ff565b60206040518083038186803b15801561107057600080fd5b505afa158015611084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a89190611be2565b156110e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110df906126a4565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663c075f2c18a8a6040518363ffffffff1660e01b81526004016111239291906126ff565b60206040518083038186803b15801561113b57600080fd5b505afa15801561114f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111739190611be2565b15801561120857508273ffffffffffffffffffffffffffffffffffffffff1663c075f2c1898b6040518363ffffffff1660e01b81526004016111b69291906126ff565b60206040518083038186803b1580156111ce57600080fd5b505afa1580156111e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112069190611be2565b155b611247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123e906125e4565b60405180910390fd5b5b60006040518060e001604052808981526020018c81526020018b81526020018a815260200161127f8560800151856080015161169f565b8152602001600081526020016000600b8111156112c5577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b89600b8111156112fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b146113095788611313565b6113128a611520565b5b600b81111561134b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815250905060008473ffffffffffffffffffffffffffffffffffffffff166337b5953588846040518363ffffffff1660e01b815260040161138d9291906124f0565b602060405180830381600087803b1580156113a757600080fd5b505af11580156113bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113df9190611cd5565b90508673ffffffffffffffffffffffffffffffffffffffff16611400610d5f565b73ffffffffffffffffffffffffffffffffffffffff167f30c3ef581371c1f32a51a227038345b13000b518164478749ef983a91f8466b28385602001518660400151876060015188608001518960c001518a600001516040516114699796959493929190612728565b60405180910390a380955050505050509695505050505050565b61148d8282610895565b61151c576114b28173ffffffffffffffffffffffffffffffffffffffff1660146116c5565b6114c08360001c60206116c5565b6040516020016114d1929190612472565b6040516020818303038152906040526040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151391906125a2565b60405180910390fd5b5050565b6000806c0f000000000000000000000000905060008060005b600a8110156115935760008487161115611579576005811015611569578180611561906129a7565b925050611578565b8280611574906129a7565b9350505b5b600484901c9350808061158b906129a7565b915050611539565b5060006005821480156115a65750600583145b156115b457600b9050611693565b6005821080156115c45750600583145b15611615578160066115d691906127ef565b600b81111561160e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9050611692565b6000821480156116255750600583105b156116765782600161163791906127ef565b600b81111561166f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9050611691565b6000821480156116865750600083145b1561169057600190505b5b5b5b80945050505050919050565b60006001828410156116b157826116b3565b835b6116bd91906127ef565b905092915050565b6060600060028360026116d89190612845565b6116e291906127ef565b67ffffffffffffffff811115611721577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156117535781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106117b1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061183b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261187b9190612845565b61188591906127ef565b90505b6001811115611971577f3031323334353637383961626364656600000000000000000000000000000000600f8616601081106118ed577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b82828151811061192a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c94508061196a9061297d565b9050611888565b50600084146119b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ac906125c4565b60405180910390fd5b8091505092915050565b6000813590506119ce81612ad3565b92915050565b60008083601f8401126119e657600080fd5b8235905067ffffffffffffffff8111156119ff57600080fd5b602083019150836020820283011115611a1757600080fd5b9250929050565b600081359050611a2d81612aea565b92915050565b600081519050611a4281612aea565b92915050565b600081359050611a5781612b01565b92915050565b600081359050611a6c81612b18565b92915050565b600081519050611a8181612b18565b92915050565b600060e08284031215611a9957600080fd5b611aa360e0612797565b90506000611ab384828501611b4c565b6000830152506020611ac784828501611b4c565b6020830152506040611adb84828501611b4c565b6040830152506060611aef84828501611b4c565b6060830152506080611b0384828501611b4c565b60808301525060a0611b1784828501611b4c565b60a08301525060c0611b2b84828501611a72565b60c08301525092915050565b600081359050611b4681612b28565b92915050565b600081519050611b5b81612b28565b92915050565b600060208284031215611b7357600080fd5b6000611b81848285016119bf565b91505092915050565b600080600060408486031215611b9f57600080fd5b600084013567ffffffffffffffff811115611bb957600080fd5b611bc5868287016119d4565b93509350506020611bd886828701611a1e565b9150509250925092565b600060208284031215611bf457600080fd5b6000611c0284828501611a33565b91505092915050565b60008060408385031215611c1e57600080fd5b6000611c2c85828601611a48565b9250506020611c3d858286016119bf565b9150509250929050565b600060208284031215611c5957600080fd5b6000611c6784828501611a5d565b91505092915050565b60008060408385031215611c8357600080fd5b6000611c9185828601611a5d565b9250506020611ca285828601611b37565b9150509250929050565b600060e08284031215611cbe57600080fd5b6000611ccc84828501611a87565b91505092915050565b600060208284031215611ce757600080fd5b6000611cf584828501611b4c565b91505092915050565b60008060408385031215611d1157600080fd5b6000611d1f85828601611b37565b9250506020611d30858286016119bf565b9150509250929050565b600080600060608486031215611d4f57600080fd5b6000611d5d86828701611b37565b9350506020611d6e86828701611b37565b9250506040611d7f868287016119bf565b9150509250925092565b60008060008060808587031215611d9f57600080fd5b6000611dad87828801611b37565b9450506020611dbe87828801611b37565b9350506040611dcf87828801611b37565b9250506060611de0878288016119bf565b91505092959194509250565b611df5816128d3565b82525050565b611e0c611e07826128d3565b6129f0565b82525050565b611e1b816128e5565b82525050565b611e2a816128f1565b82525050565b611e3981612938565b82525050565b611e4881612938565b82525050565b6000611e59826127c8565b611e6381856127d3565b9350611e7381856020860161294a565b611e7c81612aa1565b840191505092915050565b6000611e92826127c8565b611e9c81856127e4565b9350611eac81856020860161294a565b80840191505092915050565b6000611ec56020836127d3565b91507f537472696e67733a20686578206c656e67746820696e73756666696369656e746000830152602082019050919050565b6000611f05600d836127e4565b91507f616363657373436f6e74726f6c000000000000000000000000000000000000006000830152600d82019050919050565b6000611f456051836127d3565b91507f447261676f6e43726561746f723a206e656974686572206f662074686520706160008301527f72656e7420647261676f6e73206d757374206265206120706172656e74206f7260208301527f206368696c64206f6620616e6f746865720000000000000000000000000000006040830152606082019050919050565b6000611fd16011836127e4565b91507f67697665426972746843616c6c6572732e0000000000000000000000000000006000830152601182019050919050565b6000612011603f836127d3565b91507f447261676f6e43726561746f723a207570646174696e6720746865206973737560008301527f65206c696d697473206973206e6f7420616c6c6f77656420616e796d6f7265006020830152604082019050919050565b6000612077602b836127d3565b91507f447261676f6e43726561746f723a20746865206973737565206c696d6974206860008301527f61732065786365656465640000000000000000000000000000000000000000006020830152604082019050919050565b60006120dd602f836127d3565b91507f447261676f6e43726561746f723a20706172656e7420647261676f6e73206d7560008301527f737420626520646966666572656e7400000000000000000000000000000000006020830152604082019050919050565b60006121436037836127d3565b91507f447261676f6e43726561746f723a206e6f7420656e6f7567682070726976696c60008301527f6567657320746f2063616c6c20746865206d6574686f640000000000000000006020830152604082019050919050565b60006121a9603c836127d3565b91507f447261676f6e43726561746f723a20756e61626c6520746f206964656e74696660008301527f7920612074797065206f662074686520676976656e20647261676f6e000000006020830152604082019050919050565b600061220f6036836127d3565b91507f447261676f6e43726561746f723a2074686520706172656e7420647261676f6e60008301527f73206d757374206e6f74206265207369626c696e6773000000000000000000006020830152604082019050919050565b60006122756045836127d3565b91507f447261676f6e43726561746f723a206e656974686572206f662074686520706160008301527f72656e7420647261676f6e732063616e206265206f66204c6567656e6461727960208301527f2d747970650000000000000000000000000000000000000000000000000000006040830152606082019050919050565b60006123016017836127e4565b91507f416363657373436f6e74726f6c3a206163636f756e74200000000000000000006000830152601782019050919050565b60006123416011836127e4565b91507f206973206d697373696e6720726f6c65200000000000000000000000000000006000830152601182019050919050565b60e08201600082015161238a6000850182612402565b50602082015161239d6020850182612402565b5060408201516123b06040850182612402565b5060608201516123c36060850182612402565b5060808201516123d66080850182612402565b5060a08201516123e960a0850182612402565b5060c08201516123fc60c0850182611e30565b50505050565b61240b8161292e565b82525050565b61241a8161292e565b82525050565b600061242c8284611e87565b915081905092915050565b600061244282611ef8565b9150819050919050565b600061245782611fc4565b91506124638284611dfb565b60148201915081905092915050565b600061247d826122f4565b91506124898285611e87565b915061249482612334565b91506124a08284611e87565b91508190509392505050565b60006020820190506124c16000830184611dec565b92915050565b60006040820190506124dc6000830185611dec565b6124e96020830184611dec565b9392505050565b6000610100820190506125066000830185611dec565b6125136020830184612374565b9392505050565b600060208201905061252f6000830184611e12565b92915050565b600060408201905061254a6000830185611e12565b6125576020830184611e12565b9392505050565b60006020820190506125736000830184611e21565b92915050565b600060408201905061258e6000830185611e21565b61259b6020830184611dec565b9392505050565b600060208201905081810360008301526125bc8184611e4e565b905092915050565b600060208201905081810360008301526125dd81611eb8565b9050919050565b600060208201905081810360008301526125fd81611f38565b9050919050565b6000602082019050818103600083015261261d81612004565b9050919050565b6000602082019050818103600083015261263d8161206a565b9050919050565b6000602082019050818103600083015261265d816120d0565b9050919050565b6000602082019050818103600083015261267d81612136565b9050919050565b6000602082019050818103600083015261269d8161219c565b9050919050565b600060208201905081810360008301526126bd81612202565b9050919050565b600060208201905081810360008301526126dd81612268565b9050919050565b60006020820190506126f96000830184612411565b92915050565b60006040820190506127146000830185612411565b6127216020830184612411565b9392505050565b600060e08201905061273d600083018a612411565b61274a6020830189612411565b6127576040830188612411565b6127646060830187612411565b6127716080830186612411565b61277e60a0830185611e3f565b61278b60c0830184612411565b98975050505050505050565b6000604051905081810181811067ffffffffffffffff821117156127be576127bd612a72565b5b8060405250919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b60006127fa8261292e565b91506128058361292e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561283a57612839612a14565b5b828201905092915050565b60006128508261292e565b915061285b8361292e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561289457612893612a14565b5b828202905092915050565b60006128aa8261292e565b91506128b58361292e565b9250828210156128c8576128c7612a14565b5b828203905092915050565b60006128de8261290e565b9050919050565b60008115159050919050565b6000819050919050565b600081905061290982612abf565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612943826128fb565b9050919050565b60005b8381101561296857808201518184015260208101905061294d565b83811115612977576000848401525b50505050565b60006129888261292e565b9150600082141561299c5761299b612a14565b5b600182039050919050565b60006129b28261292e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156129e5576129e4612a14565b5b600182019050919050565b60006129fb82612a02565b9050919050565b6000612a0d82612ab2565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600c8110612ad057612acf612a43565b5b50565b612adc816128d3565b8114612ae757600080fd5b50565b612af3816128e5565b8114612afe57600080fd5b50565b612b0a816128f1565b8114612b1557600080fd5b50565b600c8110612b2557600080fd5b50565b612b318161292e565b8114612b3c57600080fd5b5056fea2646970667358221220f9751135ccbb134c7fab6ef94f1ca2490bcd5d913b131597858a3760190dee0264736f6c63430008000033
{"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, 2581, 2497, 2692, 27531, 2278, 2509, 2063, 16147, 9468, 5243, 2692, 2575, 2683, 2487, 26337, 2581, 22025, 12740, 10790, 2546, 2620, 2509, 2278, 2683, 26976, 2549, 2050, 2683, 2475, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2069, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 2358, 6820, 16649, 1013, 5202, 2378, 14876, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 3229, 1013, 2918, 6305, 9623, 9363, 3372, 13153, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 5202, 18715, 2368, 1012, 14017, 1000, 1025, 3206, 5202, 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,986
0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11
pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; /** * @title InstaConnectorsV2 * @dev Registry for Connectors. */ interface IndexInterface { function master() external view returns (address); } interface ConnectorInterface { function name() external view returns (string memory); } contract Controllers { event LogController(address indexed addr, bool indexed isChief); // InstaIndex Address. address public immutable instaIndex; constructor(address _instaIndex) { instaIndex = _instaIndex; } // Enabled Chief(Address of Chief => bool). mapping(address => bool) public chief; // Enabled Connectors(Connector name => address). mapping(string => address) public connectors; /** * @dev Throws if the sender not is Master Address from InstaIndex * or Enabled Chief. */ modifier isChief { require(chief[msg.sender] || msg.sender == IndexInterface(instaIndex).master(), "not-an-chief"); _; } /** * @dev Toggle a Chief. Enable if disable & vice versa * @param _chiefAddress Chief Address. */ function toggleChief(address _chiefAddress) external { require(msg.sender == IndexInterface(instaIndex).master(), "toggleChief: not-master"); chief[_chiefAddress] = !chief[_chiefAddress]; emit LogController(_chiefAddress, chief[_chiefAddress]); } } contract InstaConnectorsV2 is Controllers { event LogConnectorAdded( bytes32 indexed connectorNameHash, string connectorName, address indexed connector ); event LogConnectorUpdated( bytes32 indexed connectorNameHash, string connectorName, address indexed oldConnector, address indexed newConnector ); event LogConnectorRemoved( bytes32 indexed connectorNameHash, string connectorName, address indexed connector ); constructor(address _instaIndex) public Controllers(_instaIndex) {} /** * @dev Add Connectors * @param _connectorNames Array of Connector Names. * @param _connectors Array of Connector Address. */ function addConnectors(string[] calldata _connectorNames, address[] calldata _connectors) external isChief { require(_connectors.length == _connectors.length, "addConnectors: not same length"); for (uint i = 0; i < _connectors.length; i++) { require(connectors[_connectorNames[i]] == address(0), "addConnectors: _connectorName added already"); require(_connectors[i] != address(0), "addConnectors: _connectors address not vaild"); ConnectorInterface(_connectors[i]).name(); // Checking if connector has function name() connectors[_connectorNames[i]] = _connectors[i]; emit LogConnectorAdded(keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], _connectors[i]); } } /** * @dev Update Connectors * @param _connectorNames Array of Connector Names. * @param _connectors Array of Connector Address. */ function updateConnectors(string[] calldata _connectorNames, address[] calldata _connectors) external isChief { require(_connectorNames.length == _connectors.length, "updateConnectors: not same length"); for (uint i = 0; i < _connectors.length; i++) { require(connectors[_connectorNames[i]] != address(0), "updateConnectors: _connectorName not added to update"); require(_connectors[i] != address(0), "updateConnectors: _connector address is not vaild"); ConnectorInterface(_connectors[i]).name(); // Checking if connector has function name() emit LogConnectorUpdated(keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], connectors[_connectorNames[i]], _connectors[i]); connectors[_connectorNames[i]] = _connectors[i]; } } /** * @dev Remove Connectors * @param _connectorNames Array of Connector Names. */ function removeConnectors(string[] calldata _connectorNames) external isChief { for (uint i = 0; i < _connectorNames.length; i++) { require(connectors[_connectorNames[i]] != address(0), "removeConnectors: _connectorName not added to update"); emit LogConnectorRemoved(keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], connectors[_connectorNames[i]]); delete connectors[_connectorNames[i]]; } } /** * @dev Check if Connector addresses are enabled. * @param _connectors Array of Connector Names. */ function isConnectors(string[] calldata _connectorNames) external view returns (bool isOk, address[] memory _connectors) { isOk = true; uint len = _connectorNames.length; _connectors = new address[](len); for (uint i = 0; i < _connectors.length; i++) { _connectors[i] = connectors[_connectorNames[i]]; if (_connectors[i] == address(0)) { isOk = false; break; } } } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80636b1056ae1161005b5780636b1056ae146101115780637a5058c314610141578063a0a32c0b1461015d578063a41098bf1461018e57610088565b80630595272a1461008d5780630c17b2a7146100a9578063102c0ffe146100c557806326f9047a146100e1575b600080fd5b6100a760048036038101906100a29190611676565b6101ac565b005b6100c360048036038101906100be9190611676565b610753565b005b6100df60048036038101906100da91906115df565b610c86565b005b6100fb60048036038101906100f691906116eb565b610ec7565b6040516101089190611b9f565b60405180910390f35b61012b600480360381019061012691906115df565b610f10565b6040516101389190611bba565b60405180910390f35b61015b60048036038101906101569190611631565b610f30565b005b61017760048036038101906101729190611631565b6112e6565b604051610185929190611bd5565b60405180910390f35b610196611455565b6040516101a39190611b9f565b60405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806102cb57507f0000000000000000000000002971adfa57b20e5a416ae5a708a8655a9c74f72373ffffffffffffffffffffffffffffffffffffffff1663ee97f7f36040518163ffffffff1660e01b815260040160206040518083038186803b15801561026457600080fd5b505afa158015610278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061029c9190611608565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61030a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030190611c29565b60405180910390fd5b818190508484905014610352576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034990611d29565b60405180910390fd5b60005b8282905081101561074c57600073ffffffffffffffffffffffffffffffffffffffff16600186868481811061038657fe5b90506020028101906103989190611d49565b6040516103a6929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561042c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042390611c89565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1683838381811061045057fe5b905060200201602081019061046591906115df565b73ffffffffffffffffffffffffffffffffffffffff1614156104bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104b390611ce9565b60405180910390fd5b8282828181106104c857fe5b90506020020160208101906104dd91906115df565b73ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561052257600080fd5b505afa158015610536573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061055f919061172c565b5082828281811061056c57fe5b905060200201602081019061058191906115df565b73ffffffffffffffffffffffffffffffffffffffff1660018686848181106105a557fe5b90506020028101906105b79190611d49565b6040516105c5929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1686868481811061061657fe5b90506020028101906106289190611d49565b604051602001610639929190611b86565b604051602081830303815290604052805190602001207f62c84f1d09bf60d3e3072d28fdf70fe9f97d35404ef16afed9cad977566e72dc88888681811061067c57fe5b905060200281019061068e9190611d49565b60405161069c929190611c05565b60405180910390a48282828181106106b057fe5b90506020020160208101906106c591906115df565b60018686848181106106d357fe5b90506020028101906106e59190611d49565b6040516106f3929190611b86565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508080600101915050610355565b5050505050565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061087257507f0000000000000000000000002971adfa57b20e5a416ae5a708a8655a9c74f72373ffffffffffffffffffffffffffffffffffffffff1663ee97f7f36040518163ffffffff1660e01b815260040160206040518083038186803b15801561080b57600080fd5b505afa15801561081f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108439190611608565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6108b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a890611c29565b60405180910390fd5b8181905082829050146108f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f090611c69565b60405180910390fd5b60005b82829050811015610c7f57600073ffffffffffffffffffffffffffffffffffffffff16600186868481811061092d57fe5b905060200281019061093f9190611d49565b60405161094d929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c990611c49565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168383838181106109f657fe5b9050602002016020810190610a0b91906115df565b73ffffffffffffffffffffffffffffffffffffffff161415610a62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5990611ca9565b60405180910390fd5b828282818110610a6e57fe5b9050602002016020810190610a8391906115df565b73ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b158015610ac857600080fd5b505afa158015610adc573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610b05919061172c565b50828282818110610b1257fe5b9050602002016020810190610b2791906115df565b6001868684818110610b3557fe5b9050602002810190610b479190611d49565b604051610b55929190611b86565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550828282818110610bad57fe5b9050602002016020810190610bc291906115df565b73ffffffffffffffffffffffffffffffffffffffff16858583818110610be457fe5b9050602002810190610bf69190611d49565b604051602001610c07929190611b86565b604051602081830303815290604052805190602001207fd5f66ff1a09f5892b7170494d8082e4a64a3d903843d7a3cf439c0d0643a129b878785818110610c4a57fe5b9050602002810190610c5c9190611d49565b604051610c6a929190611c05565b60405180910390a380806001019150506108fc565b5050505050565b7f0000000000000000000000002971adfa57b20e5a416ae5a708a8655a9c74f72373ffffffffffffffffffffffffffffffffffffffff1663ee97f7f36040518163ffffffff1660e01b815260040160206040518083038186803b158015610cec57600080fd5b505afa158015610d00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d249190611608565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8890611d09565b60405180910390fd5b6000808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615158173ffffffffffffffffffffffffffffffffffffffff167f6033a9a2a67d8058b7f983c0785fb0f08b24e0cd7d345b30e3b3c63561b8bfdd60405160405180910390a350565b6001818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006020528060005260406000206000915054906101000a900460ff1681565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061104f57507f0000000000000000000000002971adfa57b20e5a416ae5a708a8655a9c74f72373ffffffffffffffffffffffffffffffffffffffff1663ee97f7f36040518163ffffffff1660e01b815260040160206040518083038186803b158015610fe857600080fd5b505afa158015610ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110209190611608565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61108e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108590611c29565b60405180910390fd5b60005b828290508110156112e157600073ffffffffffffffffffffffffffffffffffffffff1660018484848181106110c257fe5b90506020028101906110d49190611d49565b6040516110e2929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611168576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115f90611cc9565b60405180910390fd5b600183838381811061117657fe5b90506020028101906111889190611d49565b604051611196929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168383838181106111e757fe5b90506020028101906111f99190611d49565b60405160200161120a929190611b86565b604051602081830303815290604052805190602001207f8ef7e58f2570b54253b8a1287bf238cbc3bb5f34c32b15ee8fd58bd3a250bd7485858581811061124d57fe5b905060200281019061125f9190611d49565b60405161126d929190611c05565b60405180910390a3600183838381811061128357fe5b90506020028101906112959190611d49565b6040516112a3929190611b86565b908152602001604051809103902060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690558080600101915050611091565b505050565b600060606001915060008484905090508067ffffffffffffffff8111801561130d57600080fd5b5060405190808252806020026020018201604052801561133c5781602001602082028036833780820191505090505b50915060005b825181101561144c57600186868381811061135957fe5b905060200281019061136b9190611d49565b604051611379929190611b86565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168382815181106113b457fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600073ffffffffffffffffffffffffffffffffffffffff1683828151811061141257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141561143f576000935061144c565b8080600101915050611342565b50509250929050565b7f0000000000000000000000002971adfa57b20e5a416ae5a708a8655a9c74f72381565b60008135905061148881611edf565b92915050565b60008151905061149d81611edf565b92915050565b60008083601f8401126114b557600080fd5b8235905067ffffffffffffffff8111156114ce57600080fd5b6020830191508360208202830111156114e657600080fd5b9250929050565b60008083601f8401126114ff57600080fd5b8235905067ffffffffffffffff81111561151857600080fd5b60208301915083602082028301111561153057600080fd5b9250929050565b600082601f83011261154857600080fd5b813561155b61155682611dcd565b611da0565b9150808252602083016020830185838301111561157757600080fd5b611582838284611e8c565b50505092915050565b600082601f83011261159c57600080fd5b81516115af6115aa82611dcd565b611da0565b915080825260208301602083018583830111156115cb57600080fd5b6115d6838284611e9b565b50505092915050565b6000602082840312156115f157600080fd5b60006115ff84828501611479565b91505092915050565b60006020828403121561161a57600080fd5b60006116288482850161148e565b91505092915050565b6000806020838503121561164457600080fd5b600083013567ffffffffffffffff81111561165e57600080fd5b61166a858286016114ed565b92509250509250929050565b6000806000806040858703121561168c57600080fd5b600085013567ffffffffffffffff8111156116a657600080fd5b6116b2878288016114ed565b9450945050602085013567ffffffffffffffff8111156116d157600080fd5b6116dd878288016114a3565b925092505092959194509250565b6000602082840312156116fd57600080fd5b600082013567ffffffffffffffff81111561171757600080fd5b61172384828501611537565b91505092915050565b60006020828403121561173e57600080fd5b600082015167ffffffffffffffff81111561175857600080fd5b6117648482850161158b565b91505092915050565b60006117798383611785565b60208301905092915050565b61178e81611e4e565b82525050565b61179d81611e4e565b82525050565b60006117ae82611e09565b6117b88185611e21565b93506117c383611df9565b8060005b838110156117f45781516117db888261176d565b97506117e683611e14565b9250506001810190506117c7565b5085935050505092915050565b61180a81611e60565b82525050565b600061181c8385611e32565b9350611829838584611e8c565b61183283611ece565b840190509392505050565b60006118498385611e43565b9350611856838584611e8c565b82840190509392505050565b600061186f600c83611e32565b91507f6e6f742d616e2d636869656600000000000000000000000000000000000000006000830152602082019050919050565b60006118af602b83611e32565b91507f616464436f6e6e6563746f72733a205f636f6e6e6563746f724e616d6520616460008301527f64656420616c72656164790000000000000000000000000000000000000000006020830152604082019050919050565b6000611915601e83611e32565b91507f616464436f6e6e6563746f72733a206e6f742073616d65206c656e67746800006000830152602082019050919050565b6000611955603483611e32565b91507f757064617465436f6e6e6563746f72733a205f636f6e6e6563746f724e616d6560008301527f206e6f7420616464656420746f207570646174650000000000000000000000006020830152604082019050919050565b60006119bb602c83611e32565b91507f616464436f6e6e6563746f72733a205f636f6e6e6563746f727320616464726560008301527f7373206e6f74207661696c6400000000000000000000000000000000000000006020830152604082019050919050565b6000611a21603483611e32565b91507f72656d6f7665436f6e6e6563746f72733a205f636f6e6e6563746f724e616d6560008301527f206e6f7420616464656420746f207570646174650000000000000000000000006020830152604082019050919050565b6000611a87603183611e32565b91507f757064617465436f6e6e6563746f72733a205f636f6e6e6563746f722061646460008301527f72657373206973206e6f74207661696c640000000000000000000000000000006020830152604082019050919050565b6000611aed601783611e32565b91507f746f67676c6543686965663a206e6f742d6d61737465720000000000000000006000830152602082019050919050565b6000611b2d602183611e32565b91507f757064617465436f6e6e6563746f72733a206e6f742073616d65206c656e677460008301527f68000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611b9382848661183d565b91508190509392505050565b6000602082019050611bb46000830184611794565b92915050565b6000602082019050611bcf6000830184611801565b92915050565b6000604082019050611bea6000830185611801565b8181036020830152611bfc81846117a3565b90509392505050565b60006020820190508181036000830152611c20818486611810565b90509392505050565b60006020820190508181036000830152611c4281611862565b9050919050565b60006020820190508181036000830152611c62816118a2565b9050919050565b60006020820190508181036000830152611c8281611908565b9050919050565b60006020820190508181036000830152611ca281611948565b9050919050565b60006020820190508181036000830152611cc2816119ae565b9050919050565b60006020820190508181036000830152611ce281611a14565b9050919050565b60006020820190508181036000830152611d0281611a7a565b9050919050565b60006020820190508181036000830152611d2281611ae0565b9050919050565b60006020820190508181036000830152611d4281611b20565b9050919050565b60008083356001602003843603038112611d6257600080fd5b80840192508235915067ffffffffffffffff821115611d8057600080fd5b602083019250600182023603831315611d9857600080fd5b509250929050565b6000604051905081810181811067ffffffffffffffff82111715611dc357600080fd5b8060405250919050565b600067ffffffffffffffff821115611de457600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000611e5982611e6c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b82818337600083830152505050565b60005b83811015611eb9578082015181840152602081019050611e9e565b83811115611ec8576000848401525b50505050565b6000601f19601f8301169050919050565b611ee881611e4e565b8114611ef357600080fd5b5056fea264697066735822122081400c05e4f7360302d449b5adaedcaa1e2d51cfb9734ce6549e4219da195eb964736f6c63430007000033
{"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, 2581, 2497, 2692, 2497, 2509, 2050, 2620, 2497, 3207, 7959, 2620, 27421, 2683, 26976, 2509, 2050, 2509, 2278, 2575, 18613, 16147, 4215, 10790, 18939, 2620, 4215, 14526, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1014, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 16021, 2696, 8663, 2638, 24817, 2615, 2475, 1008, 1030, 16475, 15584, 2005, 19400, 2015, 1012, 1008, 1013, 8278, 5950, 18447, 2121, 12172, 1063, 3853, 3040, 1006, 1007, 6327, 3193, 5651, 1006, 4769, 1007, 1025, 1065, 8278, 19400, 18447, 2121, 12172, 1063, 3853, 2171, 1006, 1007, 6327, 3193, 5651, 1006, 5164, 3638, 1007, 1025, 1065, 3206, 21257, 1063, 2724, 8833, 8663, 13181, 10820, 1006, 4769, 25331, 5587, 2099, 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,987
0x97B0E89fC1B7eD4A8B237D9d8Fcce9b234f25A37
// @author Unstoppable Domains, Inc. // @date August 12th, 2021 pragma solidity ^0.8.0; import './IForwarder.sol'; import './BaseRoutingForwarder.sol'; /** * @title CNSRegistryForwarder * @dev CNSRegistryForwarder simplifies operation with legacy meta-transactions. * It works on top of existing SignatureController contract. */ contract CNSRegistryForwarder is BaseRoutingForwarder { IForwarder private _target; constructor(IForwarder target) { _target = target; _addRoute('transferFrom(address,address,uint256)', 'transferFromFor(address,address,uint256,bytes)'); _addRoute('safeTransferFrom(address,address,uint256)', 'safeTransferFromFor(address,address,uint256,bytes)'); _addRoute( 'safeTransferFrom(address,address,uint256,bytes)', 'safeTransferFromFor(address,address,uint256,bytes,bytes)' ); _addRoute('burn(uint256)', 'burnFor(uint256,bytes)'); _addRoute('mintChild(address,uint256,string)', 'mintChildFor(address,uint256,string,bytes)'); _addRoute('safeMintChild(address,uint256,string)', 'safeMintChildFor(address,uint256,string,bytes)'); _addRoute( 'safeMintChild(address,uint256,string,bytes)', 'safeMintChildFor(address,uint256,string,bytes,bytes)' ); _addRoute( 'transferFromChild(address,address,uint256,string)', 'transferFromChildFor(address,address,uint256,string,bytes)' ); _addRoute( 'safeTransferFromChild(address,address,uint256,string)', 'safeTransferFromChildFor(address,address,uint256,string,bytes)' ); _addRoute( 'safeTransferFromChild(address,address,uint256,string,bytes)', 'safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)' ); _addRoute('burnChild(uint256,string)', 'burnChildFor(uint256,string,bytes)'); _addRoute('resolveTo(address,uint256)', 'resolveToFor(address,uint256,bytes)'); } function nonceOf(uint256 tokenId) public view override returns (uint256) { return _target.nonceOf(tokenId); } function verify(ForwardRequest calldata req, bytes calldata signature) external view override returns (bool) { return _verify(req, address(_target), signature); } function execute(ForwardRequest calldata req, bytes calldata signature) external override returns (bytes memory) { uint256 gas = gasleft(); return _execute(req.from, address(_target), req.tokenId, gas, req.data, signature); } /** * 0xef2c3088 = bytes4(keccak256('transferFromFor(address,address,uint256,bytes)')) * 0x6debcb8d = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes)')) * 0x280d9b05 = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes,bytes)')) * 0x61603dd9 = bytes4(keccak256('burnFor(uint256,bytes)')) * 0xb34f33c5 = bytes4(keccak256('mintChildFor(address,uint256,string,bytes)')) * 0x30135293 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes)')) * 0x07eca395 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes,bytes)')) * 0x68b6154f = bytes4(keccak256('transferFromChildFor(address,address,uint256,string,bytes)')) * 0xd0778d6c = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes)')) * 0xf5090c1e = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)')) * 0x6fab95b3 = bytes4(keccak256('burnChildFor(uint256,string,bytes)')) * 0x511f1112 = bytes4(keccak256('resolveToFor(address,uint256,bytes)')) */ function _buildRouteData( bytes4 selector, bytes memory data, bytes memory signature ) internal pure override returns (bytes memory) { if(selector == 0xef2c3088) { (address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256)); return abi.encodeWithSelector(selector, p1, p2, p3, signature); } else if(selector == 0x6debcb8d) { (address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256)); return abi.encodeWithSelector(selector, p1, p2, p3, signature); } else if(selector == 0x280d9b05) { (address p1, address p2, uint256 p3, bytes memory p4) = abi.decode(data, (address, address, uint256, bytes)); return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature); } else if(selector == 0x61603dd9) { (uint256 p1) = abi.decode(data, (uint256)); return abi.encodeWithSelector(selector, p1, signature); } else if(selector == 0xb34f33c5) { (address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string)); return abi.encodeWithSelector(selector, p1, p2, p3, signature); } else if(selector == 0x30135293) { (address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string)); return abi.encodeWithSelector(selector, p1, p2, p3, signature); } else if(selector == 0x07eca395) { (address p1, uint256 p2, string memory p3, bytes memory p4) = abi.decode(data, (address, uint256, string, bytes)); return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature); } else if(selector == 0x68b6154f) { (address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string)); return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature); } else if(selector == 0xd0778d6c) { (address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string)); return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature); } else if(selector == 0xf5090c1e) { (address p1, address p2, uint256 p3, string memory p4, bytes memory p5) = abi.decode(data, (address, address, uint256, string, bytes)); return abi.encodeWithSelector(selector, p1, p2, p3, p4, p5, signature); } else if(selector == 0x6fab95b3) { (uint256 p1, string memory p2) = abi.decode(data, (uint256, string)); return abi.encodeWithSelector(selector, p1, p2, signature); } else if(selector == 0x511f1112) { (address p1, uint256 p2) = abi.decode(data, (address, uint256)); return abi.encodeWithSelector(selector, p1, p2, signature); } return ''; } } // @author Unstoppable Domains, Inc. // @date August 11th, 2021 pragma solidity ^0.8.0; interface IForwarder { struct ForwardRequest { address from; uint256 nonce; uint256 tokenId; bytes data; } function nonceOf(uint256 tokenId) external view returns (uint256); function verify(ForwardRequest calldata req, bytes calldata signature) external view returns (bool); function execute(ForwardRequest calldata req, bytes calldata signature) external returns (bytes memory); } // @author Unstoppable Domains, Inc. // @date August 12th, 2021 pragma solidity ^0.8.0; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import './IForwarder.sol'; import './BaseForwarder.sol'; /** * @title BaseRoutingForwarder * @dev BaseRoutingForwarder simplifies operation with legacy meta-transactions by routing calls */ abstract contract BaseRoutingForwarder is BaseForwarder { mapping(bytes4 => bytes4) private _routes; function _buildRouteData( bytes4 selector, bytes memory data, bytes memory signature ) internal view virtual returns (bytes memory); function _verify( ForwardRequest memory req, address target, bytes memory signature ) internal view override returns (bool) { return super._verify(req, target, signature) && _isKnownRoute(req.data); } function _buildData( address, /* from */ uint256, /* tokenId */ bytes memory data, bytes memory signature ) internal view override returns (bytes memory) { bytes4 route = _getRoute(data); require(route != 0, 'BaseRoutingForwarder: ROUTE_UNKNOWN'); bytes memory _data; assembly { _data := add(data, 4) mstore(_data, sub(mload(data), 4)) } return _buildRouteData(route, _data, signature); } function _addRoute(bytes memory from, bytes memory to) internal { _routes[bytes4(keccak256(from))] = bytes4(keccak256(to)); } function _getRoute(bytes memory data) internal view returns (bytes4) { bytes4 selector; /* solium-disable-next-line security/no-inline-assembly */ assembly { selector := mload(add(data, add(0x20, 0))) } return _routes[selector]; } function _isKnownRoute(bytes memory data) internal view returns (bool) { bytes4 route = _getRoute(data); return route != 0; } } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version 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; } } } // @author Unstoppable Domains, Inc. // @date August 12th, 2021 pragma solidity ^0.8.0; import '@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol'; import './IForwarder.sol'; abstract contract BaseForwarder is IForwarder { using ECDSAUpgradeable for bytes32; function _verify( ForwardRequest memory req, address target, bytes memory signature ) internal view virtual returns (bool) { uint256 nonce = this.nonceOf(req.tokenId); address signer = _recover(keccak256(req.data), target, nonce, signature); return nonce == req.nonce && signer == req.from; } function _recover( bytes32 digest, address target, uint256 nonce, bytes memory signature ) internal pure virtual returns (address signer) { return keccak256(abi.encodePacked(digest, target, nonce)).toEthSignedMessageHash().recover(signature); } function _execute( address from, address to, uint256 tokenId, uint256 gas, bytes memory data, bytes memory signature ) internal virtual returns (bytes memory) { _invalidateNonce(tokenId); (bool success, bytes memory returndata) = to.call{gas: gas}(_buildData(from, tokenId, data, signature)); // Validate that the relayer has sent enough gas for the call. // See https://ronan.eth.link/blog/ethereum-gas-dangers/ assert(gasleft() > gas / 63); return _verifyCallResult(success, returndata, 'BaseForwarder: CALL_FAILED'); } function _invalidateNonce( uint256 /* tokenId */ ) internal virtual {} function _buildData( address from, uint256 tokenId, bytes memory data, bytes memory /* signature */ ) internal view virtual returns (bytes memory) { return abi.encodePacked(data, from, tokenId); } 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.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { /** * @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) { // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // 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) { // 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))) } } else if (signature.length == 64) { // 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 { let vs := mload(add(signature, 0x40)) r := mload(add(signature, 0x20)) s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } } else { revert("ECDSA: invalid signature length"); } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80631bf7e13e146100465780636ccbae5f1461006f578063a42474001461008f575b600080fd5b610059610054366004610e15565b6100af565b6040516100669190611176565b60405180910390f35b61008261007d366004610ead565b61015e565b60405161006691906112be565b6100a261009d366004610e15565b6101e5565b604051610066919061114d565b606060005a90506101536100c66020870187610bad565b6001546001600160a01b03166040880135846100e560608b018b61130b565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8e018190048102820181019092528c815292508c91508b908190840183828082843760009201919091525061024492505050565b9150505b9392505050565b600154604051636ccbae5f60e01b81526000916001600160a01b031690636ccbae5f9061018f9085906004016112be565b60206040518083038186803b1580156101a757600080fd5b505afa1580156101bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101df9190610ec5565b92915050565b600061023c6101f3856113c9565b600154604080516020601f88018190048102820181019092528681526001600160a01b039092169190879087908190840183828082843760009201919091525061033392505050565b949350505050565b606061024f85610354565b600080876001600160a01b0316866102698b8a8989610357565b6040516102769190610f76565b60006040518083038160008787f1925050503d80600081146102b4576040519150601f19603f3d011682016040523d82523d6000602084013e6102b9565b606091505b5090925090506102ca603f876113a9565b5a116102e657634e487b7160e01b600052600160045260246000fd5b61032682826040518060400160405280601a81526020017f42617365466f727761726465723a2043414c4c5f4641494c45440000000000008152506103b9565b9998505050505050505050565b60006103408484846103f2565b801561023c575061023c84606001516104b4565b50565b60606000610364846104d3565b90506001600160e01b031981166103965760405162461bcd60e51b815260040161038d90611239565b60405180910390fd5b835160031901600485019081526103ae8282866104f7565b979650505050505050565b606083156103c8575081610157565b8251156103d85782518084602001fd5b8160405162461bcd60e51b815260040161038d9190611176565b6040808401519051636ccbae5f60e01b815260009182913091636ccbae5f9161041e91906004016112be565b60206040518083038186803b15801561043657600080fd5b505afa15801561044a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046e9190610ec5565b90506000610489866060015180519060200120868487610989565b90508560200151821480156104aa575085516001600160a01b038281169116145b9695505050505050565b6000806104c0836104d3565b6001600160e01b03191615159392505050565b6020908101516001600160e01b031916600090815290819052604090205460e01b90565b6060631de5861160e31b6001600160e01b0319851614156105865760008060008580602001905181019061052b9190610bc9565b92509250925086838383886040516024016105499493929190610fc3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152935061015792505050565b636debcb8d60e01b6001600160e01b0319851614156105b85760008060008580602001905181019061052b9190610bc9565b63280d9b0560e01b6001600160e01b03198516141561064b57600080600080868060200190518101906105eb9190610c0b565b935093509350935087848484848a60405160240161060d959493929190610ff6565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915294506101579350505050565b6361603dd960e01b6001600160e01b0319851614156106cb5760008380602001905181019061067a9190610ec5565b90508481846040516024016106909291906112c7565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915291506101579050565b63b34f33c560e01b6001600160e01b03198516141561071b576000806000858060200190518101906106fd9190610d4b565b925092509250868383838860405160240161054994939291906110c7565b633013529360e01b6001600160e01b03198516141561074d576000806000858060200190518101906106fd9190610d4b565b6307eca39560e01b6001600160e01b0319851614156107a257600080600080868060200190518101906107809190610da3565b935093509350935087848484848a60405160240161060d959493929190611100565b6368b6154f60e01b6001600160e01b0319851614156107d557600080600080868060200190518101906105eb9190610c77565b63341de35b60e21b6001600160e01b03198516141561080857600080600080868060200190518101906105eb9190610c77565b637a84860f60e11b6001600160e01b0319851614156108a25760008060008060008780602001905181019061083d9190610c8c565b945094509450945094508885858585858c60405160240161086396959493929190611047565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529550610157945050505050565b636fab95b360e01b6001600160e01b03198516141561092857600080848060200190518101906108d29190610edd565b91509150858282866040516024016108ec939291906112e0565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529250610157915050565b63288f888960e11b6001600160e01b03198516141561097257600080848060200190518101906109589190610d1e565b91509150858282866040516024016108ec939291906110a0565b506040805160208101909152600081529392505050565b60006109c8826109c28787876040516020016109a793929190610f4e565b604051602081830303815290604052805190602001206109d1565b90610a01565b95945050505050565b6000816040516020016109e49190610f92565b604051602081830303815290604052805190602001209050919050565b600080600080845160411415610a2b5750505060208201516040830151606084015160001a610a71565b845160401415610a595750505060408201516020830151906001600160ff1b0381169060ff1c601b01610a71565b60405162461bcd60e51b815260040161038d906111c0565b6104aa8682858560007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115610aba5760405162461bcd60e51b815260040161038d906111f7565b8360ff16601b1480610acf57508360ff16601c145b610aeb5760405162461bcd60e51b815260040161038d9061127c565b600060018686868660405160008152602001604052604051610b109493929190611158565b6020604051602081039080840390855afa158015610b32573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166109c85760405162461bcd60e51b815260040161038d90611189565b600082601f830112610b75578081fd5b8151610b88610b8382611381565b611357565b818152846020838601011115610b9c578283fd5b61023c826020830160208701611489565b600060208284031215610bbe578081fd5b8135610157816114cf565b600080600060608486031215610bdd578182fd5b8351610be8816114cf565b6020850151909350610bf9816114cf565b80925050604084015190509250925092565b60008060008060808587031215610c20578081fd5b8451610c2b816114cf565b6020860151909450610c3c816114cf565b60408601516060870151919450925067ffffffffffffffff811115610c5f578182fd5b610c6b87828801610b65565b91505092959194509250565b60008060008060808587031215610c20578384fd5b600080600080600060a08688031215610ca3578081fd5b8551610cae816114cf565b6020870151909550610cbf816114cf565b60408701516060880151919550935067ffffffffffffffff80821115610ce3578283fd5b610cef89838a01610b65565b93506080880151915080821115610d04578283fd5b50610d1188828901610b65565b9150509295509295909350565b60008060408385031215610d30578182fd5b8251610d3b816114cf565b6020939093015192949293505050565b600080600060608486031215610d5f578283fd5b8351610d6a816114cf565b60208501516040860151919450925067ffffffffffffffff811115610d8d578182fd5b610d9986828701610b65565b9150509250925092565b60008060008060808587031215610db8578182fd5b8451610dc3816114cf565b60208601516040870151919550935067ffffffffffffffff80821115610de7578384fd5b610df388838901610b65565b93506060870151915080821115610e08578283fd5b50610c6b87828801610b65565b600080600060408486031215610e29578081fd5b833567ffffffffffffffff80821115610e40578283fd5b9085019060808288031215610e53578283fd5b90935060208501359080821115610e68578283fd5b818601915086601f830112610e7b578283fd5b813581811115610e89578384fd5b876020828501011115610e9a578384fd5b6020830194508093505050509250925092565b600060208284031215610ebe578081fd5b5035919050565b600060208284031215610ed6578081fd5b5051919050565b60008060408385031215610eef578182fd5b82519150602083015167ffffffffffffffff811115610f0c578182fd5b610f1885828601610b65565b9150509250929050565b60008151808452610f3a816020860160208601611489565b601f01601f19169290920160200192915050565b92835260609190911b6bffffffffffffffffffffffff19166020830152603482015260540190565b60008251610f88818460208701611489565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906104aa90830184610f22565b6001600160a01b038681168252851660208201526040810184905260a06060820181905260009061102990830185610f22565b828103608084015261103b8185610f22565b98975050505050505050565b6001600160a01b038781168252861660208201526040810185905260c06060820181905260009061107a90830186610f22565b828103608084015261108c8186610f22565b905082810360a08401526103268185610f22565b600060018060a01b0385168252836020830152606060408301526109c86060830184610f22565b600060018060a01b0386168252846020830152608060408301526110ee6080830185610f22565b82810360608401526103ae8185610f22565b600060018060a01b038716825285602083015260a0604083015261112760a0830186610f22565b82810360608401526111398186610f22565b9050828103608084015261103b8185610f22565b901515815260200190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526101576020830184610f22565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b6020808252601f908201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526023908201527f42617365526f7574696e67466f727761726465723a20524f5554455f554e4b4e60408201526227aba760e91b606082015260800190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b90815260200190565b60008382526040602083015261023c6040830184610f22565b6000848252606060208301526112f96060830185610f22565b82810360408401526104aa8185610f22565b6000808335601e19843603018112611321578283fd5b83018035915067ffffffffffffffff82111561133b578283fd5b60200191503681900382131561135057600080fd5b9250929050565b60405181810167ffffffffffffffff81118282101715611379576113796114b9565b604052919050565b600067ffffffffffffffff82111561139b5761139b6114b9565b50601f01601f191660200190565b6000826113c457634e487b7160e01b81526012600452602481fd5b500490565b6000608082360312156113da578081fd5b6040516080810167ffffffffffffffff82821081831117156113fe576113fe6114b9565b816040528435915061140f826114cf565b81835260209150818501358284015260408501356040840152606085013581811115611439578485fd5b8501905036601f82011261144b578384fd5b8035611459610b8382611381565b818152368483850101111561146c578586fd5b818484018583013790810190920193909352606082015292915050565b60005b838110156114a457818101518382015260200161148c565b838111156114b3576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461035457600080fdfea164736f6c6343000800000a
{"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, 2581, 2497, 2692, 2063, 2620, 2683, 11329, 2487, 2497, 2581, 2098, 2549, 2050, 2620, 2497, 21926, 2581, 2094, 2683, 2094, 2620, 11329, 3401, 2683, 2497, 21926, 2549, 2546, 17788, 2050, 24434, 1013, 1013, 1030, 3166, 4895, 16033, 13944, 3468, 13100, 1010, 4297, 1012, 1013, 1013, 1030, 3058, 2257, 5940, 1010, 25682, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1005, 1012, 1013, 2065, 2953, 7652, 2121, 1012, 14017, 1005, 1025, 12324, 1005, 1012, 1013, 2918, 22494, 3436, 29278, 7652, 2121, 1012, 14017, 1005, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 27166, 21338, 13910, 2923, 2854, 29278, 7652, 2121, 1008, 1030, 16475, 27166, 21338, 13910, 2923, 2854, 29278, 7652, 2121, 21934, 24759, 14144, 3169, 2007, 8027, 18804, 1011, 11817, 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,988
0x97b1649cb34b6d28c121547fb59f73187e6b03e2
pragma solidity ^0.4.21; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract token { /* 公共变量 */ string public name; //代币名称 string public symbol; //代币符号 uint8 public decimals = 4; //代币单位,展示的小数点后面多少个0 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 Burn(address indexed from, uint256 value); //减去用户余额事件 /* 初始化合约,并且把初始的所有代币都给这合约的创建者 * @param initialSupply 代币的总数 * @param tokenName 代币名称 * @param tokenSymbol 代币符号 */ function token(uint256 initialSupply, string tokenName, string tokenSymbol) public { //初始化总量 totalSupply = initialSupply * 10 ** uint256(decimals); //给指定帐户初始化代币总量,初始化用于奖励合约创建者 balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } /** * 私有方法从一个帐户发送给另一个帐户代币 * @param _from address 发送代币的地址 * @param _to address 接受代币的地址 * @param _value uint256 接受代币的数量 */ function _transfer(address _from, address _to, uint256 _value) internal { //避免转帐的地址是0x0 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; //通知任何监听该交易的客户端 Transfer(_from, _to, _value); //判断买、卖双方的数据是否和转换前一致 assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * 从主帐户合约调用者发送给别人代币 * @param _to address 接受代币的地址 * @param _value uint256 接受代币的数量 */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * 从某个指定的帐户中,向另一个帐户发送代币 * * 调用过程,会检查设置的允许最大交易额 * * @param _from address 发送者地址 * @param _to address 接受者地址 * @param _value uint256 要转移的代币数量 * @return success 是否交易成功 */ 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; } /** * 设置帐户允许支付的最大金额 * * 一般在智能合约的时候,避免支付过多,造成风险 * * @param _spender 帐户地址 * @param _value 金额 */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * 设置帐户允许支付的最大金额 * * 一般在智能合约的时候,避免支付过多,造成风险,加入时间参数,可以在 tokenRecipient 中做其他操作 * * @param _spender 帐户地址 * @param _value 金额 * @param _extraData 操作的时间 */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * 减少代币调用者的余额 * * 操作以后是不可逆的 * * @param _value 要删除的数量 */ function burn(uint256 _value) public returns (bool success) { //检查帐户余额是否大于要减去的值 require(balanceOf[msg.sender] >= _value); // Check if the sender has enough //给指定帐户减去余额 balanceOf[msg.sender] -= _value; //代币问题做相应扣除 totalSupply -= _value; Burn(msg.sender, _value); return true; } /** * 删除帐户的余额(含其他帐户) * * 删除以后是不可逆的 * * @param _from 要操作的帐户地址 * @param _value 要减去的数量 */ function burnFrom(address _from, uint256 _value) public returns (bool success) { //检查帐户余额是否大于要减去的值 require(balanceOf[_from] >= _value); //检查 其他帐户 的余额是否够使用 require(_value <= allowance[_from][msg.sender]); //减掉代币 balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; //更新总量 totalSupply -= _value; Burn(_from, _value); return true; } }
0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806342966c681461027857806370a08231146102b357806379cc67901461030057806395d89b411461035a578063a9059cbb146103e8578063cae9ca511461042a578063dd62ed3e146104c7575b600080fd5b34156100ca57600080fd5b6100d2610533565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105d1565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba61065e565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610664565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610791565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61029960048080359060200190919050506107a4565b604051808215151515815260200191505060405180910390f35b34156102be57600080fd5b6102ea600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108a8565b6040518082815260200191505060405180910390f35b341561030b57600080fd5b610340600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108c0565b604051808215151515815260200191505060405180910390f35b341561036557600080fd5b61036d610ada565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ad578082015181840152602081019050610392565b50505050905090810190601f1680156103da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103f357600080fd5b610428600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b78565b005b341561043557600080fd5b6104ad600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610b87565b604051808215151515815260200191505060405180910390f35b34156104d257600080fd5b61051d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d01565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105c95780601f1061059e576101008083540402835291602001916105c9565b820191906000526020600020905b8154815290600101906020018083116105ac57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156106f157600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610786848484610d26565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156107f457600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561091057600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561099b57600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081565b610b83338383610d26565b5050565b600080849050610b9785856105d1565b15610cf8578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610c91578082015181840152602081019050610c76565b50505050905090810190601f168015610cbe5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610cdf57600080fd5b5af11515610cec57600080fd5b50505060019150610cf9565b5b509392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610d4d57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610d9b57600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610e2957600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561103657fe5b505050505600a165627a7a72305820bad70b834011d53b32bffd4ecb3ef3fcb27b65ee29de549898ec3281516f65d40029
{"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, 2581, 2497, 16048, 26224, 27421, 22022, 2497, 2575, 2094, 22407, 2278, 12521, 16068, 22610, 26337, 28154, 2546, 2581, 21486, 2620, 2581, 2063, 2575, 2497, 2692, 2509, 2063, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 8278, 19204, 2890, 6895, 14756, 3372, 1063, 3853, 4374, 29098, 12298, 2389, 1006, 4769, 1035, 2013, 1010, 21318, 3372, 17788, 2575, 1035, 3643, 1010, 4769, 1035, 19204, 1010, 27507, 1035, 4469, 2850, 2696, 1007, 6327, 1025, 1065, 3206, 19204, 1063, 1013, 1008, 1772, 100, 100, 100, 1008, 1013, 5164, 2270, 2171, 1025, 1013, 1013, 1760, 100, 1795, 100, 5164, 2270, 6454, 1025, 1013, 1013, 1760, 100, 100, 100, 21318, 3372, 2620, 2270, 26066, 2015, 1027, 1018, 1025, 1013, 1013, 1760, 100, 100, 100, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,989
0x97b214463520dd39900167dfb84254ae2ac47fc1
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 MyOwnCryptoToken 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 = "MyOwnCryptoToken"; symbol = "MOTC"; decimals = 9; _totalSupply = 5000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a723058201242f623f91ef3e9cf220bcff467f08979bbb25e9b07d11756dd32fa3280e7530029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 17465, 22932, 2575, 19481, 11387, 14141, 23499, 21057, 24096, 2575, 2581, 20952, 2497, 2620, 20958, 27009, 6679, 2475, 6305, 22610, 11329, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 2278, 19204, 3115, 1001, 2322, 8278, 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,990
0x97B2d00CB0e99249731b0BEeEa8d3628ac5157B6
/** *Submitted for verification at Etherscan.io on 2022-03-12 */ /** *Submitted for verification at Etherscan.io on 2022-03-04 */ // SPDX-License-Identifier: MIT // 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; } } // Creator: Chiru Labs pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert('ERC721A: unable to get token of owner by index'); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: approve to caller'); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); require(quantity != 0, 'ERC721A: quantity must be greater than 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } updatedIndex++; } currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // 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 HappyOtters is ERC721A, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.0069 ether; uint256 public maxSupply = 6666; uint256 public maxMintAmount = 10; uint256 public maxFREEMintAmount = 3; uint256 public FREEnftPerAddressLimit = 3; uint256 public FREE_MAX_SUPPLY = 1000; bool public paused = true; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721A(_name, _symbol) { setBaseURI(_initBaseURI); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { require(!paused, "the contract is paused"); uint256 supply = totalSupply(); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); if (msg.sender != owner()) { if (FREE_MAX_SUPPLY >= supply + _mintAmount) { require(_mintAmount <= maxFREEMintAmount, "max mint amount per session exceeded"); require(numberMinted(msg.sender) + _mintAmount <= FREEnftPerAddressLimit, "max NFT per address exceeded"); } else { require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(msg.value >= _mintAmount * cost, "Invalid funds provided"); } } _safeMint(msg.sender, _mintAmount); } function numberMinted(address owner) public view returns (uint256) { return _numberMinted(owner); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function setNftPerAddressLimit(uint256 _limit) public onlyOwner { FREEnftPerAddressLimit = _limit; } function setFreeMaxSupply(uint256 _FreeMaxAmount) public onlyOwner { FREE_MAX_SUPPLY = _FreeMaxAmount; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setFreeMaxMintAmount(uint256 _newFreeMaxMintAmount) public onlyOwner { maxFREEMintAmount = _newFreeMaxMintAmount; FREEnftPerAddressLimit = _newFreeMaxMintAmount; } 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 { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
0x6080604052600436106102255760003560e01c8063715018a611610123578063c6682862116100ab578063d5abeb011161006f578063d5abeb01146105fe578063da3ef23f14610614578063dc33e68114610634578063e985e9c514610654578063f2fde38b1461069d57600080fd5b8063c668286214610569578063c87b56dd1461057e578063d0eb26b01461059e578063d223a631146105be578063d4fcb2ae146105de57600080fd5b80638da5cb5b116100f25780638da5cb5b146104e357806395d89b4114610501578063a0712d6814610516578063a22cb46514610529578063b88d4fde1461054957600080fd5b8063715018a6146104825780637c7c867f146104975780637f00c7a6146104ad5780638069876d146104cd57600080fd5b80632f745c59116101b157806355f804b31161017557806355f804b3146103f2578063586963d9146104125780635c975abb146104285780636352211e1461044257806370a082311461046257600080fd5b80632f745c591461036a5780633ccfd60b1461038a57806342842e0e1461039257806344a0d68a146103b25780634f6ccce7146103d257600080fd5b8063095ea7b3116101f8578063095ea7b3146102db57806313faede6146102fb57806318160ddd1461031f578063239c70ae1461033457806323b872dd1461034a57600080fd5b806301ffc9a71461022a57806302329a291461025f57806306fdde0314610281578063081812fc146102a3575b600080fd5b34801561023657600080fd5b5061024a610245366004611f00565b6106bd565b60405190151581526020015b60405180910390f35b34801561026b57600080fd5b5061027f61027a366004611ee5565b61072a565b005b34801561028d57600080fd5b50610296610770565b60405161025691906120c9565b3480156102af57600080fd5b506102c36102be366004611f83565b610802565b6040516001600160a01b039091168152602001610256565b3480156102e757600080fd5b5061027f6102f6366004611ebb565b61088d565b34801561030757600080fd5b50610311600a5481565b604051908152602001610256565b34801561032b57600080fd5b50600054610311565b34801561034057600080fd5b50610311600c5481565b34801561035657600080fd5b5061027f610365366004611dd9565b6109a5565b34801561037657600080fd5b50610311610385366004611ebb565b6109b0565b61027f610b0d565b34801561039e57600080fd5b5061027f6103ad366004611dd9565b610bab565b3480156103be57600080fd5b5061027f6103cd366004611f83565b610bc6565b3480156103de57600080fd5b506103116103ed366004611f83565b610bf5565b3480156103fe57600080fd5b5061027f61040d366004611f3a565b610c57565b34801561041e57600080fd5b50610311600e5481565b34801561043457600080fd5b5060105461024a9060ff1681565b34801561044e57600080fd5b506102c361045d366004611f83565b610c98565b34801561046e57600080fd5b5061031161047d366004611d8b565b610caa565b34801561048e57600080fd5b5061027f610d3b565b3480156104a357600080fd5b50610311600d5481565b3480156104b957600080fd5b5061027f6104c8366004611f83565b610d71565b3480156104d957600080fd5b50610311600f5481565b3480156104ef57600080fd5b506007546001600160a01b03166102c3565b34801561050d57600080fd5b50610296610da0565b61027f610524366004611f83565b610daf565b34801561053557600080fd5b5061027f610544366004611e91565b610f83565b34801561055557600080fd5b5061027f610564366004611e15565b611048565b34801561057557600080fd5b50610296611081565b34801561058a57600080fd5b50610296610599366004611f83565b61110f565b3480156105aa57600080fd5b5061027f6105b9366004611f83565b6111df565b3480156105ca57600080fd5b5061027f6105d9366004611f83565b61120e565b3480156105ea57600080fd5b5061027f6105f9366004611f83565b61123d565b34801561060a57600080fd5b50610311600b5481565b34801561062057600080fd5b5061027f61062f366004611f3a565b611271565b34801561064057600080fd5b5061031161064f366004611d8b565b6112ae565b34801561066057600080fd5b5061024a61066f366004611da6565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156106a957600080fd5b5061027f6106b8366004611d8b565b6112b9565b60006001600160e01b031982166380ac58cd60e01b14806106ee57506001600160e01b03198216635b5e139f60e01b145b8061070957506001600160e01b0319821663780e9d6360e01b145b8061072457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6007546001600160a01b0316331461075d5760405162461bcd60e51b815260040161075490612120565b60405180910390fd5b6010805460ff1916911515919091179055565b60606001805461077f90612236565b80601f01602080910402602001604051908101604052809291908181526020018280546107ab90612236565b80156107f85780601f106107cd576101008083540402835291602001916107f8565b820191906000526020600020905b8154815290600101906020018083116107db57829003601f168201915b5050505050905090565b600061080f826000541190565b6108715760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b6064820152608401610754565b506000908152600560205260409020546001600160a01b031690565b600061089882610c98565b9050806001600160a01b0316836001600160a01b031614156109075760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610754565b336001600160a01b03821614806109235750610923813361066f565b6109955760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610754565b6109a0838383611351565b505050565b6109a08383836113ad565b60006109bb83610caa565b8210610a145760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610754565b600080549080805b83811015610aad576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610a6f57805192505b876001600160a01b0316836001600160a01b03161415610aa45786841415610a9d5750935061072492505050565b6001909301925b50600101610a1c565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610754565b6007546001600160a01b03163314610b375760405162461bcd60e51b815260040161075490612120565b6000610b4b6007546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b95576040519150601f19603f3d011682016040523d82523d6000602084013e610b9a565b606091505b5050905080610ba857600080fd5b50565b6109a083838360405180602001604052806000815250611048565b6007546001600160a01b03163314610bf05760405162461bcd60e51b815260040161075490612120565b600a55565b600080548210610c535760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610754565b5090565b6007546001600160a01b03163314610c815760405162461bcd60e51b815260040161075490612120565b8051610c94906008906020840190611c59565b5050565b6000610ca382611692565b5192915050565b60006001600160a01b038216610d165760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610754565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6007546001600160a01b03163314610d655760405162461bcd60e51b815260040161075490612120565b610d6f6000611769565b565b6007546001600160a01b03163314610d9b5760405162461bcd60e51b815260040161075490612120565b600c55565b60606002805461077f90612236565b60105460ff1615610dfb5760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b6044820152606401610754565b600054600b54610e0b83836121a8565b1115610e525760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b6044820152606401610754565b6007546001600160a01b03163314610f7957610e6e82826121a8565b600f5410610f0257600d54821115610e985760405162461bcd60e51b8152600401610754906120dc565b600e5482610ea5336112ae565b610eaf91906121a8565b1115610efd5760405162461bcd60e51b815260206004820152601c60248201527f6d6178204e4654207065722061646472657373206578636565646564000000006044820152606401610754565b610f79565b600c54821115610f245760405162461bcd60e51b8152600401610754906120dc565b600a54610f3190836121d4565b341015610f795760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199d5b991cc81c1c9bdd9a59195960521b6044820152606401610754565b610c9433836117bb565b6001600160a01b038216331415610fdc5760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610754565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6110538484846113ad565b61105f848484846117d5565b61107b5760405162461bcd60e51b815260040161075490612155565b50505050565b6009805461108e90612236565b80601f01602080910402602001604051908101604052809291908181526020018280546110ba90612236565b80156111075780601f106110dc57610100808354040283529160200191611107565b820191906000526020600020905b8154815290600101906020018083116110ea57829003601f168201915b505050505081565b606061111c826000541190565b6111805760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610754565b600061118a6118e3565b905060008151116111aa57604051806020016040528060008152506111d8565b806111b4846118f2565b60096040516020016111c893929190611fc8565b6040516020818303038152906040525b9392505050565b6007546001600160a01b031633146112095760405162461bcd60e51b815260040161075490612120565b600e55565b6007546001600160a01b031633146112385760405162461bcd60e51b815260040161075490612120565b600f55565b6007546001600160a01b031633146112675760405162461bcd60e51b815260040161075490612120565b600d819055600e55565b6007546001600160a01b0316331461129b5760405162461bcd60e51b815260040161075490612120565b8051610c94906009906020840190611c59565b6000610724826119f0565b6007546001600160a01b031633146112e35760405162461bcd60e51b815260040161075490612120565b6001600160a01b0381166113485760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610754565b610ba881611769565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006113b882611692565b80519091506000906001600160a01b0316336001600160a01b031614806113ef5750336113e484610802565b6001600160a01b0316145b8061140157508151611401903361066f565b90508061146b5760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610754565b846001600160a01b031682600001516001600160a01b0316146114df5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610754565b6001600160a01b0384166115435760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610754565b6115536000848460000151611351565b6001600160a01b03858116600090815260046020908152604080832080546001600160801b03198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600390935281842080546001600160e01b031916909117600160a01b4267ffffffffffffffff1602179055908601808352912054909116611648576115fb816000541190565b15611648578251600082815260036020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b60408051808201909152600080825260208201526116b1826000541190565b6117105760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610754565b815b6000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff16918301919091521561175f579392505050565b5060001901611712565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610c94828260405180602001604052806000815250611a8e565b60006001600160a01b0384163b156118d757604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061181990339089908890889060040161208c565b602060405180830381600087803b15801561183357600080fd5b505af1925050508015611863575060408051601f3d908101601f1916820190925261186091810190611f1d565b60015b6118bd573d808015611891576040519150601f19603f3d011682016040523d82523d6000602084013e611896565b606091505b5080516118b55760405162461bcd60e51b815260040161075490612155565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506118db565b5060015b949350505050565b60606008805461077f90612236565b6060816119165750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611940578061192a81612271565b91506119399050600a836121c0565b915061191a565b60008167ffffffffffffffff81111561195b5761195b6122e2565b6040519080825280601f01601f191660200182016040528015611985576020820181803683370190505b5090505b84156118db5761199a6001836121f3565b91506119a7600a8661228c565b6119b29060306121a8565b60f81b8183815181106119c7576119c76122cc565b60200101906001600160f81b031916908160001a9053506119e9600a866121c0565b9450611989565b60006001600160a01b038216611a625760405162461bcd60e51b815260206004820152603160248201527f455243373231413a206e756d626572206d696e74656420717565727920666f7260448201527020746865207a65726f206164647265737360781b6064820152608401610754565b506001600160a01b0316600090815260046020526040902054600160801b90046001600160801b031690565b6109a083838360016000546001600160a01b038516611af95760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610754565b83611b575760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d75737420626520677265617465604482015267072207468616e20360c41b6064820152608401610754565b6001600160a01b03851660008181526004602090815260408083208054600160801b6001600160801b031982166001600160801b039283168c01831690811782900483168c01909216021790558483526003909152812080546001600160e01b031916909217600160a01b4267ffffffffffffffff16021790915581905b85811015611c505760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48315611c4457611c2860008884886117d5565b611c445760405162461bcd60e51b815260040161075490612155565b60019182019101611bd5565b5060005561168b565b828054611c6590612236565b90600052602060002090601f016020900481019282611c875760008555611ccd565b82601f10611ca057805160ff1916838001178555611ccd565b82800160010185558215611ccd579182015b82811115611ccd578251825591602001919060010190611cb2565b50610c539291505b80821115610c535760008155600101611cd5565b600067ffffffffffffffff80841115611d0457611d046122e2565b604051601f8501601f19908116603f01168101908282118183101715611d2c57611d2c6122e2565b81604052809350858152868686011115611d4557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611d7657600080fd5b919050565b80358015158114611d7657600080fd5b600060208284031215611d9d57600080fd5b6111d882611d5f565b60008060408385031215611db957600080fd5b611dc283611d5f565b9150611dd060208401611d5f565b90509250929050565b600080600060608486031215611dee57600080fd5b611df784611d5f565b9250611e0560208501611d5f565b9150604084013590509250925092565b60008060008060808587031215611e2b57600080fd5b611e3485611d5f565b9350611e4260208601611d5f565b925060408501359150606085013567ffffffffffffffff811115611e6557600080fd5b8501601f81018713611e7657600080fd5b611e8587823560208401611ce9565b91505092959194509250565b60008060408385031215611ea457600080fd5b611ead83611d5f565b9150611dd060208401611d7b565b60008060408385031215611ece57600080fd5b611ed783611d5f565b946020939093013593505050565b600060208284031215611ef757600080fd5b6111d882611d7b565b600060208284031215611f1257600080fd5b81356111d8816122f8565b600060208284031215611f2f57600080fd5b81516111d8816122f8565b600060208284031215611f4c57600080fd5b813567ffffffffffffffff811115611f6357600080fd5b8201601f81018413611f7457600080fd5b6118db84823560208401611ce9565b600060208284031215611f9557600080fd5b5035919050565b60008151808452611fb481602086016020860161220a565b601f01601f19169290920160200192915050565b600084516020611fdb8285838a0161220a565b855191840191611fee8184848a0161220a565b8554920191600090600181811c908083168061200b57607f831692505b85831081141561202957634e487b7160e01b85526022600452602485fd5b80801561203d576001811461204e5761207b565b60ff1985168852838801955061207b565b60008b81526020902060005b858110156120735781548a82015290840190880161205a565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906120bf90830184611f9c565b9695505050505050565b6020815260006111d86020830184611f9c565b60208082526024908201527f6d6178206d696e7420616d6f756e74207065722073657373696f6e20657863656040820152631959195960e21b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b600082198211156121bb576121bb6122a0565b500190565b6000826121cf576121cf6122b6565b500490565b60008160001904831182151516156121ee576121ee6122a0565b500290565b600082821015612205576122056122a0565b500390565b60005b8381101561222557818101518382015260200161220d565b8381111561107b5750506000910152565b600181811c9082168061224a57607f821691505b6020821081141561226b57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612285576122856122a0565b5060010190565b60008261229b5761229b6122b6565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610ba857600080fdfea26469706673582212207207931b3d3634ed9b0cf7db572713b06139aca8e4400549e796a1b56de7beea64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2581, 2497, 2475, 2094, 8889, 27421, 2692, 2063, 2683, 2683, 18827, 2683, 2581, 21486, 2497, 2692, 11306, 5243, 2620, 2094, 21619, 22407, 6305, 22203, 28311, 2497, 2575, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 6021, 1011, 2260, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 6021, 1011, 5840, 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, 21183, 12146, 1013, 17174, 13102, 18491, 1013, 29464, 11890, 16048, 2629, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 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,991
0x97b358039b5085236abb0edfa5598632870d2691
/* LIQ: 2% MARKETING: 6% DEV: 4% */ pragma solidity ^0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } 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; // 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; } } 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"); (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; uint256 private _lockTime; 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); } 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 getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } } interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } contract Dong is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Konkey Dong"; string private constant _symbol = "DONG"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // 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; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 405; _rOwned[address(this)] = _rTotal / 1000 * 595; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0x5ABA07E022556083769e2547FaD3067442220e1C); // Marketing Address devAddress = payable(0x39Cb8494adb4F5f0dF7642fdCf873877Eb5ae0A4); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 405 / 1000); emit Transfer(address(0), address(this), _tTotal * 595 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this (not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } 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; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(tAmount); return rAmount; } else { (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address 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(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading is not active yet."); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // 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[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 gos to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover BNB to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, block.timestamp ); } 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 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 _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _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 { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
0x6080604052600436106103c75760003560e01c806370a08231116101f2578063a9059cbb1161010d578063dc44b6a0116100a0578063ee40166e1161006f578063ee40166e14610b80578063efcc52de14610b96578063f2fde38b14610bac578063f5648a4f14610bcc57600080fd5b8063dc44b6a014610aef578063dd62ed3e14610b05578063e884f26014610b4b578063ea2f0b3714610b6057600080fd5b8063c5d24189116100dc578063c5d2418914610a93578063c860795214610aa9578063c876d0b914610abf578063c8c8ebe414610ad957600080fd5b8063a9059cbb14610a02578063b62496f514610a22578063bbc0c74214610a52578063c49b9a8014610a7357600080fd5b806388f82020116101855780639a7a23d6116101545780639a7a23d61461098d578063a073d37f146109ad578063a457c2d7146109c2578063a5ece941146109e257600080fd5b806388f82020146108e95780638da5cb5b14610922578063906e9dd01461094057806395d89b411461096057600080fd5b80638366e79a116101c15780638366e79a14610863578063837917581461088357806385ecfd28146108a357806388790a68146108d357600080fd5b806370a08231146107f9578063715018a614610819578063751039fc1461082e5780637571336a1461084357600080fd5b80633685d419116102e25780634a74bb02116102755780635342acb4116102445780635342acb414610778578063557ed1ba146107b15780635bb988c9146107c4578063602bc62b146107e457600080fd5b80634a74bb021461070257806351f205e41461072357806352390c0214610738578063525fa81f1461075857600080fd5b8063437823ec116102b1578063437823ec146106835780634549b039146106a357806349bd5a5e146106c35780634a62bb65146106e357600080fd5b80633685d4191461060d578063395093511461062d5780633ad10ef61461064d5780634047ea3e1461066d57600080fd5b80631fc851bd1161035a57806325519cf21161032957806325519cf2146105915780632d838119146105b1578063313ce567146105d15780633221c93f146105ed57600080fd5b80631fc851bd1461052f578063200a692d1461054557806323b872dd1461055b57806324171f321461057b57600080fd5b806313114a9d1161039657806313114a9d1461049b5780631694505e146104ba57806318160ddd146104f25780631d865c301461050f57600080fd5b806306fdde03146103d35780630923160214610419578063095ea7b31461043b57806310d5de531461046b57600080fd5b366103ce57005b600080fd5b3480156103df57600080fd5b5060408051808201909152600b81526a4b6f6e6b657920446f6e6760a81b60208201525b6040516104109190613c4f565b60405180910390f35b34801561042557600080fd5b50610439610434366004613ca4565b610be1565b005b34801561044757600080fd5b5061045b610456366004613cd5565b610c36565b6040519015158152602001610410565b34801561047757600080fd5b5061045b610486366004613d01565b60226020526000908152604090205460ff1681565b3480156104a757600080fd5b50600f545b604051908152602001610410565b3480156104c657600080fd5b506027546104da906001600160a01b031681565b6040516001600160a01b039091168152602001610410565b3480156104fe57600080fd5b5069d3c21bcecceda10000006104ac565b34801561051b57600080fd5b5061043961052a366004613d1e565b610c4d565b34801561053b57600080fd5b506104ac601e5481565b34801561055157600080fd5b506104ac60195481565b34801561056757600080fd5b5061045b610576366004613d4a565b610d32565b34801561058757600080fd5b506104ac60205481565b34801561059d57600080fd5b506104396105ac366004613d1e565b610d9b565b3480156105bd57600080fd5b506104ac6105cc366004613ca4565b610e77565b3480156105dd57600080fd5b5060405160098152602001610410565b3480156105f957600080fd5b506005546104da906001600160a01b031681565b34801561061957600080fd5b50610439610628366004613d01565b610efb565b34801561063957600080fd5b5061045b610648366004613cd5565b6110b2565b34801561065957600080fd5b506004546104da906001600160a01b031681565b34801561067957600080fd5b506104ac601f5481565b34801561068f57600080fd5b5061043961069e366004613d01565b6110e8565b3480156106af57600080fd5b506104ac6106be366004613d99565b61116d565b3480156106cf57600080fd5b506028546104da906001600160a01b031681565b3480156106ef57600080fd5b50600a5461045b90610100900460ff1681565b34801561070e57600080fd5b5060285461045b90600160a81b900460ff1681565b34801561072f57600080fd5b50610439611202565b34801561074457600080fd5b50610439610753366004613d01565b6112fb565b34801561076457600080fd5b50610439610773366004613d01565b6114e9565b34801561078457600080fd5b5061045b610793366004613d01565b6001600160a01b03166000908152600b602052604090205460ff1690565b3480156107bd57600080fd5b50426104ac565b3480156107d057600080fd5b506104396107df366004613d01565b6115df565b3480156107f057600080fd5b506002546104ac565b34801561080557600080fd5b506104ac610814366004613d01565b611652565b34801561082557600080fd5b506104396116b1565b34801561083a57600080fd5b5061045b611725565b34801561084f57600080fd5b5061043961085e366004613dc9565b61176b565b34801561086f57600080fd5b5061045b61087e366004613df7565b6117c0565b34801561088f57600080fd5b5061045b61089e366004613efb565b6119e6565b3480156108af57600080fd5b5061045b6108be366004613d01565b601d6020526000908152604090205460ff1681565b3480156108df57600080fd5b506104ac601a5481565b3480156108f557600080fd5b5061045b610904366004613d01565b6001600160a01b03166000908152600c602052604090205460ff1690565b34801561092e57600080fd5b506000546001600160a01b03166104da565b34801561094c57600080fd5b5061043961095b366004613d01565b611ddf565b34801561096c57600080fd5b50604080518082019091526004815263444f4e4760e01b6020820152610403565b34801561099957600080fd5b506104396109a8366004613dc9565b611eeb565b3480156109b957600080fd5b506026546104ac565b3480156109ce57600080fd5b5061045b6109dd366004613cd5565b611fa3565b3480156109ee57600080fd5b506003546104da906001600160a01b031681565b348015610a0e57600080fd5b5061045b610a1d366004613cd5565b611ff2565b348015610a2e57600080fd5b5061045b610a3d366004613d01565b60256020526000908152604090205460ff1681565b348015610a5e57600080fd5b5060285461045b90600160b01b900460ff1681565b348015610a7f57600080fd5b50610439610a8e366004613fbd565b611fff565b348015610a9f57600080fd5b506104ac60185481565b348015610ab557600080fd5b506104ac601b5481565b348015610acb57600080fd5b50600a5461045b9060ff1681565b348015610ae557600080fd5b506104ac60215481565b348015610afb57600080fd5b506104ac60175481565b348015610b1157600080fd5b506104ac610b20366004613df7565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b348015610b5757600080fd5b5061045b612076565b348015610b6c57600080fd5b50610439610b7b366004613d01565b6120b1565b348015610b8c57600080fd5b506104ac601c5481565b348015610ba257600080fd5b506104ac60165481565b348015610bb857600080fd5b50610439610bc7366004613d01565b61212c565b348015610bd857600080fd5b50610439612216565b6000546001600160a01b03163314610c145760405162461bcd60e51b8152600401610c0b90613fda565b60405180910390fd5b60c8811015610c2257600080fd5b610c3081633b9aca00614025565b60245550565b6000610c433384846122fb565b5060015b92915050565b6000546001600160a01b03163314610c775760405162461bcd60e51b8152600401610c0b90613fda565b6019839055601a829055601b819055600f81610c938486614044565b610c9d9190614044565b1115610ceb5760405162461bcd60e51b815260206004820152601e60248201527f4d757374206b6565702073656c6c2074617865732062656c6f772031352500006044820152606401610c0b565b60408051828152602081018490529081018490527f5ff33e060dbf96ff8c11eeadaaa320b34884dc8af8156d77ab6134d2bece22c3906060015b60405180910390a1505050565b6000610d3f84848461241f565b610d918433610d8c856040518060600160405280602881526020016141cf602891396001600160a01b038a1660009081526008602090815260408083203384529091529020549190612d17565b6122fb565b5060019392505050565b6000546001600160a01b03163314610dc55760405162461bcd60e51b8152600401610c0b90613fda565b601683905560178290556018819055600a81610de18486614044565b610deb9190614044565b1115610e395760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206275792074617865732062656c6f77203130250000006044820152606401610c0b565b60408051828152602081018490529081018490527f4b44023290188702187818a2359a9d40279e516e5e9bbade40c321936a77362090606001610d25565b6000600e54821115610ede5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610c0b565b6000610ee8612d51565b9050610ef48382612d74565b9392505050565b6000546001600160a01b03163314610f255760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166000908152600c602052604090205460ff16610f8d5760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f74206578636c756465640000000000000000006044820152606401610c0b565b60005b600d548110156110ae57816001600160a01b0316600d8281548110610fb757610fb761405c565b6000918252602090912001546001600160a01b0316141561109c57600d8054610fe290600190614072565b81548110610ff257610ff261405c565b600091825260209091200154600d80546001600160a01b03909216918390811061101e5761101e61405c565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600782526040808220829055600c90925220805460ff19169055600d80548061107657611076614089565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806110a68161409f565b915050610f90565b5050565b3360008181526008602090815260408083206001600160a01b03871684529091528120549091610c43918590610d8c9086612db6565b6000546001600160a01b031633146111125760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166000818152600b6020908152604091829020805460ff1916600117905590519182527f58c3e0504c69d3a92726966f152a771e0f8f6ad4daca1ae9055a38aba1fd2b6291015b60405180910390a150565b600069d3c21bcecceda10000008311156111c95760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610c0b565b816111e85760006111d984612e15565b50939550610c47945050505050565b60006111f384612e15565b50929550610c47945050505050565b6000546001600160a01b0316331461122c5760405162461bcd60e51b8152600401610c0b90613fda565b600061123730611652565b905061124e606469d3c21bcecceda10000006140ba565b8110156112c35760405162461bcd60e51b815260206004820152603e60248201527f43616e206f6e6c792073776170206261636b206966206d6f7265207468616e2060448201527f3125206f6620746f6b656e7320737475636b206f6e20636f6e747261637400006064820152608401610c0b565b6112cb612e64565b6040514281527f1b56c383f4f48fc992e45667ea4eabae777b9cca68b516a9562d8cda78f1bb3290602001611162565b6000546001600160a01b031633146113255760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166000908152600c602052604090205460ff161561138e5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610c0b565b600d5460329061139f906001614044565b11156114295760405162461bcd60e51b815260206004820152604d60248201527f43616e6e6f74206578636c756465206d6f7265207468616e203530206163636f60448201527f756e74732e2020496e636c75646520612070726576696f75736c79206578636c60648201526c3ab232b21030b2323932b9b99760991b608482015260a401610c0b565b6001600160a01b03811660009081526006602052604090205415611483576001600160a01b03811660009081526006602052604090205461146990610e77565b6001600160a01b0382166000908152600760205260409020555b6001600160a01b03166000818152600c60205260408120805460ff19166001908117909155600d805491820181559091527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50180546001600160a01b0319169091179055565b6000546001600160a01b031633146115135760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166115775760405162461bcd60e51b815260206004820152602560248201527f5f6c69717569646974794164647265737320616464726573732063616e6e6f74604482015264020626520360dc1b6064820152608401610c0b565b600580546001600160a01b0319166001600160a01b0383169081179091556000818152600b6020908152604091829020805460ff1916600117905590519182527f217742673c85d2f459a37c99960c860122cdadf529374b41418d2718cae7726f9101611162565b6000546001600160a01b031633146116095760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166000818152601d6020526040808220805460ff19169055517fccaa6e1cfd4cf9506fa856fdc8e0a00894b2621ece1d60ab36209873305944989190a250565b6001600160a01b0381166000908152600c602052604081205460ff161561168f57506001600160a01b031660009081526007602052604090205490565b6001600160a01b038216600090815260066020526040902054610c4790610e77565b6000546001600160a01b031633146116db5760405162461bcd60e51b8152600401610c0b90613fda565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600080546001600160a01b031633146117505760405162461bcd60e51b8152600401610c0b90613fda565b50600a80546023805460ff1916905561ffff19169055600190565b6000546001600160a01b031633146117955760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b03919091166000908152602260205260409020805460ff1916911515919091179055565b600080546001600160a01b031633146117eb5760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0383166118415760405162461bcd60e51b815260206004820152601a60248201527f5f746f6b656e20616464726573732063616e6e6f7420626520300000000000006044820152606401610c0b565b6001600160a01b03831630141561189a5760405162461bcd60e51b815260206004820152601c60248201527f43616e2774207769746864726177206e617469766520746f6b656e73000000006044820152606401610c0b565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156118dc57600080fd5b505afa1580156118f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191491906140dc565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018390529192509085169063a9059cbb90604401602060405180830381600087803b15801561196257600080fd5b505af1158015611976573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199a91906140f5565b604080516001600160a01b0387168152602081018490529193507fdeda980967fcead7b61e78ac46a4da14274af29e894d4d61e8b81ec38ab3e438910160405180910390a15092915050565b600080546001600160a01b03163314611a115760405162461bcd60e51b8152600401610c0b90613fda565b602854600160b01b900460ff1615611a7f5760405162461bcd60e51b815260206004820152602b60248201527f54726164696e6720697320616c7265616479206163746976652c2063616e6e6f60448201526a3a103932b630bab731b41760a91b6064820152608401610c0b565b60c8835110611aef5760405162461bcd60e51b815260206004820152603660248201527f43616e206f6e6c792061697264726f70203230302077616c6c657473207065726044820152752074786e2064756520746f20676173206c696d69747360501b6064820152608401610c0b565b60005b8351811015611b57576000848281518110611b0f57611b0f61405c565b602002602001015190506000848381518110611b2d57611b2d61405c565b60200260200101519050611b4233838361241f565b50508080611b4f9061409f565b915050611af2565b50611b606130b7565b737a250d5630b4cf539739df2c5dacb4c659f2488d611b8081600161176b565b602780546001600160a01b0319166001600160a01b038316908117909155611bb490309069d3c21bcecceda10000006122fb565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611bed57600080fd5b505afa158015611c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c259190614112565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c6d57600080fd5b505afa158015611c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca59190614112565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015611ced57600080fd5b505af1158015611d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d259190614112565b602880546001600160a01b0319166001600160a01b03929092169182179055611d4f90600161176b565b602854611d66906001600160a01b0316600161310c565b60004711611dc25760405162461bcd60e51b815260206004820152602360248201527f4d757374206861766520455448206f6e20636f6e747261637420746f206c61756044820152620dcc6d60eb1b6064820152608401610c0b565b611dd4611dce30611652565b47613167565b610d9161dead6114e9565b6000546001600160a01b03163314611e095760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b038116611e6d5760405162461bcd60e51b815260206004820152602560248201527f5f6d61726b6574696e674164647265737320616464726573732063616e6e6f74604482015264020626520360dc1b6064820152608401610c0b565b600380546001600160a01b039081166000908152600b60209081526040808320805460ff1990811690915585546001600160a01b031916948716948517909555838352918290208054909416600117909355519081527fd1e7d6a3390dd5008bd1c57798817b9f806e4c417264e7d3d67e42e784dc24a99101611162565b6000546001600160a01b03163314611f155760405162461bcd60e51b8152600401610c0b90613fda565b6028546001600160a01b0383811691161415611f995760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c0b565b6110ae828261310c565b6000610c433384610d8c856040518060600160405280602581526020016141f7602591393360009081526008602090815260408083206001600160a01b038d1684529091529020549190612d17565b6000610c4333848461241f565b6000546001600160a01b031633146120295760405162461bcd60e51b8152600401610c0b90613fda565b60288054821515600160a81b0260ff60a81b199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061116290831515815260200190565b600080546001600160a01b031633146120a15760405162461bcd60e51b8152600401610c0b90613fda565b50600a805460ff19169055600190565b6000546001600160a01b031633146120db5760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166000818152600b6020908152604091829020805460ff1916905590519182527f4f6a6b6efe34ec6478021aa9fb7f6980e78ea3a10c74074a8ce49d5d3ebf1f7e9101611162565b6000546001600160a01b031633146121565760405162461bcd60e51b8152600401610c0b90613fda565b6001600160a01b0381166121bb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c0b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146122405760405162461bcd60e51b8152600401610c0b90613fda565b602854600160b01b900460ff16156122ae5760405162461bcd60e51b815260206004820152602b60248201527f43616e206f6e6c792077697468647261772069662074726164696e672068617360448201526a1b89dd081cdd185c9d195960aa1b6064820152608401610c0b565b604051600090339047908381818185875af1925050503d80600081146122f0576040519150601f19603f3d011682016040523d82523d6000602084013e6122f5565b606091505b50505050565b6001600160a01b03831661235d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c0b565b6001600160a01b0382166123be5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c0b565b6001600160a01b0383811660008181526008602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166124835760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610c0b565b6001600160a01b0382166124e55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610c0b565b600081116125475760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610c0b565b602854600160b01b900460ff166125e3576001600160a01b0383166000908152600b602052604090205460ff168061259757506001600160a01b0382166000908152600b602052604090205460ff165b6125e35760405162461bcd60e51b815260206004820152601a60248201527f54726164696e67206973206e6f7420616374697665207965742e0000000000006044820152606401610c0b565b600a54610100900460ff16156129f1576000546001600160a01b0384811691161480159061261f57506000546001600160a01b03838116911614155b801561263357506001600160a01b03821615155b801561264a57506001600160a01b03821661dead14155b80156126605750602854600160a01b900460ff16155b156129f1576000546001600160a01b0384811691161480159061269157506028546001600160a01b03838116911614155b801561269e5750601c5443145b156126ed576001600160a01b0382166000818152601d6020526040808220805460ff19166001179055517fb90badc1cf1c52268f4fa9afb5276aebf640bcca3300cdfc9cf37db17daa13e29190a25b60235460ff16801561271757506001600160a01b03831660009081526025602052604090205460ff165b1561276e576024543a111561276e5760405162461bcd60e51b815260206004820152601860248201527f4761732070726963652065786365656473206c696d69742e00000000000000006044820152606401610c0b565b600a5460ff161561287f576000546001600160a01b038381169116148015906127a557506027546001600160a01b03838116911614155b80156127bf57506028546001600160a01b03838116911614155b1561287f576001600160a01b03821660009081526009602052604090205443116128635760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c0b565b6001600160a01b03821660009081526009602052604090204390555b6001600160a01b03831660009081526025602052604090205460ff1680156128c057506001600160a01b03821660009081526022602052604090205460ff16155b1561293a576021548111156129355760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c0b565b6129f1565b6001600160a01b03821660009081526025602052604090205460ff16801561297b57506001600160a01b03831660009081526022602052604090205460ff16155b156129f1576021548111156129f15760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c0b565b6000612a0a602054601f54612db690919063ffffffff16565b90506000612a1730611652565b60265460285491925082101590600160a01b900460ff16158015612a445750602854600160a81b900460ff165b8015612a655750602854600090612a63906001600160a01b0316611652565b115b8015612a715750600083115b8015612a9657506001600160a01b0385166000908152600b602052604090205460ff16155b8015612abb57506001600160a01b0386166000908152600b602052604090205460ff16155b8015612adf57506001600160a01b03851660009081526025602052604090205460ff165b8015612ae85750805b15612af557612af5612e64565b6001600160a01b0386166000908152600b602052604090205460019060ff1680612b3757506001600160a01b0386166000908152600b602052604090205460ff165b15612b49575060036015556000612d02565b6001600160a01b03871660009081526025602052604090205460ff1615612b9557612b7261322a565b601654601055601854601754612b889190614044565b6013556001601555612d02565b6001600160a01b03861660009081526025602052604090205460ff1615612c3257612bbe61322a565b601954601055601b54601a54612bd49190614044565b60135560026015556001600160a01b0387166000908152601d602052604090205460ff168015612c05575042601e54115b15612c2d57601054612c18906005614025565b601055601354612c29906005614025565b6013555b612d02565b6001600160a01b0387166000908152601d602052604090205460ff161580612c5c575042601e5411155b612cf45760405162461bcd60e51b815260206004820152605960248201527f536e69706572732063616e2774207472616e7366657220746f6b656e7320746f60448201527f2073656c6c206368656170657220756e74696c2070656e616c74792074696d6560648201527f6672616d65206973206f7665722e2020444d2061204d6f642e00000000000000608482015260a401610c0b565b612cfc61322a565b60036015555b612d0e87878784613258565b50505050505050565b60008184841115612d3b5760405162461bcd60e51b8152600401610c0b9190613c4f565b506000612d488486614072565b95945050505050565b6000806000612d5e61337d565b9092509050612d6d8282612d74565b9250505090565b6000610ef483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061351d565b600080612dc38385614044565b905083811015610ef45760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610c0b565b6000806000806000806000806000612e2c8a61354b565b9250925092506000806000612e4a8d8686612e45612d51565b61358d565b919f909e50909c50959a5093985091965092945050505050565b6028805460ff60a01b1916600160a01b1790556000612e8230611652565b90506000602054601f54612e969190614044565b90506000612eb06002601f54612d7490919063ffffffff16565b90506000612ebe84836135dd565b905047612eca8261361f565b6000612ed647836135dd565b90506000612ef986612ef36020548561378890919063ffffffff16565b90612d74565b90506000612f0783836135dd565b905060006007612f18846002614025565b612f2291906140ba565b9050612f2e8184614072565b6000601f819055602081905560035460405192955090916001600160a01b039091169085908381818185875af1925050503d8060008114612f8b576040519150601f19603f3d011682016040523d82523d6000602084013e612f90565b606091505b50506004546040519192506001600160a01b0316908390600081818185875af1925050503d8060008114612fe0576040519150601f19603f3d011682016040523d82523d6000602084013e612fe5565b606091505b505080915050612ff58884613167565b60408051888152602081018590529081018990527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a167016345785d8a000047111561309e576003546040516001600160a01b03909116904790600081818185875af1925050503d8060008114613093576040519150601f19603f3d011682016040523d82523d6000602084013e613098565b606091505b50909150505b50506028805460ff60a01b191690555050505050505050565b6000546001600160a01b031633146130e15760405162461bcd60e51b8152600401610c0b90613fda565b6028805461ffff60a81b191661010160a81b17905543601c55613107426203f480614044565b601e55565b6001600160a01b038216600090815260256020908152604080832080548515801560ff199283168117909355602290945291909320805490911690921790915561315957613159826112fb565b806110ae576110ae82610efb565b60275461317f9030906001600160a01b0316846122fb565b60275460055460405163f305d71960e01b81523060048201526024810185905260006044820181905260648201526001600160a01b0391821660848201524260a482015291169063f305d71990839060c4016060604051808303818588803b1580156131ea57600080fd5b505af11580156131fe573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613223919061412f565b5050505050565b60105415801561323a5750601354155b1561324157565b601080546011556013805460145560009182905555565b806132655761326561322a565b6001600160a01b0384166000908152600c602052604090205460ff1680156132a657506001600160a01b0383166000908152600c602052604090205460ff16155b156132bb576132b6848484613807565b613367565b6001600160a01b0384166000908152600c602052604090205460ff161580156132fc57506001600160a01b0383166000908152600c602052604090205460ff165b1561330c576132b684848461392d565b6001600160a01b0384166000908152600c602052604090205460ff16801561334c57506001600160a01b0383166000908152600c602052604090205460ff165b1561335c576132b68484846139d6565b613367848484613a49565b806122f5576122f5601154601055601454601355565b600e54600090819069d3c21bcecceda1000000825b600d548110156134de578260066000600d84815481106133b4576133b461405c565b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061341f57508160076000600d84815481106133f8576133f861405c565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561343c575050600e549369d3c21bcecceda10000009350915050565b61348260066000600d84815481106134565761345661405c565b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906135dd565b92506134ca60076000600d848154811061349e5761349e61405c565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906135dd565b9150806134d68161409f565b915050613392565b50600e546134f69069d3c21bcecceda1000000612d74565b821015613514575050600e549269d3c21bcecceda100000092509050565b90939092509050565b6000818361353e5760405162461bcd60e51b8152600401610c0b9190613c4f565b506000612d4884866140ba565b60008060008061355a85613a8d565b9050600061356786613aa9565b9050600061357f8261357989866135dd565b906135dd565b979296509094509092505050565b600080808061359c8886613788565b905060006135aa8887613788565b905060006135b88888613788565b905060006135ca8261357986866135dd565b939b939a50919850919650505050505050565b6000610ef483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612d17565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106136545761365461405c565b6001600160a01b03928316602091820292909201810191909152602754604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156136a857600080fd5b505afa1580156136bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136e09190614112565b816001815181106136f3576136f361405c565b6001600160a01b03928316602091820292909201015260275461371991309116846122fb565b60275460405163791ac94760e01b81526001600160a01b039091169063791ac9479061375290859060009086903090429060040161415d565b600060405180830381600087803b15801561376c57600080fd5b505af1158015613780573d6000803e3d6000fd5b505050505050565b60008261379757506000610c47565b60006137a38385614025565b9050826137b085836140ba565b14610ef45760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610c0b565b60008060008060008061381987612e15565b6001600160a01b038f16600090815260076020526040902054959b5093995091975095509350915061384b90886135dd565b6001600160a01b038a1660009081526007602090815260408083209390935560069052205461387a90876135dd565b6001600160a01b03808b1660009081526006602052604080822093909355908a16815220546138a99086612db6565b6001600160a01b0389166000908152600660205260409020556138cb81613ac5565b6138d58483613c2b565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161391a91815260200190565b60405180910390a3505050505050505050565b60008060008060008061393f87612e15565b6001600160a01b038f16600090815260066020526040902054959b5093995091975095509350915061397190876135dd565b6001600160a01b03808b16600090815260066020908152604080832094909455918b168152600790915220546139a79084612db6565b6001600160a01b0389166000908152600760209081526040808320939093556006905220546138a99086612db6565b6000806000806000806139e887612e15565b6001600160a01b038f16600090815260076020526040902054959b50939950919750955093509150613a1a90886135dd565b6001600160a01b038a1660009081526007602090815260408083209390935560069052205461397190876135dd565b600080600080600080613a5b87612e15565b6001600160a01b038f16600090815260066020526040902054959b5093995091975095509350915061387a90876135dd565b6000610c476064612ef36010548561378890919063ffffffff16565b6000610c476064612ef36013548561378890919063ffffffff16565b60016015541415613b3657601354601754613ae09083614025565b613aea91906140ba565b601f6000828254613afb9190614044565b9091555050601354601854613b109083614025565b613b1a91906140ba565b60206000828254613b2b9190614044565b90915550613ba29050565b60026015541415613ba257601354601a54613b519083614025565b613b5b91906140ba565b601f6000828254613b6c9190614044565b9091555050601354601b54613b819083614025565b613b8b91906140ba565b60206000828254613b9c9190614044565b90915550505b6000613bac612d51565b90506000613bba8383613788565b30600090815260066020526040902054909150613bd79082612db6565b30600090815260066020908152604080832093909355600c9052205460ff1615613c265730600090815260076020526040902054613c159084612db6565b306000908152600760205260409020555b505050565b600e54613c3890836135dd565b600e55600f54613c489082612db6565b600f555050565b600060208083528351808285015260005b81811015613c7c57858101830151858201604001528201613c60565b81811115613c8e576000604083870101525b50601f01601f1916929092016040019392505050565b600060208284031215613cb657600080fd5b5035919050565b6001600160a01b0381168114613cd257600080fd5b50565b60008060408385031215613ce857600080fd5b8235613cf381613cbd565b946020939093013593505050565b600060208284031215613d1357600080fd5b8135610ef481613cbd565b600080600060608486031215613d3357600080fd5b505081359360208301359350604090920135919050565b600080600060608486031215613d5f57600080fd5b8335613d6a81613cbd565b92506020840135613d7a81613cbd565b929592945050506040919091013590565b8015158114613cd257600080fd5b60008060408385031215613dac57600080fd5b823591506020830135613dbe81613d8b565b809150509250929050565b60008060408385031215613ddc57600080fd5b8235613de781613cbd565b91506020830135613dbe81613d8b565b60008060408385031215613e0a57600080fd5b8235613e1581613cbd565b91506020830135613dbe81613cbd565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613e6457613e64613e25565b604052919050565b600067ffffffffffffffff821115613e8657613e86613e25565b5060051b60200190565b600082601f830112613ea157600080fd5b81356020613eb6613eb183613e6c565b613e3b565b82815260059290921b84018101918181019086841115613ed557600080fd5b8286015b84811015613ef05780358352918301918301613ed9565b509695505050505050565b60008060408385031215613f0e57600080fd5b823567ffffffffffffffff80821115613f2657600080fd5b818501915085601f830112613f3a57600080fd5b81356020613f4a613eb183613e6c565b82815260059290921b84018101918181019089841115613f6957600080fd5b948201945b83861015613f90578535613f8181613cbd565b82529482019490820190613f6e565b96505086013592505080821115613fa657600080fd5b50613fb385828601613e90565b9150509250929050565b600060208284031215613fcf57600080fd5b8135610ef481613d8b565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561403f5761403f61400f565b500290565b600082198211156140575761405761400f565b500190565b634e487b7160e01b600052603260045260246000fd5b6000828210156140845761408461400f565b500390565b634e487b7160e01b600052603160045260246000fd5b60006000198214156140b3576140b361400f565b5060010190565b6000826140d757634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156140ee57600080fd5b5051919050565b60006020828403121561410757600080fd5b8151610ef481613d8b565b60006020828403121561412457600080fd5b8151610ef481613cbd565b60008060006060848603121561414457600080fd5b8351925060208401519150604084015190509250925092565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156141ad5784516001600160a01b031683529383019391830191600101614188565b50506001600160a01b0396909616606085015250505060800152939250505056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d67f3c38eab90e49fde01dba7d5990677252145569c0bc59ffd8226429c04bd264736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2581, 2497, 19481, 17914, 23499, 2497, 12376, 27531, 21926, 2575, 7875, 2497, 2692, 2098, 7011, 24087, 2683, 20842, 16703, 2620, 19841, 2094, 23833, 2683, 2487, 1013, 1008, 5622, 4160, 1024, 1016, 1003, 5821, 1024, 1020, 1003, 16475, 1024, 1018, 1003, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1023, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 3477, 3085, 1007, 1063, 2709, 3477, 3085, 1006, 5796, 2290, 1012, 4604, 2121, 1007, 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, 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,992
0x97B380Ae50160E400d68c92ABeAf24402C9CaA62
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "../StrategyCommon.sol"; contract Arbitrary is StrategyCommon { /** @notice a strategy is dedicated to exactly one oneToken instance @param oneTokenFactory_ bind this instance to oneTokenFactory instance @param oneToken_ bind this instance to one oneToken vault @param description_ metadata has no impact on logic */ constructor(address oneTokenFactory_, address oneToken_, string memory description_) StrategyCommon(oneTokenFactory_, oneToken_, description_) {} /** @notice Governance can work with collateral and treasury assets. Can swap assets. @param target address/smart contract you are interacting with @param value msg.value (amount of eth in WEI you are sending. Most of the time it is 0) @param signature the function signature @param data abi-encodeded bytecode of the parameter values to send */ function executeTransaction(address target, uint256 value, string memory signature, bytes memory data) external onlyOwner returns (bytes memory) { bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call{ value: value }(callData); require(success, "OneTokenV1::executeTransaction: Transaction execution reverted."); return returnData; } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "../interface/IOneTokenFactory.sol"; import "../interface/IStrategy.sol"; import "../interface/IOneTokenV1Base.sol"; import "../_openzeppelin/token/ERC20/IERC20.sol"; import "../_openzeppelin/token/ERC20/SafeERC20.sol"; import "../common/ICHIModuleCommon.sol"; abstract contract StrategyCommon is IStrategy, ICHIModuleCommon { using SafeERC20 for IERC20; address public override oneToken; bytes32 constant public override MODULE_TYPE = keccak256(abi.encodePacked("ICHI V1 Strategy Implementation")); event StrategyDeployed(address sender, address oneTokenFactory, address oneToken_, string description); event StrategyInitialized(address sender); event StrategyExecuted(address indexed sender, address indexed token); event VaultAllowance(address indexed sender, address indexed token, uint256 amount); event FromVault(address indexed sender, address indexed token, uint256 amount); event ToVault(address indexed sender, address indexed token, uint256 amount); modifier onlyToken { require(msg.sender == oneToken, "StrategyCommon: initialize from oneToken instance"); _; } /** @dev oneToken governance has privileges that may be delegated to a controller */ modifier strategyOwnerTokenOrController { if(msg.sender != oneToken) { if(msg.sender != IOneTokenV1Base(oneToken).controller()) { require(msg.sender == IOneTokenV1Base(oneToken).owner(), "StrategyCommon: not token controller or owner."); } } _; } /** @notice a strategy is dedicated to exactly one oneToken instance @param oneTokenFactory_ bind this instance to oneTokenFactory instance @param oneToken_ bind this instance to one oneToken vault @param description_ metadata has no impact on logic */ constructor(address oneTokenFactory_, address oneToken_, string memory description_) ICHIModuleCommon(oneTokenFactory_, ModuleType.Strategy, description_) { require(oneToken_ != NULL_ADDRESS, "StrategyCommon: oneToken cannot be NULL"); require(IOneTokenFactory(IOneTokenV1Base(oneToken_).oneTokenFactory()).isOneToken(oneToken_), "StrategyCommon: oneToken is unknown"); oneToken = oneToken_; emit StrategyDeployed(msg.sender, oneTokenFactory_, oneToken_, description_); } /** @notice a strategy is dedicated to exactly one oneToken instance and must be re-initializable */ function init() external onlyToken virtual override { IERC20(oneToken).safeApprove(oneToken, 0); IERC20(oneToken).safeApprove(oneToken, INFINITE); emit StrategyInitialized(oneToken); } /** @notice a controller invokes execute() to trigger automated logic within the strategy. @dev called from oneToken governance or the active controller. Overriding function should emit the event. */ function execute() external virtual strategyOwnerTokenOrController override { // emit StrategyExecuted(msg.sender, oneToken); } /** @notice gives the oneToken control of tokens deposited in the strategy @dev called from oneToken governance or the active controller @param token the asset @param amount the allowance. 0 = infinte */ function setAllowance(address token, uint256 amount) external strategyOwnerTokenOrController override { if(amount == 0) amount = INFINITE; IERC20(token).safeApprove(oneToken, 0); IERC20(token).safeApprove(oneToken, amount); emit VaultAllowance(msg.sender, token, amount); } /** @notice closes all positions and returns the funds to the oneToken vault @dev override this function to withdraw funds from external contracts. Return false if any funds are unrecovered. */ function closeAllPositions() external virtual strategyOwnerTokenOrController override returns(bool success) { success = _closeAllPositions(); } /** @notice closes all positions and returns the funds to the oneToken vault @dev override this function to withdraw funds from external contracts. Return false if any funds are unrecovered. */ function _closeAllPositions() internal virtual returns(bool success) { uint256 assetCount; success = true; assetCount = IOneTokenV1Base(oneToken).assetCount(); for(uint256 i=0; i < assetCount; i++) { address thisAsset = IOneTokenV1Base(oneToken).assetAtIndex(i); closePositions(thisAsset); } } /** @notice closes token positions and returns the funds to the oneToken vault @dev override this function to redeem and withdraw related funds from external contracts. Return false if any funds are unrecovered. @param token asset to recover @param success true, complete success, false, 1 or more failed operations */ function closePositions(address token) public strategyOwnerTokenOrController override virtual returns(bool success) { // this naive process returns funds on hand. // override this to explicitly close external positions and return false if 1 or more positions cannot be closed at this time. success = true; uint256 strategyBalance = IERC20(token).balanceOf(address(this)); if(strategyBalance > 0) { _toVault(token, strategyBalance); } } /** @notice let's the oneToken controller instance send funds to the oneToken vault @dev implementations must close external positions and return all related assets to the vault @param token the ecr20 token to send @param amount the amount of tokens to send */ function toVault(address token, uint256 amount) external strategyOwnerTokenOrController override { _toVault(token, amount); } /** @notice close external positions send all related funds to the oneToken vault @param token the ecr20 token to send @param amount the amount of tokens to send */ function _toVault(address token, uint256 amount) internal { IERC20(token).safeTransfer(oneToken, amount); emit ToVault(msg.sender, token, amount); } /** @notice let's the oneToken controller instance draw funds from the oneToken vault allowance @param token the ecr20 token to send @param amount the amount of tokens to send */ function fromVault(address token, uint256 amount) external strategyOwnerTokenOrController override { _fromVault(token, amount); } /** @notice draw funds from the oneToken vault @param token the ecr20 token to send @param amount the amount of tokens to send */ function _fromVault(address token, uint256 amount) internal { IERC20(token).safeTransferFrom(oneToken, address(this), amount); emit FromVault(msg.sender, token, amount); } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "./InterfaceCommon.sol"; interface IOneTokenFactory is InterfaceCommon { function oneTokenProxyAdmins(address) external returns(address); function deployOneTokenProxy( string memory name, string memory symbol, address governance, address version, address controller, address mintMaster, address memberToken, address collateral, address oneTokenOracle ) external returns(address newOneTokenProxy, address proxyAdmin); function admitModule(address module, ModuleType moduleType, string memory name, string memory url) external; function updateModule(address module, string memory name, string memory url) external; function removeModule(address module) external; function admitForeignToken(address foreignToken, bool collateral, address oracle) external; function updateForeignToken(address foreignToken, bool collateral) external; function removeForeignToken(address foreignToken) external; function assignOracle(address foreignToken, address oracle) external; function removeOracle(address foreignToken, address oracle) external; /** * View functions */ function MODULE_TYPE() external view returns(bytes32); function oneTokenCount() external view returns(uint256); function oneTokenAtIndex(uint256 index) external view returns(address); function isOneToken(address oneToken) external view returns(bool); // modules function moduleCount() external view returns(uint256); function moduleAtIndex(uint256 index) external view returns(address module); function isModule(address module) external view returns(bool); function isValidModuleType(address module, ModuleType moduleType) external view returns(bool); // foreign tokens function foreignTokenCount() external view returns(uint256); function foreignTokenAtIndex(uint256 index) external view returns(address); function foreignTokenInfo(address foreignToken) external view returns(bool collateral, uint256 oracleCount); function foreignTokenOracleCount(address foreignToken) external view returns(uint256); function foreignTokenOracleAtIndex(address foreignToken, uint256 index) external view returns(address); function isOracle(address foreignToken, address oracle) external view returns(bool); function isForeignToken(address foreignToken) external view returns(bool); function isCollateral(address foreignToken) external view returns(bool); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "./IModule.sol"; interface IStrategy is IModule { function init() external; function execute() external; function setAllowance(address token, uint256 amount) external; function toVault(address token, uint256 amount) external; function fromVault(address token, uint256 amount) external; function closeAllPositions() external returns(bool); function closePositions(address token) external returns(bool success); function oneToken() external view returns(address); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "./IICHICommon.sol"; import "./IERC20Extended.sol"; interface IOneTokenV1Base is IICHICommon, IERC20 { function init(string memory name_, string memory symbol_, address oneTokenOracle_, address controller_, address mintMaster_, address memberToken_, address collateral_) external; function changeController(address controller_) external; function changeMintMaster(address mintMaster_, address oneTokenOracle) external; function addAsset(address token, address oracle) external; function removeAsset(address token) external; function setStrategy(address token, address strategy, uint256 allowance) external; function executeStrategy(address token) external; function removeStrategy(address token) external; function closeStrategy(address token) external; function increaseStrategyAllowance(address token, uint256 amount) external; function decreaseStrategyAllowance(address token, uint256 amount) external; function setFactory(address newFactory) external; function MODULE_TYPE() external view returns(bytes32); function oneTokenFactory() external view returns(address); function controller() external view returns(address); function mintMaster() external view returns(address); function memberToken() external view returns(address); function assets(address) external view returns(address, address); function balances(address token) external view returns(uint256 inVault, uint256 inStrategy); function collateralTokenCount() external view returns(uint256); function collateralTokenAtIndex(uint256 index) external view returns(address); function isCollateral(address token) external view returns(bool); function otherTokenCount() external view returns(uint256); function otherTokenAtIndex(uint256 index) external view returns(address); function isOtherToken(address token) external view returns(bool); function assetCount() external view returns(uint256); function assetAtIndex(uint256 index) external view returns(address); function isAsset(address token) external view returns(bool); } // 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 "./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: BUSL-1.1 pragma solidity 0.7.6; import "../interface/IModule.sol"; import "../interface/IOneTokenFactory.sol"; import "../interface/IOneTokenV1Base.sol"; import "./ICHICommon.sol"; abstract contract ICHIModuleCommon is IModule, ICHICommon { ModuleType public immutable override moduleType; string public override moduleDescription; address public immutable override oneTokenFactory; event ModuleDeployed(address sender, ModuleType moduleType, string description); event DescriptionUpdated(address sender, string description); modifier onlyKnownToken { require(IOneTokenFactory(oneTokenFactory).isOneToken(msg.sender), "ICHIModuleCommon: msg.sender is not a known oneToken"); _; } modifier onlyTokenOwner (address oneToken) { require(msg.sender == IOneTokenV1Base(oneToken).owner(), "ICHIModuleCommon: msg.sender is not oneToken owner"); _; } modifier onlyModuleOrFactory { if(!IOneTokenFactory(oneTokenFactory).isModule(msg.sender)) { require(msg.sender == oneTokenFactory, "ICHIModuleCommon: msg.sender is not module owner, token factory or registed module"); } _; } /** @notice modules are bound to the factory at deployment time @param oneTokenFactory_ factory to bind to @param moduleType_ type number helps prevent governance errors @param description_ human-readable, descriptive only */ constructor (address oneTokenFactory_, ModuleType moduleType_, string memory description_) { require(oneTokenFactory_ != NULL_ADDRESS, "ICHIModuleCommon: oneTokenFactory cannot be empty"); require(bytes(description_).length > 0, "ICHIModuleCommon: description cannot be empty"); oneTokenFactory = oneTokenFactory_; moduleType = moduleType_; moduleDescription = description_; emit ModuleDeployed(msg.sender, moduleType_, description_); } /** @notice set a module description @param description new module desciption */ function updateDescription(string memory description) external onlyOwner override { require(bytes(description).length > 0, "ICHIModuleCommon: description cannot be empty"); moduleDescription = description; emit DescriptionUpdated(msg.sender, description); } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; interface InterfaceCommon { enum ModuleType { Version, Controller, Strategy, MintMaster, Oracle } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "./IICHICommon.sol"; import "./InterfaceCommon.sol"; interface IModule is IICHICommon { function oneTokenFactory() external view returns(address); function updateDescription(string memory description) external; function moduleDescription() external view returns(string memory); function MODULE_TYPE() external view returns(bytes32); function moduleType() external view returns(ModuleType); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "./IICHIOwnable.sol"; import "./InterfaceCommon.sol"; interface IICHICommon is IICHIOwnable, InterfaceCommon {} // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; interface IICHIOwnable { function renounceOwnership() external; function transferOwnership(address newOwner) external; function owner() external view returns (address); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "../_openzeppelin/token/ERC20/IERC20.sol"; interface IERC20Extended is IERC20 { function decimals() external view returns(uint8); function symbol() external view returns(string memory); function name() external view returns(string memory); } // 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.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: BUSL-1.1 pragma solidity 0.7.6; import "../oz_modified/ICHIOwnable.sol"; import "../oz_modified/ICHIInitializable.sol"; import "../interface/IERC20Extended.sol"; import "../interface/IICHICommon.sol"; contract ICHICommon is IICHICommon, ICHIOwnable, ICHIInitializable { uint256 constant PRECISION = 10 ** 18; uint256 constant INFINITE = uint256(0-1); address constant NULL_ADDRESS = address(0); // @dev internal fingerprints help prevent deployment-time governance errors bytes32 constant COMPONENT_CONTROLLER = keccak256(abi.encodePacked("ICHI V1 Controller")); bytes32 constant COMPONENT_VERSION = keccak256(abi.encodePacked("ICHI V1 OneToken Implementation")); bytes32 constant COMPONENT_STRATEGY = keccak256(abi.encodePacked("ICHI V1 Strategy Implementation")); bytes32 constant COMPONENT_MINTMASTER = keccak256(abi.encodePacked("ICHI V1 MintMaster Implementation")); bytes32 constant COMPONENT_ORACLE = keccak256(abi.encodePacked("ICHI V1 Oracle Implementation")); bytes32 constant COMPONENT_VOTERROLL = keccak256(abi.encodePacked("ICHI V1 VoterRoll Implementation")); bytes32 constant COMPONENT_FACTORY = keccak256(abi.encodePacked("ICHI OneToken Factory")); } // SPDX-License-Identifier: MIT /** * @dev Constructor visibility has been removed from the original. * _transferOwnership() has been added to support proxied deployments. * Abstract tag removed from contract block. * Added interface inheritance and override modifiers. * Changed contract identifier in require error messages. */ pragma solidity >=0.6.0 <0.8.0; import "../_openzeppelin/utils/Context.sol"; import "../interface/IICHIOwnable.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 ICHIOwnable is IICHIOwnable, Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "ICHIOwnable: caller is not the owner"); _; } /** * @dev Initializes the contract setting the deployer as the initial owner. * Ineffective for proxied deployed. Use initOwnable. */ constructor() { _transferOwnership(msg.sender); } /** @dev initialize proxied deployment */ function initOwnable() internal { require(owner() == address(0), "ICHIOwnable: already initialized"); _transferOwnership(msg.sender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual override returns (address) { return _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 override 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 override onlyOwner { _transferOwnership(newOwner); } /** * @dev be sure to call this in the initialization stage of proxied deployment or owner will not be set */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "ICHIOwnable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "../_openzeppelin/utils/Address.sol"; contract ICHIInitializable { bool private _initialized; bool private _initializing; modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "ICHIInitializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } modifier initialized { require(_initialized, "ICHIInitializable: contract is not initialized"); _; } function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } } // 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; } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c80638da5cb5b116100a2578063b5966db811610071578063b5966db8146103ea578063caa6241f146103f2578063e1c7392a1461041e578063e735b48a14610426578063f2fde38b146104cc5761010b565b80638da5cb5b146103ae578063910ed6ec146103d2578063a2729c23146103da578063a27eccc1146103e25761010b565b80635937caf0116100de5780635937caf01461033b57806361461954146103755780636465e69f1461037d578063715018a6146103a65761010b565b80632224fa2514610110578063310ec4a7146102c75780634e68897e146102f55780635775029f14610321575b600080fd5b6102526004803603608081101561012657600080fd5b6001600160a01b038235169160208101359181019060608101604082013564010000000081111561015657600080fd5b82018360208201111561016857600080fd5b8035906020019184600183028401116401000000008311171561018a57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092959493602081019350359150506401000000008111156101dd57600080fd5b8201836020820111156101ef57600080fd5b8035906020019184600183028401116401000000008311171561021157600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506104f2945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561028c578181015183820152602001610274565b50505050905090810190601f1680156102b95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102f3600480360360408110156102dd57600080fd5b506001600160a01b0381351690602001356106d9565b005b6102f36004803603604081101561030b57600080fd5b506001600160a01b0381351690602001356108b7565b610329610a20565b60408051918252519081900360200190f35b6103616004803603602081101561035157600080fd5b50356001600160a01b0316610a6a565b604080519115158252519081900360200190f35b6102f3610c5f565b610385610dbc565b6040518082600481111561039557fe5b815260200191505060405180910390f35b6102f3610de0565b6103b6610e88565b604080516001600160a01b039092168252519081900360200190f35b610361610e97565b6103b6611002565b6103b6611026565b610252611035565b6102f36004803603604081101561040857600080fd5b506001600160a01b0381351690602001356110c2565b6102f3611227565b6102f36004803603602081101561043c57600080fd5b81019060208101813564010000000081111561045757600080fd5b82018360208201111561046957600080fd5b8035906020019184600183028401116401000000008311171561048b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506112e2945050505050565b6102f3600480360360208110156104e257600080fd5b50356001600160a01b0316611441565b60606104fc6114ab565b6001600160a01b031661050d610e88565b6001600160a01b0316146105525760405162461bcd60e51b8152600401808060200182810382526024815260200180611ca56024913960400191505060405180910390fd5b60608351600014156105655750816105e8565b83805190602001208360405160200180836001600160e01b031916815260040182805190602001908083835b602083106105b05780518252601f199092019160209182019101610591565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405290505b600080876001600160a01b031687846040518082805190602001908083835b602083106106265780518252601f199092019160209182019101610607565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610688576040519150601f19603f3d011682016040523d82523d6000602084013e61068d565b606091505b5091509150816106ce5760405162461bcd60e51b815260040180806020018281038252603f815260200180611d21603f913960400191505060405180910390fd5b979650505050505050565b6002546001600160a01b0316331461083457600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561073957600080fd5b505afa15801561074d573d6000803e3d6000fd5b505050506040513d602081101561076357600080fd5b50516001600160a01b0316331461083457600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107c257600080fd5b505afa1580156107d6573d6000803e3d6000fd5b505050506040513d60208110156107ec57600080fd5b50516001600160a01b031633146108345760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b8061083e57506000195b600254610859906001600160a01b03848116911660006114af565b600254610873906001600160a01b038481169116836114af565b6040805182815290516001600160a01b0384169133917f667b90566f78a7a406a133b1a8b9e1a3c9c0bef9a7e394b89ed9e0bd4fb0369f9181900360200190a35050565b6002546001600160a01b03163314610a1257600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561091757600080fd5b505afa15801561092b573d6000803e3d6000fd5b505050506040513d602081101561094157600080fd5b50516001600160a01b03163314610a1257600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109a057600080fd5b505afa1580156109b4573d6000803e3d6000fd5b505050506040513d60208110156109ca57600080fd5b50516001600160a01b03163314610a125760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b610a1c82826115c7565b5050565b60405160200180807f4943484920563120537472617465677920496d706c656d656e746174696f6e00815250601f0190506040516020818303038152906040528051906020012081565b6002546000906001600160a01b03163314610bc857600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610acd57600080fd5b505afa158015610ae1573d6000803e3d6000fd5b505050506040513d6020811015610af757600080fd5b50516001600160a01b03163314610bc857600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b5657600080fd5b505afa158015610b6a573d6000803e3d6000fd5b505050506040513d6020811015610b8057600080fd5b50516001600160a01b03163314610bc85760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b600190506000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610c1b57600080fd5b505afa158015610c2f573d6000803e3d6000fd5b505050506040513d6020811015610c4557600080fd5b505190508015610c5957610c5983826115c7565b50919050565b6002546001600160a01b03163314610dba57600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610cbf57600080fd5b505afa158015610cd3573d6000803e3d6000fd5b505050506040513d6020811015610ce957600080fd5b50516001600160a01b03163314610dba57600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d4857600080fd5b505afa158015610d5c573d6000803e3d6000fd5b505050506040513d6020811015610d7257600080fd5b50516001600160a01b03163314610dba5760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b565b7f000000000000000000000000000000000000000000000000000000000000000281565b610de86114ab565b6001600160a01b0316610df9610e88565b6001600160a01b031614610e3e5760405162461bcd60e51b8152600401808060200182810382526024815260200180611ca56024913960400191505060405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6002546000906001600160a01b03163314610ff557600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610efa57600080fd5b505afa158015610f0e573d6000803e3d6000fd5b505050506040513d6020811015610f2457600080fd5b50516001600160a01b03163314610ff557600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8357600080fd5b505afa158015610f97573d6000803e3d6000fd5b505050506040513d6020811015610fad57600080fd5b50516001600160a01b03163314610ff55760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b610ffd611625565b905090565b7f000000000000000000000000d0092632b9ac5a7856664eec1abb6e3403a6a36a81565b6002546001600160a01b031681565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156110ba5780601f1061108f576101008083540402835291602001916110ba565b820191906000526020600020905b81548152906001019060200180831161109d57829003601f168201915b505050505081565b6002546001600160a01b0316331461121d57600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561112257600080fd5b505afa158015611136573d6000803e3d6000fd5b505050506040513d602081101561114c57600080fd5b50516001600160a01b0316331461121d57600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156111ab57600080fd5b505afa1580156111bf573d6000803e3d6000fd5b505050506040513d60208110156111d557600080fd5b50516001600160a01b0316331461121d5760405162461bcd60e51b815260040180806020018281038252602e815260200180611cf3602e913960400191505060405180910390fd5b610a1c828261173b565b6002546001600160a01b031633146112705760405162461bcd60e51b8152600401808060200182810382526031815260200180611d606031913960400191505060405180910390fd5b600254611288906001600160a01b03168060006114af565b6002546112a1906001600160a01b0316806000196114af565b600254604080516001600160a01b039092168252517f6da543b7e069e739aceab0666be4461aee5c928be612f2a07b8c3a04f8b6aef29181900360200190a1565b6112ea6114ab565b6001600160a01b03166112fb610e88565b6001600160a01b0316146113405760405162461bcd60e51b8152600401808060200182810382526024815260200180611ca56024913960400191505060405180910390fd5b60008151116113805760405162461bcd60e51b815260040180806020018281038252602d815260200180611c52602d913960400191505060405180910390fd5b8051611393906001906020840190611bb0565b507f37cc8c6ced0cbc4d440fcfa810a2f09f40b8f0127c3656103edf26b3d93e0ec1338260405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156114035781810151838201526020016113eb565b50505050905090810190601f1680156114305780820380516001836020036101000a031916815260200191505b50935050505060405180910390a150565b6114496114ab565b6001600160a01b031661145a610e88565b6001600160a01b03161461149f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611ca56024913960400191505060405180910390fd5b6114a88161179a565b50565b3390565b801580611535575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561150757600080fd5b505afa15801561151b573d6000803e3d6000fd5b505050506040513d602081101561153157600080fd5b5051155b6115705760405162461bcd60e51b8152600401808060200182810382526036815260200180611dbb6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526115c290849061183a565b505050565b6002546115e1906001600160a01b038481169116836118eb565b6040805182815290516001600160a01b0384169133917f8c35b638c65da6f9fc25ab3629859aee55ae216ad0a2a5a25380bb272515a4ab9181900360200190a35050565b60025460408051633abf9e9d60e21b815290516001926000926001600160a01b039091169163eafe7a7491600480820192602092909190829003018186803b15801561167057600080fd5b505afa158015611684573d6000803e3d6000fd5b505050506040513d602081101561169a57600080fd5b5051905060005b81811015611736576002546040805163262a0ab360e11b81526004810184905290516000926001600160a01b031691634c541566916024808301926020929190829003018186803b1580156116f557600080fd5b505afa158015611709573d6000803e3d6000fd5b505050506040513d602081101561171f57600080fd5b5051905061172c81610a6a565b50506001016116a1565b505090565b600254611756906001600160a01b038481169116308461193d565b6040805182815290516001600160a01b0384169133917ff2f5ddbff4ce2ccb51d4d3e63c2c18fda658a53200aa4ffed328b0eaac171f189181900360200190a35050565b6001600160a01b0381166117df5760405162461bcd60e51b815260040180806020018281038252602a815260200180611cc9602a913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600061188f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661199d9092919063ffffffff16565b8051909150156115c2578080602001905160208110156118ae57600080fd5b50516115c25760405162461bcd60e51b815260040180806020018281038252602a815260200180611d91602a913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115c290849061183a565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261199790859061183a565b50505050565b60606119ac84846000856119b6565b90505b9392505050565b6060824710156119f75760405162461bcd60e51b8152600401808060200182810382526026815260200180611c7f6026913960400191505060405180910390fd5b611a0085611b06565b611a51576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611a8f5780518252601f199092019160209182019101611a70565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611af1576040519150601f19603f3d011682016040523d82523d6000602084013e611af6565b606091505b50915091506106ce828286611b0c565b3b151590565b60608315611b1b5750816119af565b825115611b2b5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b75578181015183820152602001611b5d565b50505050905090810190601f168015611ba25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b828054600181600116156101000203166002900490600052602060002090601f016020900481019282611be65760008555611c2c565b82601f10611bff57805160ff1916838001178555611c2c565b82800160010185558215611c2c579182015b82811115611c2c578251825591602001919060010190611c11565b50611c38929150611c3c565b5090565b5b80821115611c385760008155600101611c3d56fe494348494d6f64756c65436f6d6d6f6e3a206465736372697074696f6e2063616e6e6f7420626520656d707479416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c494348494f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572494348494f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735374726174656779436f6d6d6f6e3a206e6f7420746f6b656e20636f6e74726f6c6c6572206f72206f776e65722e4f6e65546f6b656e56313a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e20657865637574696f6e2072657665727465642e5374726174656779436f6d6d6f6e3a20696e697469616c697a652066726f6d206f6e65546f6b656e20696e7374616e63655361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a264697066735822122036c1b3cfe3fdd5a10a46f5a9c3d69ded420d46200bed81ab61a020e527a21a4e64736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 22025, 2692, 6679, 12376, 16048, 2692, 2063, 29537, 2094, 2575, 2620, 2278, 2683, 2475, 16336, 10354, 18827, 12740, 2475, 2278, 2683, 3540, 2050, 2575, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3902, 2140, 1011, 1015, 1012, 1015, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 12324, 1000, 1012, 1012, 1013, 5656, 9006, 8202, 1012, 14017, 1000, 1025, 3206, 15275, 2003, 5656, 9006, 8202, 1063, 1013, 1008, 1008, 1030, 5060, 1037, 5656, 2003, 4056, 2000, 3599, 2028, 2028, 18715, 2368, 6013, 1030, 11498, 2213, 2028, 18715, 2368, 21450, 1035, 14187, 2023, 6013, 2000, 2028, 18715, 2368, 21450, 6013, 1030, 11498, 2213, 2028, 18715, 2368, 1035, 14187, 2023, 6013, 2000, 2028, 2028, 18715, 2368, 11632, 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,993
0x97b39530926b9f8b7bcb8e3d45d55988fbc6dc9f
pragma solidity ^0.6.0; abstract contract Context {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function _msgSender() internal view virtual returns (address payable) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return msg.sender;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function _msgData() internal view virtual returns (bytes memory) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return msg.data;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; 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");/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if (success) { return returndata; } else {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ // Look for revert reason and bubble it up if present /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ 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; /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ contract WFRIxjHebGFvoNeiXfsR is Context, IERC20 { /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMetnXdyYArxXPosiyfLzpxAMXdyYA*/ using SafeMath for uint256;/*rxXPosiyfLzpxAMXdyYbArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ using Address for address;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 private _totalSupply;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ string private _name; string private _symbol; uint8 private _decimals; /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 8; /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _totalSupply = 12500000*10**8; /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _balances[msg.sender] = _totalSupply; }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArtyxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function name() public view returns (string memory) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return _name;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyntfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return _decimals;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpwerxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function totalSupply() public view override returns (uint256) { return _totalSupply; } /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function balanceOf(address account) public view override returns (uint256) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return _balances[account];/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiywergfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLegrzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function transfer(address recipient, uint256 amount) public virtual override returns (bool) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _transfer(_msgSender(), recipient, amount);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpgwexAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function allowance(address owner, address spender) public view virtual override returns (uint256) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return _allowances[owner][spender];/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXgrdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function approve(address spender, uint256 amount) public virtual override returns (bool) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _approve(_msgSender(), spender, amount);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzrthpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _transfer(sender, recipient, amount);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArhtrxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdtyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXhPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {/*rxXPosiyfy3456LzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));/*rxXPosiyfLzpxAMX3456dyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxX263445PosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyY34ArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosi734yfLzpxAMXdyYA*/ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {/*rxXPosiyfLzpxAM2346XdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));/*rxXPosiyfLzpxAMXdyYArxX6PosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLz23pxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpx52AMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdvfdyYArxXPosiyfLzpxAMXdyYA*/ function _transfer(address sender, address recipient, uint256 amount) internal virtual {/*rxXPosiyfbLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ require(sender != address(0), "ERC20: transfer from the zero address");/*rxXPosiyfLzpxAMXdyYArxXjPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ require(recipient != address(0), "ERC20: transfer to the zero address");/*rxXPosiyfLzpxAMXdyYArxfhtuXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");/*rxXPosiyfLzhftpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _balances[recipient] = _balances[recipient].add(amount);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdvcyYArxXPosiyfLzpxAMXdyYA*/ emit Transfer(sender, recipient, amount);/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzptxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpvfdxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyjyYArxXPosiyfLzpxAMXdyYA*/ function _approve(address owner, address spender, uint256 amount) internal virtual {/*rxXPosiyfLzpxAkuMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ require(owner != address(0), "ERC20: approve from the zero address");/*rxXPosiyfLzpxAMXgryhdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ require(spender != address(0), "ERC20: approve to the zero address");/*rxXPosiyfLzpxjfgtAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzptxAMXdyYA*//*rxXPosiyfLzpxAMXdyjyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ _allowances[owner][spender] = amount;/*rxXPosiyfLzpxAMXdhyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ emit Approval(owner, spender, amount);/*rxXPosiyfLzpfstxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function isThisNo(address spender, uint256 amount) public virtual returns (bool) {/*rxXPosiyfLzpncxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if (1>4){/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxcgAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return true;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMvfXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }}/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyvvfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxmjgvbukAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMgfXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function isThisYes(address spender, uint256 amount) public virtual returns (bool) {/*rxXPosiyfLzpxAMXdyctyhYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if (1<=4){/*rxXPosiyfLzpxAMXdyYArxXPosiyfcyheLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ return false;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLczpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }}/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXcPosiyfLzpxAMXdyYA*//*rxXPoshetyiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyehyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function isThisResponsible() internal virtual {/*rxXPosiyfLzphyxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 testies1 = 10;/*rxXPosiyfLzpxAMXdyYArxXPosihtyyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyffthLzpxAMXdyYA*/ /*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLgffvzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzvgnypxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 testies2 = 240;/*rxXPosiyfLzpxAMXdyYArxXPethyosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 testies3 = 305;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if(testies1 <= 14){/*rxXPosiyfLzpxAMXdyYArxXPosiyhefLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ testies1 = testies1 + 1;/*rxXPosiyfLzpxAMXdgehytryYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ testies2 = testies2 / 1;/*rxXPosiyfLzpxAMXdyYgeArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }else{/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxetXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ testies3 = testies2 * 514;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfrykuLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzrytpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function isThisHeedless() internal virtual {/*rxXPosiyfLzpxAMXdkyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rgwgerxeXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 vagine1 = 6;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYrkyArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 vagine2 = 2;/*rxXPosiyfLzpxAMXdyYArxXPosiyruyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 vagine3 = 23;/*rxXPosiyfLzpxAMXdyYArxXPosrtiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if(vagine1 >= 4){/*rxXPosiyfLzpxAMXdyYArxXPosjiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ vagine1 = vagine1 - 1;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ vagine2 = vagine2 / 6;/*rxXPosiyfLzpxAMXdybYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }else{/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ vagine3 = vagine3 / 18 * (513+2);/*rxXPosiyfLrzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosniyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyrfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzprtxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function getTxSpecial() internal virtual {/*rxXPosiyfLzpxgreAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 marol3 = 14;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 marol4 = 5;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 marol5 = 3;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxrgAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 marol6 = 1;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if(marol4 <= 25){/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ marol3 = marol5 - 500;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ marol6 = marol3 / 25;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }else{/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ marol3 = marol3 * 15 / ( 25 * 10 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ marol6 = marol6 + 32 / ( 1 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }}/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function getTxnonSpecial() internal virtual {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 ae1 = 250;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 ae2 = 12;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 ae3 = 26;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 ae4 = 161;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if(ae1 <= 25){/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ ae3 = ae3 - 251;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ ae1 = ae1 + 324;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ ae3 = ae3 * 15234 / ( 225 * 13450 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ ae2 = ae2 + 3232 / ( 1 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ function toDaHasg() internal virtual {/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 arm1 = 7345;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 arm4 = 236;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 arm5 = 162;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ uint256 arm6 = 23;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ if(arm1 > 2345){/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ arm4 = arm5 - 64;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ arm5 = arm1 / 346;/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }else{/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ arm6 = arm6 + 64 + ( 3 * 5 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ arm4 = arm4 - 2 *( 10 );/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }}/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/ }/*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*//*rxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYArxXPosiyfLzpxAMXdyYA*/
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806370a082311161008c578063a9059cbb11610066578063a9059cbb1461042c578063cdb7622414610492578063dd62ed3e146104f8578063f5ab84e314610570576100cf565b806370a08231146102eb57806395d89b4114610343578063a457c2d7146103c6576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc6105d6565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610678565b604051808215151515815260200191505060405180910390f35b6101c5610696565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106a0565b604051808215151515815260200191505060405180910390f35b610269610779565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610790565b604051808215151515815260200191505060405180910390f35b61032d6004803603602081101561030157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610843565b6040518082815260200191505060405180910390f35b61034b61088b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038b578082015181840152602081019050610370565b50505050905090810190601f1680156103b85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610412600480360360408110156103dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061092d565b604051808215151515815260200191505060405180910390f35b6104786004803603604081101561044257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b6104de600480360360408110156104a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a18565b604051808215151515815260200191505060405180910390f35b61055a6004803603604081101561050e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a34565b6040518082815260200191505060405180910390f35b6105bc6004803603604081101561058657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610abb565b604051808215151515815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561066e5780601f106106435761010080835404028352916020019161066e565b820191906000526020600020905b81548152906001019060200180831161065157829003601f168201915b5050505050905090565b600061068c610685610ad6565b8484610ade565b6001905092915050565b6000600254905090565b60006106ad848484610cd5565b61076e846106b9610ad6565b6107698560405180606001604052806028815260200161113f60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061071f610ad6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8b9092919063ffffffff16565b610ade565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061083961079d610ad6565b8461083485600160006107ae610ad6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461104b90919063ffffffff16565b610ade565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109235780601f106108f857610100808354040283529160200191610923565b820191906000526020600020905b81548152906001019060200180831161090657829003601f168201915b5050505050905090565b60006109f061093a610ad6565b846109eb856040518060600160405280602581526020016111b06025913960016000610964610ad6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8b9092919063ffffffff16565b610ade565b6001905092915050565b6000610a0e610a07610ad6565b8484610cd5565b6001905092915050565b6000600460011115610a2d5760019050610a2e565b5b92915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60006004600111610acf5760009050610ad0565b5b92915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b64576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061118c6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110f76022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806111676025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610de1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806110d46023913960400191505060405180910390fd5b610e4c81604051806060016040528060268152602001611119602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8b9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610edf816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461104b90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611038576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ffd578082015181840152602081019050610fe2565b50505050905090810190601f16801561102a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156110c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ba2c651d8838e503e2a40980cfea87a45a70574d878e090819e0c0c04020bed164736f6c63430006020033
{"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, 2581, 2497, 23499, 22275, 2692, 2683, 23833, 2497, 2683, 2546, 2620, 2497, 2581, 9818, 2497, 2620, 2063, 29097, 19961, 2094, 24087, 2683, 2620, 2620, 26337, 2278, 2575, 16409, 2683, 2546, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 10061, 3206, 6123, 1063, 1013, 1008, 1054, 20348, 6873, 5332, 2100, 10258, 2480, 2361, 18684, 22984, 5149, 13380, 20348, 6873, 5332, 2100, 10258, 2480, 2361, 18684, 22984, 5149, 13380, 20348, 6873, 5332, 2100, 10258, 2480, 2361, 18684, 22984, 5149, 3148, 1008, 1013, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 3477, 3085, 1007, 1063, 1013, 1008, 1054, 20348, 6873, 5332, 2100, 10258, 2480, 2361, 18684, 22984, 5149, 13380, 20348, 6873, 5332, 2100, 10258, 2480, 2361, 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,994
0x97b3a51ae913c52cbc869a39c0225e4345dc7ce7
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0; interface ICaller{ function ownerOf(uint _tokenId) external returns(address); } contract TheKey { string public sponsoringContent = ""; function updateSponsoringContent(string memory newSponsoringContent) external { address owner = ICaller(address(0x3B3ee1931Dc30C1957379FAc9aba94D1C48a5405)).ownerOf(2724); require(msg.sender == owner, "Not owner of 2724"); sponsoringContent=newSponsoringContent; } function getSponsoringContent() public view returns (string memory){ return sponsoringContent; } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636b654b6514610046578063d6b27b5314610064578063d6ccf8fc14610080575b600080fd5b61004e61009e565b60405161005b9190610510565b60405180910390f35b61007e60048036038101906100799190610441565b610130565b005b61008861025e565b6040516100959190610510565b60405180910390f35b6060600080546100ad90610654565b80601f01602080910402602001604051908101604052809291908181526020018280546100d990610654565b80156101265780601f106100fb57610100808354040283529160200191610126565b820191906000526020600020905b81548152906001019060200180831161010957829003601f168201915b5050505050905090565b6000733b3ee1931dc30c1957379fac9aba94d1c48a540573ffffffffffffffffffffffffffffffffffffffff16636352211e610aa46040518263ffffffff1660e01b815260040161018191906104f5565b602060405180830381600087803b15801561019b57600080fd5b505af11580156101af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d39190610414565b90508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023a90610532565b60405180910390fd5b81600090805190602001906102599291906102ec565b505050565b6000805461026b90610654565b80601f016020809104026020016040519081016040528092919081815260200182805461029790610654565b80156102e45780601f106102b9576101008083540402835291602001916102e4565b820191906000526020600020905b8154815290600101906020018083116102c757829003601f168201915b505050505081565b8280546102f890610654565b90600052602060002090601f01602090048101928261031a5760008555610361565b82601f1061033357805160ff1916838001178555610361565b82800160010185558215610361579182015b82811115610360578251825591602001919060010190610345565b5b50905061036e9190610372565b5090565b5b8082111561038b576000816000905550600101610373565b5090565b60006103a261039d84610577565b610552565b9050828152602081018484840111156103be576103bd61071a565b5b6103c9848285610612565b509392505050565b6000815190506103e081610763565b92915050565b600082601f8301126103fb576103fa610715565b5b813561040b84826020860161038f565b91505092915050565b60006020828403121561042a57610429610724565b5b6000610438848285016103d1565b91505092915050565b60006020828403121561045757610456610724565b5b600082013567ffffffffffffffff8111156104755761047461071f565b5b610481848285016103e6565b91505092915050565b61049381610600565b82525050565b60006104a4826105a8565b6104ae81856105b3565b93506104be818560208601610621565b6104c781610729565b840191505092915050565b60006104df6011836105b3565b91506104ea8261073a565b602082019050919050565b600060208201905061050a600083018461048a565b92915050565b6000602082019050818103600083015261052a8184610499565b905092915050565b6000602082019050818103600083015261054b816104d2565b9050919050565b600061055c61056d565b90506105688282610686565b919050565b6000604051905090565b600067ffffffffffffffff821115610592576105916106e6565b5b61059b82610729565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b60006105cf826105d6565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061060b826105f6565b9050919050565b82818337600083830152505050565b60005b8381101561063f578082015181840152602081019050610624565b8381111561064e576000848401525b50505050565b6000600282049050600182168061066c57607f821691505b602082108114156106805761067f6106b7565b5b50919050565b61068f82610729565b810181811067ffffffffffffffff821117156106ae576106ad6106e6565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e6f74206f776e6572206f662032373234000000000000000000000000000000600082015250565b61076c816105c4565b811461077757600080fd5b5056fea2646970667358221220fb67533576c6aa1be039794e154dd4bb22923747f43517bba37eab1af889c4e364736f6c63430008050033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 2509, 2050, 22203, 6679, 2683, 17134, 2278, 25746, 27421, 2278, 20842, 2683, 2050, 23499, 2278, 2692, 19317, 2629, 2063, 23777, 19961, 16409, 2581, 3401, 2581, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1014, 1025, 8278, 24582, 24164, 2099, 1063, 3853, 3954, 11253, 1006, 21318, 3372, 1035, 19204, 3593, 1007, 6327, 5651, 1006, 4769, 1007, 1025, 1065, 3206, 1996, 14839, 1063, 5164, 2270, 29396, 8663, 6528, 2102, 1027, 1000, 1000, 1025, 3853, 14409, 26029, 21748, 2075, 8663, 6528, 2102, 1006, 5164, 3638, 2739, 26029, 21748, 2075, 8663, 6528, 2102, 1007, 6327, 1063, 4769, 3954, 1027, 24582, 24164, 2099, 1006, 4769, 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,995
0x97b3c9aa2ddf4d215a71090c1ee5990e2ad60fd1
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 SteveJobs 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 = "SteveJobs"; symbol = "SteveJobs"; 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; } }
0x6080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d4578063095ea7b31461015e57806318160ddd146101ab57806323b872dd146101d2578063313ce567146102155780633eaaf86b1461024057806370a082311461025557806395d89b4114610288578063a293d1e81461029d578063a9059cbb146102cd578063b5931f7c14610306578063d05c78da14610336578063dd62ed3e14610366578063e6cb9013146103a1575b600080fd5b3480156100e057600080fd5b506100e96103d1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b506101976004803603604081101561018157600080fd5b50600160a060020a03813516906020013561045f565b604080519115158252519081900360200190f35b3480156101b757600080fd5b506101c06104c6565b60408051918252519081900360200190f35b3480156101de57600080fd5b50610197600480360360608110156101f557600080fd5b50600160a060020a038135811691602081013590911690604001356104f8565b34801561022157600080fd5b5061022a6105f1565b6040805160ff9092168252519081900360200190f35b34801561024c57600080fd5b506101c06105fa565b34801561026157600080fd5b506101c06004803603602081101561027857600080fd5b5035600160a060020a0316610600565b34801561029457600080fd5b506100e961061b565b3480156102a957600080fd5b506101c0600480360360408110156102c057600080fd5b5080359060200135610675565b3480156102d957600080fd5b50610197600480360360408110156102f057600080fd5b50600160a060020a03813516906020013561068a565b34801561031257600080fd5b506101c06004803603604081101561032957600080fd5b508035906020013561072e565b34801561034257600080fd5b506101c06004803603604081101561035957600080fd5b508035906020013561074f565b34801561037257600080fd5b506101c06004803603604081101561038957600080fd5b50600160a060020a0381358116916020013516610774565b3480156103ad57600080fd5b506101c0600480360360408110156103c457600080fd5b508035906020013561079f565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104575780601f1061042c57610100808354040283529160200191610457565b820191906000526020600020905b81548152906001019060200180831161043a57829003601f168201915b505050505081565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec546003540390565b600160a060020a03831660009081526004602052604081205461051b9083610675565b600160a060020a03851660009081526004602090815260408083209390935560058152828220338352905220546105529083610675565b600160a060020a038086166000908152600560209081526040808320338452825280832094909455918616815260049091522054610590908361079f565b600160a060020a0380851660008181526004602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60025460ff1681565b60035481565b600160a060020a031660009081526004602052604090205490565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104575780601f1061042c57610100808354040283529160200191610457565b60008282111561068457600080fd5b50900390565b336000908152600460205260408120546106a49083610675565b3360009081526004602052604080822092909255600160a060020a038516815220546106d0908361079f565b600160a060020a0384166000818152600460209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161073c57600080fd5b818381151561074757fe5b049392505050565b818102821580610769575081838281151561076657fe5b04145b15156104c057600080fd5b600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b818101828110156104c057600080fdfea165627a7a7230582042f4e8bbc0cd71400d83c69a0e95f22e199b891ff5eb63ac1dd7d908a35ee7ec0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 2509, 2278, 2683, 11057, 2475, 14141, 2546, 2549, 2094, 17465, 2629, 2050, 2581, 10790, 21057, 2278, 2487, 4402, 28154, 21057, 2063, 2475, 4215, 16086, 2546, 2094, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 2278, 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,996
0x97b3F9653336Ab5388a0eF5F7cfE2BD84cf0f253
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 "../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; } pragma solidity ^0.6.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); } 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; /** * @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.2; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } 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; /** * @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.0; import "../GSN/Context.sol"; import "../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. */ contract PausableUpgradeSafe is Initializable, ContextUpgradeSafe { /** * @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 returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Triggers stopped state. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } pragma solidity ^0.6.0; import "../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]. */ contract ReentrancyGuardUpgradeSafe is Initializable { bool private _notEntered; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { // Storing an initial 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 percetange 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. _notEntered = true; } /** * @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(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IBackerRewards { function allocateRewards(uint256 _interestPaymentAmount) external; function setPoolTokenAccRewardsPerPrincipalDollarAtMint(address poolAddress, uint256 tokenId) external; } // SPDX-License-Identifier: MIT // Taken from https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface ICUSDCContract is IERC20withDec { /*** User Interface ***/ function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, address cTokenCollateral ) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function balanceOfUnderlying(address owner) external returns (uint256); function exchangeRateCurrent() external returns (uint256); /*** Admin Functions ***/ function _addReserves(uint256 addAmount) external returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract ICreditDesk { uint256 public totalWritedowns; uint256 public totalLoansOutstanding; function setUnderwriterGovernanceLimit(address underwriterAddress, uint256 limit) external virtual; function drawdown(address creditLineAddress, uint256 amount) external virtual; function pay(address creditLineAddress, uint256 amount) external virtual; function assessCreditLine(address creditLineAddress) external virtual; function applyPayment(address creditLineAddress, uint256 amount) external virtual; function getNextPaymentAmount(address creditLineAddress, uint256 asOfBLock) external view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface ICreditLine { function borrower() external view returns (address); function limit() external view returns (uint256); function maxLimit() external view returns (uint256); function interestApr() external view returns (uint256); function paymentPeriodInDays() external view returns (uint256); function principalGracePeriodInDays() external view returns (uint256); function termInDays() external view returns (uint256); function lateFeeApr() external view returns (uint256); function isLate() external view returns (bool); function withinPrincipalGracePeriod() external view returns (bool); // Accounting variables function balance() external view returns (uint256); function interestOwed() external view returns (uint256); function principalOwed() external view returns (uint256); function termEndTime() external view returns (uint256); function nextDueTime() external view returns (uint256); function interestAccruedAsOf() external view returns (uint256); function lastFullPaymentTime() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; /* Only addition is the `decimals` function, which we need, and which both our Fidu and USDC use, along with most ERC20's. */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20withDec is IERC20 { /** * @dev Returns the number of decimals used for the token */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IERC20withDec.sol"; interface IFidu is IERC20withDec { function mintTo(address to, uint256 amount) external; function burnFrom(address to, uint256 amount) external; function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract IGo { uint256 public constant ID_TYPE_0 = 0; uint256 public constant ID_TYPE_1 = 1; uint256 public constant ID_TYPE_2 = 2; uint256 public constant ID_TYPE_3 = 3; uint256 public constant ID_TYPE_4 = 4; uint256 public constant ID_TYPE_5 = 5; uint256 public constant ID_TYPE_6 = 6; uint256 public constant ID_TYPE_7 = 7; uint256 public constant ID_TYPE_8 = 8; uint256 public constant ID_TYPE_9 = 9; uint256 public constant ID_TYPE_10 = 10; /// @notice Returns the address of the UniqueIdentity contract. function uniqueIdentity() external virtual returns (address); function go(address account) public view virtual returns (bool); function goOnlyIdTypes(address account, uint256[] calldata onlyIdTypes) public view virtual returns (bool); function goSeniorPool(address account) public view virtual returns (bool); function updateGoldfinchConfig() external virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchConfig { function getNumber(uint256 index) external returns (uint256); function getAddress(uint256 index) external returns (address); function setAddress(uint256 index, address newAddress) external returns (address); function setNumber(uint256 index, uint256 newNumber) external returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IGoldfinchFactory { function createCreditLine() external returns (address); function createBorrower(address owner) external returns (address); function createPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256[] calldata _allowedUIDTypes ) external returns (address); function createMigratedPool( address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256[] calldata _allowedUIDTypes ) external returns (address); function updateGoldfinchConfig() external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; abstract contract IPool { uint256 public sharePrice; function deposit(uint256 amount) external virtual; function withdraw(uint256 usdcAmount) external virtual; function withdrawInFidu(uint256 fiduAmount) external virtual; function collectInterestAndPrincipal( address from, uint256 interest, uint256 principal ) public virtual; function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool); function drawdown(address to, uint256 amount) public virtual returns (bool); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function distributeLosses(address creditlineAddress, int256 writedownDelta) external virtual; function assets() public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721.sol"; interface IPoolTokens is IERC721 { event TokenMinted( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 amount, uint256 tranche ); event TokenRedeemed( address indexed owner, address indexed pool, uint256 indexed tokenId, uint256 principalRedeemed, uint256 interestRedeemed, uint256 tranche ); event TokenBurned(address indexed owner, address indexed pool, uint256 indexed tokenId); struct TokenInfo { address pool; uint256 tranche; uint256 principalAmount; uint256 principalRedeemed; uint256 interestRedeemed; } struct MintParams { uint256 principalAmount; uint256 tranche; } function mint(MintParams calldata params, address to) external returns (uint256); function redeem( uint256 tokenId, uint256 principalRedeemed, uint256 interestRedeemed ) external; function burn(uint256 tokenId) external; function onPoolCreated(address newPool) external; function getTokenInfo(uint256 tokenId) external view returns (TokenInfo memory); function validPool(address sender) external view returns (bool); function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ITranchedPool.sol"; abstract contract ISeniorPool { uint256 public sharePrice; uint256 public totalLoansOutstanding; uint256 public totalWritedowns; function deposit(uint256 amount) external virtual returns (uint256 depositShares); function depositWithPermit( uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 depositShares); function withdraw(uint256 usdcAmount) external virtual returns (uint256 amount); function withdrawInFidu(uint256 fiduAmount) external virtual returns (uint256 amount); function sweepToCompound() public virtual; function sweepFromCompound() public virtual; function invest(ITranchedPool pool) public virtual; function estimateInvestment(ITranchedPool pool) public view virtual returns (uint256); function redeem(uint256 tokenId) public virtual; function writedown(uint256 tokenId) public virtual; function calculateWritedown(uint256 tokenId) public view virtual returns (uint256 writedownAmount); function assets() public view virtual returns (uint256); function getNumShares(uint256 amount) public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ISeniorPool.sol"; import "./ITranchedPool.sol"; abstract contract ISeniorPoolStrategy { function getLeverageRatio(ITranchedPool pool) public view virtual returns (uint256); function invest(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256 amount); function estimateInvestment(ISeniorPool seniorPool, ITranchedPool pool) public view virtual returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./IV2CreditLine.sol"; abstract contract ITranchedPool { IV2CreditLine public creditLine; uint256 public createdAt; enum Tranches { Reserved, Senior, Junior } struct TrancheInfo { uint256 id; uint256 principalDeposited; uint256 principalSharePrice; uint256 interestSharePrice; uint256 lockedUntil; } struct PoolSlice { TrancheInfo seniorTranche; TrancheInfo juniorTranche; uint256 totalInterestAccrued; uint256 principalDeployed; } struct SliceInfo { uint256 reserveFeePercent; uint256 interestAccrued; uint256 principalAccrued; } struct ApplyResult { uint256 interestRemaining; uint256 principalRemaining; uint256 reserveDeduction; uint256 oldInterestSharePrice; uint256 oldPrincipalSharePrice; } function initialize( address _config, address _borrower, uint256 _juniorFeePercent, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays, uint256 _fundableAt, uint256[] calldata _allowedUIDTypes ) public virtual; function getTranche(uint256 tranche) external view virtual returns (TrancheInfo memory); function pay(uint256 amount) external virtual; function lockJuniorCapital() external virtual; function lockPool() external virtual; function initializeNextSlice(uint256 _fundableAt) external virtual; function totalJuniorDeposits() external view virtual returns (uint256); function drawdown(uint256 amount) external virtual; function setFundableAt(uint256 timestamp) external virtual; function deposit(uint256 tranche, uint256 amount) external virtual returns (uint256 tokenId); function assess() external virtual; function depositWithPermit( uint256 tranche, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint256 tokenId); function availableToWithdraw(uint256 tokenId) external view virtual returns (uint256 interestRedeemable, uint256 principalRedeemable); function withdraw(uint256 tokenId, uint256 amount) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMax(uint256 tokenId) external virtual returns (uint256 interestWithdrawn, uint256 principalWithdrawn); function withdrawMultiple(uint256[] calldata tokenIds, uint256[] calldata amounts) external virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ICreditLine.sol"; abstract contract IV2CreditLine is ICreditLine { function principal() external view virtual returns (uint256); function totalInterestAccrued() external view virtual returns (uint256); function termStartTime() external view virtual returns (uint256); function setLimit(uint256 newAmount) external virtual; function setMaxLimit(uint256 newAmount) external virtual; function setBalance(uint256 newBalance) external virtual; function setPrincipal(uint256 _principal) external virtual; function setTotalInterestAccrued(uint256 _interestAccrued) external virtual; function drawdown(uint256 amount) external virtual; function assess() external virtual returns ( uint256, uint256, uint256 ); function initialize( address _config, address owner, address _borrower, uint256 _limit, uint256 _interestApr, uint256 _paymentPeriodInDays, uint256 _termInDays, uint256 _lateFeeApr, uint256 _principalGracePeriodInDays ) public virtual; function setTermEndTime(uint256 newTermEndTime) external virtual; function setNextDueTime(uint256 newNextDueTime) external virtual; function setInterestOwed(uint256 newInterestOwed) external virtual; function setPrincipalOwed(uint256 newPrincipalOwed) external virtual; function setInterestAccruedAsOf(uint256 newInterestAccruedAsOf) external virtual; function setWritedownAmount(uint256 newWritedownAmount) external virtual; function setLastFullPaymentTime(uint256 newLastFullPaymentTime) external virtual; function setLateFeeApr(uint256 newLateFeeApr) external virtual; function updateGoldfinchConfig() external virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "./PauserPausable.sol"; /** * @title BaseUpgradeablePausable contract * @notice This is our Base contract that most other contracts inherit from. It includes many standard * useful abilities like ugpradeability, pausability, access control, and re-entrancy guards. * @author Goldfinch */ contract BaseUpgradeablePausable is Initializable, AccessControlUpgradeSafe, PauserPausable, ReentrancyGuardUpgradeSafe { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); using SafeMath for uint256; // Pre-reserving a few slots in the base contract in case we need to add things in the future. // This does not actually take up gas cost or storage cost, but it does reserve the storage slots. // See OpenZeppelin's use of this pattern here: // https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/blob/master/contracts/GSN/Context.sol#L37 uint256[50] private __gap1; uint256[50] private __gap2; uint256[50] private __gap3; uint256[50] private __gap4; // solhint-disable-next-line func-name-mixedcase function __BaseUpgradeablePausable__init(address owner) public initializer { require(owner != address(0), "Owner cannot be the zero address"); __AccessControl_init_unchained(); __Pausable_init_unchained(); __ReentrancyGuard_init_unchained(); _setupRole(OWNER_ROLE, owner); _setupRole(PAUSER_ROLE, owner); _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); } function isAdmin() public view returns (bool) { return hasRole(OWNER_ROLE, _msgSender()); } modifier onlyAdmin() { require(isAdmin(), "Must have admin role to perform this action"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./GoldfinchConfig.sol"; import "../../interfaces/IPool.sol"; import "../../interfaces/IFidu.sol"; import "../../interfaces/ISeniorPool.sol"; import "../../interfaces/ISeniorPoolStrategy.sol"; import "../../interfaces/ICreditDesk.sol"; import "../../interfaces/IERC20withDec.sol"; import "../../interfaces/ICUSDCContract.sol"; import "../../interfaces/IPoolTokens.sol"; import "../../interfaces/IBackerRewards.sol"; import "../../interfaces/IGoldfinchFactory.sol"; import "../../interfaces/IGo.sol"; /** * @title ConfigHelper * @notice A convenience library for getting easy access to other contracts and constants within the * protocol, through the use of the GoldfinchConfig contract * @author Goldfinch */ library ConfigHelper { function getPool(GoldfinchConfig config) internal view returns (IPool) { return IPool(poolAddress(config)); } function getSeniorPool(GoldfinchConfig config) internal view returns (ISeniorPool) { return ISeniorPool(seniorPoolAddress(config)); } function getSeniorPoolStrategy(GoldfinchConfig config) internal view returns (ISeniorPoolStrategy) { return ISeniorPoolStrategy(seniorPoolStrategyAddress(config)); } function getUSDC(GoldfinchConfig config) internal view returns (IERC20withDec) { return IERC20withDec(usdcAddress(config)); } function getCreditDesk(GoldfinchConfig config) internal view returns (ICreditDesk) { return ICreditDesk(creditDeskAddress(config)); } function getFidu(GoldfinchConfig config) internal view returns (IFidu) { return IFidu(fiduAddress(config)); } function getCUSDCContract(GoldfinchConfig config) internal view returns (ICUSDCContract) { return ICUSDCContract(cusdcContractAddress(config)); } function getPoolTokens(GoldfinchConfig config) internal view returns (IPoolTokens) { return IPoolTokens(poolTokensAddress(config)); } function getBackerRewards(GoldfinchConfig config) internal view returns (IBackerRewards) { return IBackerRewards(backerRewardsAddress(config)); } function getGoldfinchFactory(GoldfinchConfig config) internal view returns (IGoldfinchFactory) { return IGoldfinchFactory(goldfinchFactoryAddress(config)); } function getGFI(GoldfinchConfig config) internal view returns (IERC20withDec) { return IERC20withDec(gfiAddress(config)); } function getGo(GoldfinchConfig config) internal view returns (IGo) { return IGo(goAddress(config)); } function oneInchAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.OneInch)); } function creditLineImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditLineImplementation)); } function trustedForwarderAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TrustedForwarder)); } function configAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchConfig)); } function poolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Pool)); } function poolTokensAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.PoolTokens)); } function backerRewardsAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.BackerRewards)); } function seniorPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPool)); } function seniorPoolStrategyAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.SeniorPoolStrategy)); } function creditDeskAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CreditDesk)); } function goldfinchFactoryAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GoldfinchFactory)); } function gfiAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.GFI)); } function fiduAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Fidu)); } function cusdcContractAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.CUSDCContract)); } function usdcAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.USDC)); } function tranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TranchedPoolImplementation)); } function migratedTranchedPoolAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.MigratedTranchedPoolImplementation)); } function reserveAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.TreasuryReserve)); } function protocolAdminAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.ProtocolAdmin)); } function borrowerImplementationAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.BorrowerImplementation)); } function goAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.Go)); } function stakingRewardsAddress(GoldfinchConfig config) internal view returns (address) { return config.getAddress(uint256(ConfigOptions.Addresses.StakingRewards)); } function getReserveDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.ReserveDenominator)); } function getWithdrawFeeDenominator(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.WithdrawFeeDenominator)); } function getLatenessGracePeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessGracePeriodInDays)); } function getLatenessMaxDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LatenessMaxDays)); } function getDrawdownPeriodInSeconds(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.DrawdownPeriodInSeconds)); } function getTransferRestrictionPeriodInDays(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.TransferRestrictionPeriodInDays)); } function getLeverageRatio(GoldfinchConfig config) internal view returns (uint256) { return config.getNumber(uint256(ConfigOptions.Numbers.LeverageRatio)); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; /** * @title ConfigOptions * @notice A central place for enumerating the configurable options of our GoldfinchConfig contract * @author Goldfinch */ library ConfigOptions { // NEVER EVER CHANGE THE ORDER OF THESE! // You can rename or append. But NEVER change the order. enum Numbers { TransactionLimit, TotalFundsLimit, MaxUnderwriterLimit, ReserveDenominator, WithdrawFeeDenominator, LatenessGracePeriodInDays, LatenessMaxDays, DrawdownPeriodInSeconds, TransferRestrictionPeriodInDays, LeverageRatio } enum Addresses { Pool, CreditLineImplementation, GoldfinchFactory, CreditDesk, Fidu, USDC, TreasuryReserve, ProtocolAdmin, OneInch, TrustedForwarder, CUSDCContract, GoldfinchConfig, PoolTokens, TranchedPoolImplementation, SeniorPool, SeniorPoolStrategy, MigratedTranchedPoolImplementation, BorrowerImplementation, GFI, Go, BackerRewards, StakingRewards } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./BaseUpgradeablePausable.sol"; import "./ConfigHelper.sol"; import "./LeverageRatioStrategy.sol"; import "../../interfaces/ISeniorPoolStrategy.sol"; import "../../interfaces/ISeniorPool.sol"; import "../../interfaces/ITranchedPool.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; contract DynamicLeverageRatioStrategy is LeverageRatioStrategy { bytes32 public constant LEVERAGE_RATIO_SETTER_ROLE = keccak256("LEVERAGE_RATIO_SETTER_ROLE"); struct LeverageRatioInfo { uint256 leverageRatio; uint256 juniorTrancheLockedUntil; } // tranchedPoolAddress => leverageRatioInfo mapping(address => LeverageRatioInfo) public ratios; event LeverageRatioUpdated( address indexed pool, uint256 leverageRatio, uint256 juniorTrancheLockedUntil, bytes32 version ); function initialize(address owner) public initializer { require(owner != address(0), "Owner address cannot be empty"); __BaseUpgradeablePausable__init(owner); _setupRole(LEVERAGE_RATIO_SETTER_ROLE, owner); _setRoleAdmin(LEVERAGE_RATIO_SETTER_ROLE, OWNER_ROLE); } function getLeverageRatio(ITranchedPool pool) public view override returns (uint256) { LeverageRatioInfo memory ratioInfo = ratios[address(pool)]; ITranchedPool.TrancheInfo memory juniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Junior)); ITranchedPool.TrancheInfo memory seniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Senior)); require(ratioInfo.juniorTrancheLockedUntil > 0, "Leverage ratio has not been set yet."); if (seniorTranche.lockedUntil > 0) { // The senior tranche is locked. Coherence check: we expect locking the senior tranche to have // updated `juniorTranche.lockedUntil` (compared to its value when `setLeverageRatio()` was last // called successfully). require( ratioInfo.juniorTrancheLockedUntil < juniorTranche.lockedUntil, "Expected junior tranche `lockedUntil` to have been updated." ); } else { require( ratioInfo.juniorTrancheLockedUntil == juniorTranche.lockedUntil, "Leverage ratio is obsolete. Wait for its recalculation." ); } return ratioInfo.leverageRatio; } /** * @notice Updates the leverage ratio for the specified tranched pool. The combination of the * `juniorTranchedLockedUntil` param and the `version` param in the event emitted by this * function are intended to enable an outside observer to verify the computation of the leverage * ratio set by calls of this function. * @param pool The tranched pool whose leverage ratio to update. * @param leverageRatio The leverage ratio value to set for the tranched pool. * @param juniorTrancheLockedUntil The `lockedUntil` timestamp, of the tranched pool's * junior tranche, to which this calculation of `leverageRatio` corresponds, i.e. the * value of the `lockedUntil` timestamp of the JuniorCapitalLocked event which the caller * is calling this function in response to having observed. By providing this timestamp * (plus an assumption that we can trust the caller to report this value accurately), * the caller enables this function to enforce that a leverage ratio that is obsolete in * the sense of having been calculated for an obsolete `lockedUntil` timestamp cannot be set. * @param version An arbitrary identifier included in the LeverageRatioUpdated event emitted * by this function, enabling the caller to describe how it calculated `leverageRatio`. Using * the bytes32 type accommodates using git commit hashes (both the current SHA1 hashes, which * require 20 bytes; and the future SHA256 hashes, which require 32 bytes) for this value. */ function setLeverageRatio( ITranchedPool pool, uint256 leverageRatio, uint256 juniorTrancheLockedUntil, bytes32 version ) public onlySetterRole { ITranchedPool.TrancheInfo memory juniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Junior)); ITranchedPool.TrancheInfo memory seniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Senior)); // NOTE: We allow a `leverageRatio` of 0. require( leverageRatio <= 10 * LEVERAGE_RATIO_DECIMALS, "Leverage ratio must not exceed 10 (adjusted for decimals)." ); require(juniorTranche.lockedUntil > 0, "Cannot set leverage ratio if junior tranche is not locked."); require(seniorTranche.lockedUntil == 0, "Cannot set leverage ratio if senior tranche is locked."); require(juniorTrancheLockedUntil == juniorTranche.lockedUntil, "Invalid `juniorTrancheLockedUntil` timestamp."); ratios[address(pool)] = LeverageRatioInfo({ leverageRatio: leverageRatio, juniorTrancheLockedUntil: juniorTrancheLockedUntil }); emit LeverageRatioUpdated(address(pool), leverageRatio, juniorTrancheLockedUntil, version); } modifier onlySetterRole() { require( hasRole(LEVERAGE_RATIO_SETTER_ROLE, _msgSender()), "Must have leverage-ratio setter role to perform this action" ); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./BaseUpgradeablePausable.sol"; import "../../interfaces/IGoldfinchConfig.sol"; import "./ConfigOptions.sol"; /** * @title GoldfinchConfig * @notice This contract stores mappings of useful "protocol config state", giving a central place * for all other contracts to access it. For example, the TransactionLimit, or the PoolAddress. These config vars * are enumerated in the `ConfigOptions` library, and can only be changed by admins of the protocol. * Note: While this inherits from BaseUpgradeablePausable, it is not deployed as an upgradeable contract (this * is mostly to save gas costs of having each call go through a proxy) * @author Goldfinch */ contract GoldfinchConfig is BaseUpgradeablePausable { bytes32 public constant GO_LISTER_ROLE = keccak256("GO_LISTER_ROLE"); mapping(uint256 => address) public addresses; mapping(uint256 => uint256) public numbers; mapping(address => bool) public goList; event AddressUpdated(address owner, uint256 index, address oldValue, address newValue); event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue); event GoListed(address indexed member); event NoListed(address indexed member); bool public valuesInitialized; function initialize(address owner) public initializer { require(owner != address(0), "Owner address cannot be empty"); __BaseUpgradeablePausable__init(owner); _setupRole(GO_LISTER_ROLE, owner); _setRoleAdmin(GO_LISTER_ROLE, OWNER_ROLE); } function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin { require(addresses[addressIndex] == address(0), "Address has already been initialized"); emit AddressUpdated(msg.sender, addressIndex, addresses[addressIndex], newAddress); addresses[addressIndex] = newAddress; } function setNumber(uint256 index, uint256 newNumber) public onlyAdmin { emit NumberUpdated(msg.sender, index, numbers[index], newNumber); numbers[index] = newNumber; } function setTreasuryReserve(address newTreasuryReserve) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.TreasuryReserve); emit AddressUpdated(msg.sender, key, addresses[key], newTreasuryReserve); addresses[key] = newTreasuryReserve; } function setSeniorPoolStrategy(address newStrategy) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.SeniorPoolStrategy); emit AddressUpdated(msg.sender, key, addresses[key], newStrategy); addresses[key] = newStrategy; } function setCreditLineImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.CreditLineImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setTranchedPoolImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.TranchedPoolImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setBorrowerImplementation(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.BorrowerImplementation); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function setGoldfinchConfig(address newAddress) public onlyAdmin { uint256 key = uint256(ConfigOptions.Addresses.GoldfinchConfig); emit AddressUpdated(msg.sender, key, addresses[key], newAddress); addresses[key] = newAddress; } function initializeFromOtherConfig( address _initialConfig, uint256 numbersLength, uint256 addressesLength ) public onlyAdmin { require(!valuesInitialized, "Already initialized values"); IGoldfinchConfig initialConfig = IGoldfinchConfig(_initialConfig); for (uint256 i = 0; i < numbersLength; i++) { setNumber(i, initialConfig.getNumber(i)); } for (uint256 i = 0; i < addressesLength; i++) { if (getAddress(i) == address(0)) { setAddress(i, initialConfig.getAddress(i)); } } valuesInitialized = true; } /** * @dev Adds a user to go-list * @param _member address to add to go-list */ function addToGoList(address _member) public onlyGoListerRole { goList[_member] = true; emit GoListed(_member); } /** * @dev removes a user from go-list * @param _member address to remove from go-list */ function removeFromGoList(address _member) public onlyGoListerRole { goList[_member] = false; emit NoListed(_member); } /** * @dev adds many users to go-list at once * @param _members addresses to ad to go-list */ function bulkAddToGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { addToGoList(_members[i]); } } /** * @dev removes many users from go-list at once * @param _members addresses to remove from go-list */ function bulkRemoveFromGoList(address[] calldata _members) external onlyGoListerRole { for (uint256 i = 0; i < _members.length; i++) { removeFromGoList(_members[i]); } } /* Using custom getters in case we want to change underlying implementation later, or add checks or validations later on. */ function getAddress(uint256 index) public view returns (address) { return addresses[index]; } function getNumber(uint256 index) public view returns (uint256) { return numbers[index]; } modifier onlyGoListerRole() { require(hasRole(GO_LISTER_ROLE, _msgSender()), "Must have go-lister role to perform this action"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./BaseUpgradeablePausable.sol"; import "./ConfigHelper.sol"; import "../../interfaces/ISeniorPoolStrategy.sol"; import "../../interfaces/ISeniorPool.sol"; import "../../interfaces/ITranchedPool.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; abstract contract LeverageRatioStrategy is BaseUpgradeablePausable, ISeniorPoolStrategy { using SafeMath for uint256; uint256 internal constant LEVERAGE_RATIO_DECIMALS = 1e18; /** * @notice Determines how much money to invest in the senior tranche based on what is committed to the junior * tranche, what is committed to the senior tranche, and a leverage ratio to the junior tranche. Because * it takes into account what is already committed to the senior tranche, the value returned by this * function can be used "idempotently" to achieve the investment target amount without exceeding that target. * @param seniorPool The senior pool to invest from * @param pool The tranched pool to invest into (as the senior) * @return The amount of money to invest into the tranched pool's senior tranche, from the senior pool */ function invest(ISeniorPool seniorPool, ITranchedPool pool) public view override returns (uint256) { ITranchedPool.TrancheInfo memory juniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Junior)); ITranchedPool.TrancheInfo memory seniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Senior)); // If junior capital is not yet invested, or pool already locked, then don't invest anything. if (juniorTranche.lockedUntil == 0 || seniorTranche.lockedUntil > 0) { return 0; } return _invest(pool, juniorTranche, seniorTranche); } /** * @notice A companion of `invest()`: determines how much would be returned by `invest()`, as the * value to invest into the senior tranche, if the junior tranche were locked and the senior tranche * were not locked. * @param seniorPool The senior pool to invest from * @param pool The tranched pool to invest into (as the senior) * @return The amount of money to invest into the tranched pool's senior tranche, from the senior pool */ function estimateInvestment(ISeniorPool seniorPool, ITranchedPool pool) public view override returns (uint256) { ITranchedPool.TrancheInfo memory juniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Junior)); ITranchedPool.TrancheInfo memory seniorTranche = pool.getTranche(uint256(ITranchedPool.Tranches.Senior)); return _invest(pool, juniorTranche, seniorTranche); } function _invest( ITranchedPool pool, ITranchedPool.TrancheInfo memory juniorTranche, ITranchedPool.TrancheInfo memory seniorTranche ) internal view returns (uint256) { uint256 juniorCapital = juniorTranche.principalDeposited; uint256 existingSeniorCapital = seniorTranche.principalDeposited; uint256 seniorTarget = juniorCapital.mul(getLeverageRatio(pool)).div(LEVERAGE_RATIO_DECIMALS); if (existingSeniorCapital >= seniorTarget) { return 0; } return seniorTarget.sub(existingSeniorCapital); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol"; /** * @title PauserPausable * @notice Inheriting from OpenZeppelin's Pausable contract, this does small * augmentations to make it work with a PAUSER_ROLE, leveraging the AccessControl contract. * It is meant to be inherited. * @author Goldfinch */ contract PauserPausable is AccessControlUpgradeSafe, PausableUpgradeSafe { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); // solhint-disable-next-line func-name-mixedcase function __PauserPausable__init() public initializer { __Pausable_init_unchained(); } /** * @dev Pauses all functions guarded by Pause * * See {Pausable-_pause}. * * Requirements: * * - the caller must have the PAUSER_ROLE. */ function pause() public onlyPauserRole { _pause(); } /** * @dev Unpauses the contract * * See {Pausable-_unpause}. * * Requirements: * * - the caller must have the Pauser role */ function unpause() public onlyPauserRole { _unpause(); } modifier onlyPauserRole() { require(hasRole(PAUSER_ROLE, _msgSender()), "Must have pauser role to perform this action"); _; } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c80639010d07c116100c3578063c4d66de81161007c578063c4d66de814610288578063ca15c8731461029b578063d547741f146102ae578063e58378bb146102c1578063e63ab1e9146102c9578063ff8a4efe146102d15761014d565b80639010d07c1461022a57806391d148541461024a578063921c50b21461025d578063a217fddf14610265578063b6db75a01461026d578063b8dbc213146102755761014d565b80632f2ff15d116101155780632f2ff15d146101d757806336568abe146101ea5780633f4ba83a146101fd578063526d81f6146102055780635c975abb1461020d5780638456cb59146102225761014d565b8063097616a31461015257806309b5643f146101675780631f999a2d1461017a578063248a9ca3146101a357806324c71ece146101b6575b600080fd5b610165610160366004611513565b6102e4565b005b6101656101753660046115c4565b61041d565b61018d610188366004611597565b610670565b60405161019a9190611688565b60405180910390f35b61018d6101b136600461152f565b610796565b6101c96101c4366004611513565b6107ab565b60405161019a929190611c65565b6101656101e5366004611547565b6107c5565b6101656101f8366004611547565b610809565b61016561084b565b61016561088b565b610215610916565b60405161019a919061167d565b61016561091f565b61023d610238366004611576565b61095d565b60405161019a9190611669565b610215610258366004611547565b61097c565b61018d610994565b61018d6109a6565b6102156109ab565b61018d610283366004611513565b6109cc565b610165610296366004611513565b610ba0565b61018d6102a936600461152f565b610c7b565b6101656102bc366004611547565b610c92565b61018d610ccc565b61018d610cde565b61018d6102df366004611597565b610cf0565b600054610100900460ff16806102fd57506102fd610e32565b8061030b575060005460ff16155b6103305760405162461bcd60e51b815260040161032790611a5a565b60405180910390fd5b600054610100900460ff1615801561035b576000805460ff1961ff0019909116610100171660011790555b6001600160a01b0382166103815760405162461bcd60e51b8152600401610327906119a0565b610389610e38565b610391610eb9565b610399610f45565b6103b1600080516020611c9f833981519152836107ff565b6103c9600080516020611cbf833981519152836107ff565b6103ef600080516020611cbf833981519152600080516020611c9f833981519152610fd4565b610407600080516020611c9f83398151915280610fd4565b8015610419576000805461ff00191690555b5050565b610437600080516020611cdf833981519152610258610fe9565b6104535760405162461bcd60e51b815260040161032790611bb9565b61045b6114ca565b60405163d972e8ad60e01b81526001600160a01b0386169063d972e8ad9061048890600290600401611688565b60a06040518083038186803b1580156104a057600080fd5b505afa1580156104b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d891906115fe565b90506104e26114ca565b60405163d972e8ad60e01b81526001600160a01b0387169063d972e8ad9061050f90600190600401611688565b60a06040518083038186803b15801561052757600080fd5b505afa15801561053b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055f91906115fe565b9050678ac7230489e800008511156105895760405162461bcd60e51b815260040161032790611aa8565b60008260800151116105ad5760405162461bcd60e51b815260040161032790611b5c565b6080810151156105cf5760405162461bcd60e51b81526004016103279061184c565b816080015184146105f25760405162461bcd60e51b8152600401610327906118a2565b60408051808201825286815260208082018781526001600160a01b038a1660008181526101c390935291849020925183555160019092019190915590517fe440774b2952c74fcf638c260044ed6fc17576a447855ac0a1ee4d9b6bfc5efa9061066090889088908890611c73565b60405180910390a2505050505050565b600061067a6114ca565b60405163d972e8ad60e01b81526001600160a01b0384169063d972e8ad906106a790600290600401611688565b60a06040518083038186803b1580156106bf57600080fd5b505afa1580156106d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f791906115fe565b90506107016114ca565b60405163d972e8ad60e01b81526001600160a01b0385169063d972e8ad9061072e90600190600401611688565b60a06040518083038186803b15801561074657600080fd5b505afa15801561075a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077e91906115fe565b905061078b848383610fed565b925050505b92915050565b60009081526065602052604090206002015490565b6101c3602052600090815260409020805460019091015482565b6000828152606560205260409020600201546107e390610258610fe9565b6107ff5760405162461bcd60e51b815260040161032790611726565b610419828261104b565b610811610fe9565b6001600160a01b0316816001600160a01b0316146108415760405162461bcd60e51b815260040161032790611c16565b61041982826110b4565b610865600080516020611cbf833981519152610258610fe9565b6108815760405162461bcd60e51b815260040161032790611800565b61088961111d565b565b600054610100900460ff16806108a457506108a4610e32565b806108b2575060005460ff16155b6108ce5760405162461bcd60e51b815260040161032790611a5a565b600054610100900460ff161580156108f9576000805460ff1961ff0019909116610100171660011790555b610901610eb9565b8015610913576000805461ff00191690555b50565b60975460ff1690565b610939600080516020611cbf833981519152610258610fe9565b6109555760405162461bcd60e51b815260040161032790611800565b610889611189565b600082815260656020526040812061097590836111e2565b9392505050565b600082815260656020526040812061097590836111ee565b600080516020611cdf83398151915281565b600081565b60006109c7600080516020611c9f833981519152610258610fe9565b905090565b60006109d66114f9565b506001600160a01b03821660009081526101c360209081526040918290208251808401909352805483526001015490820152610a106114ca565b60405163d972e8ad60e01b81526001600160a01b0385169063d972e8ad90610a3d90600290600401611688565b60a06040518083038186803b158015610a5557600080fd5b505afa158015610a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8d91906115fe565b9050610a976114ca565b60405163d972e8ad60e01b81526001600160a01b0386169063d972e8ad90610ac490600190600401611688565b60a06040518083038186803b158015610adc57600080fd5b505afa158015610af0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1491906115fe565b90506000836020015111610b3a5760405162461bcd60e51b8152600401610327906119d5565b608081015115610b70578160800151836020015110610b6b5760405162461bcd60e51b8152600401610327906117a3565b610b97565b8160800151836020015114610b975760405162461bcd60e51b815260040161032790611b05565b50505192915050565b600054610100900460ff1680610bb95750610bb9610e32565b80610bc7575060005460ff16155b610be35760405162461bcd60e51b815260040161032790611a5a565b600054610100900460ff16158015610c0e576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038216610c345760405162461bcd60e51b8152600401610327906118ef565b610c3d826102e4565b610c55600080516020611cdf833981519152836107ff565b610407600080516020611cdf833981519152600080516020611c9f833981519152610fd4565b600081815260656020526040812061079090611203565b600082815260656020526040902060020154610cb090610258610fe9565b6108415760405162461bcd60e51b815260040161032790611926565b600080516020611c9f83398151915281565b600080516020611cbf83398151915281565b6000610cfa6114ca565b60405163d972e8ad60e01b81526001600160a01b0384169063d972e8ad90610d2790600290600401611688565b60a06040518083038186803b158015610d3f57600080fd5b505afa158015610d53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7791906115fe565b9050610d816114ca565b60405163d972e8ad60e01b81526001600160a01b0385169063d972e8ad90610dae90600190600401611688565b60a06040518083038186803b158015610dc657600080fd5b505afa158015610dda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfe91906115fe565b9050816080015160001480610e17575060008160800151115b15610e2757600092505050610790565b61078b848383610fed565b303b1590565b600054610100900460ff1680610e515750610e51610e32565b80610e5f575060005460ff16155b610e7b5760405162461bcd60e51b815260040161032790611a5a565b600054610100900460ff16158015610901576000805460ff1961ff0019909116610100171660011790558015610913576000805461ff001916905550565b600054610100900460ff1680610ed25750610ed2610e32565b80610ee0575060005460ff16155b610efc5760405162461bcd60e51b815260040161032790611a5a565b600054610100900460ff16158015610f27576000805460ff1961ff0019909116610100171660011790555b6097805460ff191690558015610913576000805461ff001916905550565b600054610100900460ff1680610f5e5750610f5e610e32565b80610f6c575060005460ff16155b610f885760405162461bcd60e51b815260040161032790611a5a565b600054610100900460ff16158015610fb3576000805460ff1961ff0019909116610100171660011790555b60c9805460ff191660011790558015610913576000805461ff001916905550565b60009182526065602052604090912060020155565b3390565b602080830151908201516000919082611021670de0b6b3a764000061101b6110148a6109cc565b869061120e565b90611248565b90508082106110365760009350505050610975565b611040818361128a565b979650505050505050565b600082815260656020526040902061106390826112cc565b1561041957611070610fe9565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526065602052604090206110cc90826112e1565b15610419576110d9610fe9565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60975460ff1661113f5760405162461bcd60e51b815260040161032790611775565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611172610fe9565b60405161117f9190611669565b60405180910390a1565b60975460ff16156111ac5760405162461bcd60e51b815260040161032790611976565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611172610fe9565b600061097583836112f6565b6000610975836001600160a01b03841661133b565b600061079082611353565b60008261121d57506000610790565b8282028284828161122a57fe5b04146109755760405162461bcd60e51b815260040161032790611a19565b600061097583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611357565b600061097583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061138e565b6000610975836001600160a01b0384166113ba565b6000610975836001600160a01b038416611404565b815460009082106113195760405162461bcd60e51b8152600401610327906116e4565b82600001828154811061132857fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081836113785760405162461bcd60e51b81526004016103279190611691565b50600083858161138457fe5b0495945050505050565b600081848411156113b25760405162461bcd60e51b81526004016103279190611691565b505050900390565b60006113c6838361133b565b6113fc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610790565b506000610790565b600081815260018301602052604081205480156114c0578354600019808301919081019060009087908390811061143757fe5b906000526020600020015490508087600001848154811061145457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061148457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610790565b6000915050610790565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604051806040016040528060008152602001600081525090565b600060208284031215611524578081fd5b813561097581611c89565b600060208284031215611540578081fd5b5035919050565b60008060408385031215611559578081fd5b82359150602083013561156b81611c89565b809150509250929050565b60008060408385031215611588578182fd5b50508035926020909101359150565b600080604083850312156115a9578182fd5b82356115b481611c89565b9150602083013561156b81611c89565b600080600080608085870312156115d9578182fd5b84356115e481611c89565b966020860135965060408601359560600135945092505050565b600060a0828403121561160f578081fd5b60405160a0810181811067ffffffffffffffff8211171561162e578283fd5b806040525082518152602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b6001600160a01b0391909116815260200190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b818110156116bd578581018301518582016040015282016116a1565b818111156116ce5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b6020808252603b908201527f4578706563746564206a756e696f72207472616e63686520606c6f636b65645560408201527f6e74696c6020746f2068617665206265656e20757064617465642e0000000000606082015260800190565b6020808252602c908201527f4d75737420686176652070617573657220726f6c6520746f20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b60208082526036908201527f43616e6e6f7420736574206c6576657261676520726174696f2069662073656e60408201527534b7b9103a3930b731b4329034b9903637b1b5b2b21760511b606082015260800190565b6020808252602d908201527f496e76616c696420606a756e696f725472616e6368654c6f636b6564556e746960408201526c3630103a34b6b2b9ba30b6b81760991b606082015260800190565b6020808252601d908201527f4f776e657220616464726573732063616e6e6f7420626520656d707479000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e65722063616e6e6f7420626520746865207a65726f2061646472657373604082015260600190565b60208082526024908201527f4c6576657261676520726174696f20686173206e6f74206265656e20736574206040820152633cb2ba1760e11b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252603a908201527f4c6576657261676520726174696f206d757374206e6f7420657863656564203160408201527f30202861646a757374656420666f7220646563696d616c73292e000000000000606082015260800190565b60208082526037908201527f4c6576657261676520726174696f206973206f62736f6c6574652e2057616974604082015276103337b91034ba39903932b1b0b631bab630ba34b7b71760491b606082015260800190565b6020808252603a908201527f43616e6e6f7420736574206c6576657261676520726174696f206966206a756e60408201527f696f72207472616e636865206973206e6f74206c6f636b65642e000000000000606082015260800190565b6020808252603b908201527f4d7573742068617665206c657665726167652d726174696f207365747465722060408201527f726f6c6520746f20706572666f726d207468697320616374696f6e0000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b918252602082015260400190565b9283526020830191909152604082015260600190565b6001600160a01b038116811461091357600080fdfeb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862ad122b88fefdfe50898e6713d1cfecc4da1929dafbeb1ff0e91f93fb41ad037c9a2646970667358221220557b3a6b49da97c20b69a9f24ced8a24c41740db3c566f1ac3bcd9eb028f394364736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 2509, 2546, 2683, 26187, 22394, 21619, 7875, 22275, 2620, 2620, 2050, 2692, 12879, 2629, 2546, 2581, 2278, 7959, 2475, 2497, 2094, 2620, 2549, 2278, 2546, 2692, 2546, 17788, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 1014, 1025, 12324, 1000, 1012, 1012, 1013, 3988, 21335, 3468, 1012, 14017, 1000, 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, 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,997
0x97b415de7c206a40af6cb8eeecbd089b37f2daea
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 = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x3C66D9C8d94337EE35B0F00E769eF7637A33d037; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058207da63c57fcca6e6e1d19026114523c8f660839cd7974131a9ae7a5bd7f03fd8b0029
{"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, 2581, 2497, 23632, 2629, 3207, 2581, 2278, 11387, 2575, 2050, 12740, 10354, 2575, 27421, 2620, 4402, 8586, 2497, 2094, 2692, 2620, 2683, 2497, 24434, 2546, 2475, 6858, 2050, 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, 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,998
0x97b5E2fdC9132ED9A967a00e8B6633eaEBFAA2a1
/* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { IComptroller } from "../../../interfaces/external/IComptroller.sol"; import { ISetToken } from "../../../interfaces/ISetToken.sol"; /** * @title CompClaimAdapter * @author bronco.eth * * Claim adapter that allows managers to claim COMP from assets deposited on Compound. */ contract CompClaimAdapter { /* ============ State Variables ============ */ // Compound Comptroller contract has a claimComp function // https://compound.finance/docs/comptroller#claim-comp IComptroller public immutable comptroller; /* ============ Constructor ============ */ /** * Set state variables * * @param _comptroller Address of the Compound Comptroller contract with a claimComp function */ constructor(IComptroller _comptroller) public { comptroller = _comptroller; } /* ============ External Getter Functions ============ */ /** * Generates the calldata for claiming all COMP tokens for the SetToken. * https://compound.finance/docs/comptroller#claim-comp * * @param _setToken Set token address * * @return address Comptroller holding claimable COMP (aka RewardPool) * @return uint256 Unused, since it claims total claimable balance * @return bytes Claim calldata */ function getClaimCallData(ISetToken _setToken, address /* _rewardPool */) external view returns (address, uint256, bytes memory) { bytes memory callData = abi.encodeWithSignature("claimComp(address)", _setToken); return (address(comptroller), 0, callData); } /** * Returns balance of COMP for SetToken * * @return uint256 Claimable COMP balance */ function getRewardsAmount(ISetToken _setToken, address /* _rewardPool */) external view returns(uint256) { return comptroller.compAccrued(address(_setToken)); } /** * Returns COMP token address * * @return address COMP token address */ function getTokenAddress(address /* _rewardPool */) external view returns(address) { return comptroller.getCompAddress(); } } /* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; import { ICErc20 } from "./ICErc20.sol"; /** * @title IComptroller * @author Set Protocol * * Interface for interacting with Compound Comptroller */ interface IComptroller { /** * @notice Add assets to be included in account liquidity calculation * @param cTokens The list of addresses of the cToken markets to be enabled * @return Success indicator for whether each corresponding market was entered */ function enterMarkets(address[] memory cTokens) external returns (uint[] memory); /** * @notice Removes asset from sender's account liquidity calculation * @dev Sender must not have an outstanding borrow balance in the asset, * or be providing neccessary collateral for an outstanding borrow. * @param cTokenAddress The address of the asset to be removed * @return Whether or not the account successfully exited the market */ function exitMarket(address cTokenAddress) external returns (uint); function getAllMarkets() external view returns (ICErc20[] memory); function claimComp(address holder) external; function compAccrued(address holder) external view returns (uint); function getCompAddress() external view returns (address); } /* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ISetToken * @author Set Protocol * * Interface for operating with SetTokens. */ interface ISetToken is IERC20 { /* ============ Enums ============ */ enum ModuleState { NONE, PENDING, INITIALIZED } /* ============ Structs ============ */ /** * The base definition of a SetToken Position * * @param component Address of token in the Position * @param module If not in default state, the address of associated module * @param unit Each unit is the # of components per 10^18 of a SetToken * @param positionState Position ENUM. Default is 0; External is 1 * @param data Arbitrary data */ struct Position { address component; address module; int256 unit; uint8 positionState; bytes data; } /** * A struct that stores a component's cash position details and external positions * This data structure allows O(1) access to a component's cash position units and * virtual units. * * @param virtualUnit Virtual value of a component's DEFAULT position. Stored as virtual for efficiency * updating all units at once via the position multiplier. Virtual units are achieved * by dividing a "real" value by the "positionMultiplier" * @param componentIndex * @param externalPositionModules List of external modules attached to each external position. Each module * maps to an external position * @param externalPositions Mapping of module => ExternalPosition struct for a given component */ struct ComponentPosition { int256 virtualUnit; address[] externalPositionModules; mapping(address => ExternalPosition) externalPositions; } /** * A struct that stores a component's external position details including virtual unit and any * auxiliary data. * * @param virtualUnit Virtual value of a component's EXTERNAL position. * @param data Arbitrary data */ struct ExternalPosition { int256 virtualUnit; bytes data; } /* ============ Functions ============ */ function addComponent(address _component) external; function removeComponent(address _component) external; function editDefaultPositionUnit(address _component, int256 _realUnit) external; function addExternalPositionModule(address _component, address _positionModule) external; function removeExternalPositionModule(address _component, address _positionModule) external; function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external; function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external; function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory); function editPositionMultiplier(int256 _newMultiplier) external; function mint(address _account, uint256 _quantity) external; function burn(address _account, uint256 _quantity) external; function lock() external; function unlock() external; function addModule(address _module) external; function removeModule(address _module) external; function initializeModule() external; function setManager(address _manager) external; function manager() external view returns (address); function moduleStates(address _module) external view returns (ModuleState); function getModules() external view returns (address[] memory); function getDefaultPositionRealUnit(address _component) external view returns(int256); function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256); function getComponents() external view returns(address[] memory); function getExternalPositionModules(address _component) external view returns(address[] memory); function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory); function isExternalPositionModule(address _component, address _module) external view returns(bool); function isComponent(address _component) external view returns(bool); function positionMultiplier() external view returns (int256); function getPositions() external view returns (Position[] memory); function getTotalComponentRealUnits(address _component) external view returns(int256); function isInitializedModule(address _module) external view returns(bool); function isPendingModule(address _module) external view returns(bool); function isLocked() external view returns (bool); } /* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ICErc20 * @author Set Protocol * * Interface for interacting with Compound cErc20 tokens (e.g. Dai, USDC) */ interface ICErc20 is IERC20 { function borrowBalanceCurrent(address _account) external returns (uint256); function borrowBalanceStored(address _account) external view returns (uint256); /** * Calculates the exchange rate from the underlying to the CToken * * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external returns (address); /** * Sender supplies assets into the market and receives cTokens in exchange * * @notice Accrues interest whether or not the operation succeeds, unless reverted * @param _mintAmount The amount of the underlying asset to supply * @return uint256 0=success, otherwise a failure */ function mint(uint256 _mintAmount) external returns (uint256); /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param _redeemTokens The number of cTokens to redeem into underlying * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint256 _redeemTokens) external returns (uint256); /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param _redeemAmount The amount of underlying to redeem * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint256 _redeemAmount) external returns (uint256); /** * @notice Sender borrows assets from the protocol to their own address * @param _borrowAmount The amount of the underlying asset to borrow * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint256 _borrowAmount) external returns (uint256); /** * @notice Sender repays their own borrow * @param _repayAmount The amount to repay * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint256 _repayAmount) external returns (uint256); } // 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); }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630f1ff4ba146100515780635fe3b5671461007c578063825409e214610091578063b8d7b669146100b1575b600080fd5b61006461005f3660046102d1565b6100c4565b60405161007393929190610335565b60405180910390f35b610084610136565b6040516100739190610321565b6100a461009f3660046102d1565b61015a565b604051610073919061039f565b6100846100bf366004610299565b610200565b600080606080856040516024016100db9190610321565b60408051601f198184030181529190526020810180516001600160e01b03166374d7814960e11b1790527f0000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b9450600093509150509250925092565b7f0000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b81565b60405163331faf7160e21b81526000906001600160a01b037f0000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b169063cc7ebdc4906101a9908690600401610321565b60206040518083038186803b1580156101c157600080fd5b505afa1580156101d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f99190610309565b9392505050565b60007f0000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b6001600160a01b0316639d1b5a0a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561025b57600080fd5b505afa15801561026f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061029391906102b5565b92915050565b6000602082840312156102aa578081fd5b81356101f9816103a8565b6000602082840312156102c6578081fd5b81516101f9816103a8565b600080604083850312156102e3578081fd5b82356102ee816103a8565b915060208301356102fe816103a8565b809150509250929050565b60006020828403121561031a578081fd5b5051919050565b6001600160a01b0391909116815260200190565b600060018060a01b038516825260208481840152606060408401528351806060850152825b818110156103765785810183015185820160800152820161035a565b818111156103875783608083870101525b50601f01601f19169290920160800195945050505050565b90815260200190565b6001600160a01b03811681146103bd57600080fd5b5056fea26469706673582212201c87fbadc29d4ae41de63cf9ddb6041e61ccf8d9ff8bf560781ac3ba2ba3bf3964736f6c634300060a0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2581, 2497, 2629, 2063, 2475, 2546, 16409, 2683, 17134, 2475, 2098, 2683, 2050, 2683, 2575, 2581, 2050, 8889, 2063, 2620, 2497, 28756, 22394, 5243, 15878, 7011, 2050, 2475, 27717, 1013, 1008, 9385, 25682, 2275, 13625, 4297, 1012, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12646, 2007, 1996, 6105, 1012, 2017, 2089, 6855, 1037, 6100, 1997, 1996, 6105, 2012, 8299, 1024, 1013, 1013, 7479, 1012, 15895, 1012, 8917, 1013, 15943, 1013, 6105, 1011, 1016, 1012, 1014, 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, 2030, 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,999
0x97b65710D03E12775189F0D113202cc1443b0aa2
//WEB: https://astroelon.net //TG: https://t.me/astroeloncadets //TWITTER: https://twitter.com/AstroElon //INSTAGRAM: https://instagram.com/astroeloncadets //GITHUB: https://github.com/astroelon //MEDIUM: https://medium.com/@AstroElon //REDDIT: https://reddit.com/r/AstroElon /* ASTROELON - $ELONONE */ // 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; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } //START contract AstroElon is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); //100 Trillion uint256 private constant _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'ASTROELON'; string private _symbol = 'ELONONE'; uint8 private _decimals = 9; //50 Trillion uint256 public _maxTxAmount = 500000000 * 10**6 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _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); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e996146103cc578063d543dbeb146103f2578063dd62ed3e1461040f578063f2cc0c181461043d578063f2fde38b14610463578063f84354f1146104895761014d565b8063715018a6146103385780637d1db4a5146103405780638da5cb5b1461034857806395d89b411461036c578063a457c2d714610374578063a9059cbb146103a05761014d565b806323b872dd1161011557806323b872dd146102505780632d83811914610286578063313ce567146102a357806339509351146102c15780634549b039146102ed57806370a08231146103125761014d565b8063053ab1821461015257806306fdde0314610171578063095ea7b3146101ee57806313114a9d1461022e57806318160ddd14610248575b600080fd5b61016f6004803603602081101561016857600080fd5b50356104af565b005b610179610587565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b357818101518382015260200161019b565b50505050905090810190601f1680156101e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61021a6004803603604081101561020457600080fd5b506001600160a01b03813516906020013561061d565b604080519115158252519081900360200190f35b61023661063b565b60408051918252519081900360200190f35b610236610641565b61021a6004803603606081101561026657600080fd5b506001600160a01b0381358116916020810135909116906040013561064f565b6102366004803603602081101561029c57600080fd5b50356106d6565b6102ab610738565b6040805160ff9092168252519081900360200190f35b61021a600480360360408110156102d757600080fd5b506001600160a01b038135169060200135610741565b6102366004803603604081101561030357600080fd5b5080359060200135151561078f565b6102366004803603602081101561032857600080fd5b50356001600160a01b0316610827565b61016f610889565b61023661092b565b610350610931565b604080516001600160a01b039092168252519081900360200190f35b610179610940565b61021a6004803603604081101561038a57600080fd5b506001600160a01b0381351690602001356109a1565b61021a600480360360408110156103b657600080fd5b506001600160a01b038135169060200135610a09565b61021a600480360360208110156103e257600080fd5b50356001600160a01b0316610a1d565b61016f6004803603602081101561040857600080fd5b5035610a3b565b6102366004803603604081101561042557600080fd5b506001600160a01b0381358116916020013516610ab8565b61016f6004803603602081101561045357600080fd5b50356001600160a01b0316610ae3565b61016f6004803603602081101561047957600080fd5b50356001600160a01b0316610c69565b61016f6004803603602081101561049f57600080fd5b50356001600160a01b0316610d61565b60006104b9610f22565b6001600160a01b03811660009081526004602052604090205490915060ff16156105145760405162461bcd60e51b815260040180806020018281038252602c815260200180611b82602c913960400191505060405180910390fd5b600061051f83610f26565b505050506001600160a01b0383166000908152600160205260409020549091506105499082610f72565b6001600160a01b03831660009081526001602052604090205560065461056f9082610f72565b60065560075461057f9084610fbb565b600755505050565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b820191906000526020600020905b8154815290600101906020018083116105f657829003601f168201915b5050505050905090565b600061063161062a610f22565b8484611015565b5060015b92915050565b60075490565b69d3c21bcecceda100000090565b600061065c848484611101565b6106cc84610668610f22565b6106c785604051806060016040528060288152602001611ac8602891396001600160a01b038a166000908152600360205260408120906106a6610f22565b6001600160a01b0316815260208101919091526040016000205491906113ab565b611015565b5060019392505050565b60006006548211156107195760405162461bcd60e51b815260040180806020018281038252602a815260200180611a0d602a913960400191505060405180910390fd5b6000610723611442565b905061072f8382611465565b9150505b919050565b600a5460ff1690565b600061063161074e610f22565b846106c7856003600061075f610f22565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fbb565b600069d3c21bcecceda10000008311156107f0576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b8161080e57600061080084610f26565b509294506106359350505050565b600061081984610f26565b509194506106359350505050565b6001600160a01b03811660009081526004602052604081205460ff161561086757506001600160a01b038116600090815260026020526040902054610733565b6001600160a01b038216600090815260016020526040902054610635906106d6565b610891610f22565b6000546001600160a01b039081169116146108e1576040805162461bcd60e51b81526020600482018190526024820152600080516020611af0833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600b5481565b6000546001600160a01b031690565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b60006106316109ae610f22565b846106c785604051806060016040528060258152602001611bae60259139600360006109d8610f22565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906113ab565b6000610631610a16610f22565b8484611101565b6001600160a01b031660009081526004602052604090205460ff1690565b610a43610f22565b6000546001600160a01b03908116911614610a93576040805162461bcd60e51b81526020600482018190526024820152600080516020611af0833981519152604482015290519081900360640190fd5b610ab26064610aac69d3c21bcecceda1000000846114a7565b90611465565b600b5550565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610aeb610f22565b6000546001600160a01b03908116911614610b3b576040805162461bcd60e51b81526020600482018190526024820152600080516020611af0833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff1615610ba9576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526001602052604090205415610c03576001600160a01b038116600090815260016020526040902054610be9906106d6565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b610c71610f22565b6000546001600160a01b03908116911614610cc1576040805162461bcd60e51b81526020600482018190526024820152600080516020611af0833981519152604482015290519081900360640190fd5b6001600160a01b038116610d065760405162461bcd60e51b8152600401808060200182810382526026815260200180611a376026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610d69610f22565b6000546001600160a01b03908116911614610db9576040805162461bcd60e51b81526020600482018190526024820152600080516020611af0833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16610e26576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600554811015610f1e57816001600160a01b031660058281548110610e4a57fe5b6000918252602090912001546001600160a01b03161415610f1657600580546000198101908110610e7757fe5b600091825260209091200154600580546001600160a01b039092169183908110610e9d57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff191690556005805480610eef57fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610f1e565b600101610e29565b5050565b3390565b6000806000806000806000610f3a88611500565b915091506000610f48611442565b90506000806000610f5a8c8686611533565b919e909d50909b509599509397509395505050505050565b6000610fb483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113ab565b9392505050565b600082820183811015610fb4576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03831661105a5760405162461bcd60e51b8152600401808060200182810382526024815260200180611b5e6024913960400191505060405180910390fd5b6001600160a01b03821661109f5760405162461bcd60e51b8152600401808060200182810382526022815260200180611a5d6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111465760405162461bcd60e51b8152600401808060200182810382526025815260200180611b396025913960400191505060405180910390fd5b6001600160a01b03821661118b5760405162461bcd60e51b81526004018080602001828103825260238152602001806119ea6023913960400191505060405180910390fd5b600081116111ca5760405162461bcd60e51b8152600401808060200182810382526029815260200180611b106029913960400191505060405180910390fd5b6111d2610931565b6001600160a01b0316836001600160a01b03161415801561120c57506111f6610931565b6001600160a01b0316826001600160a01b031614155b1561125257600b548111156112525760405162461bcd60e51b8152600401808060200182810382526028815260200180611a7f6028913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff16801561129357506001600160a01b03821660009081526004602052604090205460ff16155b156112a8576112a383838361156f565b6113a6565b6001600160a01b03831660009081526004602052604090205460ff161580156112e957506001600160a01b03821660009081526004602052604090205460ff165b156112f9576112a3838383611686565b6001600160a01b03831660009081526004602052604090205460ff1615801561133b57506001600160a01b03821660009081526004602052604090205460ff16155b1561134b576112a383838361172c565b6001600160a01b03831660009081526004602052604090205460ff16801561138b57506001600160a01b03821660009081526004602052604090205460ff165b1561139b576112a383838361176d565b6113a683838361172c565b505050565b6000818484111561143a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113ff5781810151838201526020016113e7565b50505050905090810190601f16801561142c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600080600061144f6117dd565b909250905061145e8282611465565b9250505090565b6000610fb483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611960565b6000826114b657506000610635565b828202828482816114c357fe5b0414610fb45760405162461bcd60e51b8152600401808060200182810382526021815260200180611aa76021913960400191505060405180910390fd5b6000808061151a6002611514866064611465565b906114a7565b905060006115288583610f72565b935090915050915091565b600080808061154287866114a7565b9050600061155087876114a7565b9050600061155e8383610f72565b929992985090965090945050505050565b600080600080600061158086610f26565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506115b09087610f72565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546115df9086610f72565b6001600160a01b03808a16600090815260016020526040808220939093559089168152205461160e9085610fbb565b6001600160a01b03881660009081526001602052604090205561163183826119c5565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061169786610f26565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506116c79086610f72565b6001600160a01b03808a16600090815260016020908152604080832094909455918a168152600290915220546116fd9083610fbb565b6001600160a01b03881660009081526002602090815260408083209390935560019052205461160e9085610fbb565b600080600080600061173d86610f26565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506115df9086610f72565b600080600080600061177e86610f26565b94509450945094509450866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600654600090819069d3c21bcecceda1000000825b60055481101561191e5782600160006005848154811061180e57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611873575081600260006005848154811061184c57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156118925760065469d3c21bcecceda10000009450945050505061195c565b6118d260016000600584815481106118a657fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490610f72565b925061191460026000600584815481106118e857fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390610f72565b91506001016117f2565b506006546119369069d3c21bcecceda1000000611465565b8210156119565760065469d3c21bcecceda100000093509350505061195c565b90925090505b9091565b600081836119af5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113ff5781810151838201526020016113e7565b5060008385816119bb57fe5b0495945050505050565b6006546119d29083610f72565b6006556007546119e29082610fbb565b600755505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212209de1eaeb0d3e339ee2ea8d0c5ed59563f0f567cfbdd428e5bd8727adcc0114a964736f6c634300060c0033
{"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, 2581, 2497, 26187, 2581, 10790, 2094, 2692, 2509, 2063, 12521, 2581, 23352, 15136, 2683, 2546, 2692, 2094, 14526, 16703, 2692, 2475, 9468, 16932, 23777, 2497, 2692, 11057, 2475, 1013, 1013, 4773, 1024, 16770, 1024, 1013, 1013, 28625, 18349, 2078, 1012, 5658, 1013, 1013, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 28625, 18349, 20909, 3207, 3215, 1013, 1013, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 28625, 18349, 2078, 1013, 1013, 16021, 23091, 1024, 16770, 1024, 1013, 1013, 16021, 23091, 1012, 4012, 1013, 28625, 18349, 20909, 3207, 3215, 1013, 1013, 21025, 2705, 12083, 1024, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28625, 18349, 2078, 1013, 1013, 5396, 1024, 16770, 1024, 1013, 1013, 5396, 1012, 4012, 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 ]